Commit 304eb8d2 authored by Justin Gibbs's avatar Justin Gibbs Committed by facebook-github-bot-1

Prefer template aliases to classes in IntrusiveList

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
parent c2dc18ba
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment