Prefer template aliases to classes in IntrusiveList
authorJustin Gibbs <gibbs@fb.com>
Thu, 29 Oct 2015 21:35:22 +0000 (14:35 -0700)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Thu, 29 Oct 2015 22:20:21 +0000 (15:20 -0700)
Summary: Convert helper classes to using statements now that GCC has caught up
with c++11.

Reviewed By: simpkins

Differential Revision: D2561364

fb-gh-sync-id: 712591549aba9450d159468dc3b26a987ffe9b82

folly/IntrusiveList.h

index bb1979bf6d11b108a7b383ca9086aac4caa1cbd2..5e47c347e8394793621abcf332e95641b8e81993 100644 (file)
@@ -18,7 +18,7 @@
 #define FOLLY_INTRUSIVELIST_H_
 
 /*
- * This file contains convenience typedefs that make boost::intrusive::list
+ * This file contains convenience aliases that make boost::intrusive::list
  * easier to use.
  */
 
@@ -29,9 +29,8 @@ namespace folly {
 /**
  * An auto-unlink intrusive list hook.
  */
-typedef boost::intrusive::list_member_hook<
-      boost::intrusive::link_mode<boost::intrusive::auto_unlink> >
-        IntrusiveListHook;
+using IntrusiveListHook = boost::intrusive::list_member_hook<
+      boost::intrusive::link_mode<boost::intrusive::auto_unlink>>;
 
 /**
  * An intrusive list.
@@ -50,7 +49,7 @@ typedef boost::intrusive::list_member_hook<
  *     IntrusiveListHook listHook;
  *   };
  *
- *   typedef IntrusiveList<Foo, &Foo::listHook> FooList;
+ *   using FooList = IntrusiveList<Foo, &Foo::listHook>;
  *
  *   Foo *foo = new Foo();
  *   FooList myList;
@@ -62,25 +61,18 @@ typedef boost::intrusive::list_member_hook<
  *
  * The elements stored in the list must contain an IntrusiveListHook member
  * variable.
- *
- * TODO: This should really be a template alias.  However, gcc doesn't support
- * template aliases yet.  A subclass is a reasonable workaround for now.  This
- * subclass only supports the default constructor, but we could add other
- * constructors if necessary.
  */
 template<typename T, IntrusiveListHook T::* PtrToMember>
-class IntrusiveList : public boost::intrusive::list<
+using IntrusiveList = boost::intrusive::list<
     T,
     boost::intrusive::member_hook<T, IntrusiveListHook, PtrToMember>,
-    boost::intrusive::constant_time_size<false> > {
-};
+    boost::intrusive::constant_time_size<false>>;
 
 /**
  * A safe-link intrusive list hook.
  */
-typedef boost::intrusive::list_member_hook<
-      boost::intrusive::link_mode<boost::intrusive::safe_link> >
-        SafeIntrusiveListHook;
+using SafeIntrusiveListHook = boost::intrusive::list_member_hook<
+      boost::intrusive::link_mode<boost::intrusive::safe_link>>;
 
 /**
  * An intrusive list with const-time size() method.
@@ -104,7 +96,7 @@ typedef boost::intrusive::list_member_hook<
  *     SafeIntrusiveListHook listHook;
  *   };
  *
- *   typedef CountedIntrusiveList<Foo, &Foo::listHook> FooList;
+ *   using FooList = CountedIntrusiveList<Foo, &Foo::listHook> FooList;
  *
  *   Foo *foo = new Foo();
  *   FooList myList;
@@ -117,18 +109,12 @@ typedef boost::intrusive::list_member_hook<
  *
  * The elements stored in the list must contain an SafeIntrusiveListHook member
  * variable.
- *
- * TODO: This should really be a template alias.  However, gcc doesn't support
- * template aliases yet.  A subclass is a reasonable workaround for now.  This
- * subclass only supports the default constructor, but we could add other
- * constructors if necessary.
  */
 template<typename T, SafeIntrusiveListHook T::* PtrToMember>
-class CountedIntrusiveList : public boost::intrusive::list<
+using CountedIntrusiveList = boost::intrusive::list<
     T,
     boost::intrusive::member_hook<T, SafeIntrusiveListHook, PtrToMember>,
-    boost::intrusive::constant_time_size<true> > {
-};
+    boost::intrusive::constant_time_size<true>>;
 
 } // folly