summaryrefslogtreecommitdiff
path: root/shared/loki
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:10:11 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:10:11 +0200
commitc0cdb2ad99a1e2a6ade5ce76c91177a79258e669 (patch)
tree4701a015385d9a6a5a4ba99a8f1f5d400fff26b1 /shared/loki
parent3.13 (diff)
downloadFreeFileSync-c0cdb2ad99a1e2a6ade5ce76c91177a79258e669.tar.gz
FreeFileSync-c0cdb2ad99a1e2a6ade5ce76c91177a79258e669.tar.bz2
FreeFileSync-c0cdb2ad99a1e2a6ade5ce76c91177a79258e669.zip
3.14
Diffstat (limited to 'shared/loki')
-rw-r--r--shared/loki/AbstractFactory.h216
-rw-r--r--shared/loki/Allocator.h32
-rw-r--r--shared/loki/AssocVector.h548
-rw-r--r--shared/loki/CachedFactory.h2002
-rw-r--r--shared/loki/CheckReturn.h108
-rw-r--r--shared/loki/Checker.h46
-rw-r--r--shared/loki/ConstPolicy.h30
-rw-r--r--shared/loki/DataGenerators.h96
-rw-r--r--shared/loki/EmptyType.h46
-rw-r--r--shared/loki/Factory.h1828
-rw-r--r--shared/loki/Function.h598
-rw-r--r--shared/loki/Functor.h2813
-rw-r--r--shared/loki/HierarchyGenerators.h374
-rw-r--r--shared/loki/Key.h1442
-rw-r--r--shared/loki/LevelMutex.h204
-rw-r--r--shared/loki/LockingPtr.h156
-rw-r--r--shared/loki/LokiExport.h18
-rw-r--r--shared/loki/LokiTypeInfo.h142
-rw-r--r--shared/loki/MultiMethods.h586
-rw-r--r--shared/loki/NullType.h18
-rw-r--r--shared/loki/OrderedStatic.h376
-rw-r--r--shared/loki/Pimpl.h288
-rw-r--r--shared/loki/RefToValue.h96
-rw-r--r--shared/loki/Register.h170
-rw-r--r--shared/loki/SPCachedFactory.h292
-rw-r--r--shared/loki/SafeBits.h128
-rw-r--r--shared/loki/SafeFormat.h1022
-rw-r--r--shared/loki/ScopeGuard.h1220
-rw-r--r--shared/loki/Sequence.h54
-rw-r--r--shared/loki/Singleton.h1426
-rw-r--r--shared/loki/SmallObj.cpp582
-rw-r--r--shared/loki/SmallObj.h1106
-rw-r--r--shared/loki/SmartPtr.h2276
-rw-r--r--shared/loki/StrongPtr.h816
-rw-r--r--shared/loki/Threads.h486
-rw-r--r--shared/loki/Tuple.h14
-rw-r--r--shared/loki/TypeManip.h244
-rw-r--r--shared/loki/TypeTraits.h4238
-rw-r--r--shared/loki/Typelist.h580
-rw-r--r--shared/loki/TypelistMacros.h14
-rw-r--r--shared/loki/Visitor.h314
-rw-r--r--shared/loki/static_check.h18
42 files changed, 13592 insertions, 13471 deletions
diff --git a/shared/loki/AbstractFactory.h b/shared/loki/AbstractFactory.h
index 8ff518dc..9a30583b 100644
--- a/shared/loki/AbstractFactory.h
+++ b/shared/loki/AbstractFactory.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_ABSTRACTFACTORY_INC_
@@ -31,7 +31,7 @@
* \ingroup FactoriesGroup
* \brief Implements an abstract object factory.
*/
-
+
/**
* \class AbstractFactory
* \ingroup AbstractFactoryGroup
@@ -46,137 +46,137 @@ namespace Loki
// The building block of an Abstract Factory
////////////////////////////////////////////////////////////////////////////////
- template <class T>
- class AbstractFactoryUnit
- {
- public:
- virtual T* DoCreate(Type2Type<T>) = 0;
- virtual ~AbstractFactoryUnit() {}
- };
+template <class T>
+class AbstractFactoryUnit
+{
+public:
+ virtual T* DoCreate(Type2Type<T>) = 0;
+ virtual ~AbstractFactoryUnit() {}
+};
////////////////////////////////////////////////////////////////////////////////
// class template AbstractFactory
// Defines an Abstract Factory interface starting from a typelist
////////////////////////////////////////////////////////////////////////////////
- template
- <
- class TList,
- template <class> class Unit = AbstractFactoryUnit
- >
- class AbstractFactory : public GenScatterHierarchy<TList, Unit>
+template
+<
+class TList,
+ template <class> class Unit = AbstractFactoryUnit
+ >
+class AbstractFactory : public GenScatterHierarchy<TList, Unit>
+{
+public:
+ typedef TList ProductList;
+
+ template <class T> T* Create()
{
- public:
- typedef TList ProductList;
-
- template <class T> T* Create()
- {
- Unit<T>& unit = *this;
- return unit.DoCreate(Type2Type<T>());
- }
- };
-
+ Unit<T>& unit = *this;
+ return unit.DoCreate(Type2Type<T>());
+ }
+};
+
////////////////////////////////////////////////////////////////////////////////
// class template OpNewFactoryUnit
// Creates an object by invoking the new operator
////////////////////////////////////////////////////////////////////////////////
- template <class ConcreteProduct, class Base>
- class OpNewFactoryUnit : public Base
+template <class ConcreteProduct, class Base>
+class OpNewFactoryUnit : public Base
+{
+ typedef typename Base::ProductList BaseProductList;
+
+protected:
+ typedef typename BaseProductList::Tail ProductList;
+
+public:
+ typedef typename BaseProductList::Head AbstractProduct;
+ ConcreteProduct* DoCreate(Type2Type<AbstractProduct>)
{
- typedef typename Base::ProductList BaseProductList;
-
- protected:
- typedef typename BaseProductList::Tail ProductList;
-
- public:
- typedef typename BaseProductList::Head AbstractProduct;
- ConcreteProduct* DoCreate(Type2Type<AbstractProduct>)
- {
- return new ConcreteProduct;
- }
- };
+ return new ConcreteProduct;
+ }
+};
////////////////////////////////////////////////////////////////////////////////
// class template PrototypeFactoryUnit
// Creates an object by cloning a prototype
// There is a difference between the implementation herein and the one described
-// in the book: GetPrototype and SetPrototype use the helper friend
+// in the book: GetPrototype and SetPrototype use the helper friend
// functions DoGetPrototype and DoSetPrototype. The friend functions avoid
// name hiding issues. Plus, GetPrototype takes a reference to pointer
// instead of returning the pointer by value.
////////////////////////////////////////////////////////////////////////////////
- template <class ConcreteProduct, class Base>
- class PrototypeFactoryUnit : public Base
+template <class ConcreteProduct, class Base>
+class PrototypeFactoryUnit : public Base
+{
+ typedef typename Base::ProductList BaseProductList;
+
+protected:
+ typedef typename BaseProductList::Tail ProductList;
+
+public:
+ typedef typename BaseProductList::Head AbstractProduct;
+
+ PrototypeFactoryUnit(AbstractProduct* p = 0)
+ : pPrototype_(p)
+ {}
+
+ template <class CP, class Base1>
+ friend void DoGetPrototype(const PrototypeFactoryUnit<CP, Base1>& me,
+ typename Base1::ProductList::Head*& pPrototype);
+
+ template <class CP, class Base1>
+ friend void DoSetPrototype(PrototypeFactoryUnit<CP, Base1>& me,
+ typename Base1::ProductList::Head* pObj);
+
+ template <class U>
+ void GetPrototype(U*& p)
+ { return DoGetPrototype(*this, p); }
+
+ template <class U>
+ void SetPrototype(U* pObj)
+ { DoSetPrototype(*this, pObj); }
+
+ AbstractProduct* DoCreate(Type2Type<AbstractProduct>)
{
- typedef typename Base::ProductList BaseProductList;
-
- protected:
- typedef typename BaseProductList::Tail ProductList;
-
- public:
- typedef typename BaseProductList::Head AbstractProduct;
-
- PrototypeFactoryUnit(AbstractProduct* p = 0)
- : pPrototype_(p)
- {}
-
- template <class CP, class Base1>
- friend void DoGetPrototype(const PrototypeFactoryUnit<CP, Base1>& me,
- typename Base1::ProductList::Head*& pPrototype);
-
- template <class CP, class Base1>
- friend void DoSetPrototype(PrototypeFactoryUnit<CP, Base1>& me,
- typename Base1::ProductList::Head* pObj);
-
- template <class U>
- void GetPrototype(U*& p)
- { return DoGetPrototype(*this, p); }
-
- template <class U>
- void SetPrototype(U* pObj)
- { DoSetPrototype(*this, pObj); }
-
- AbstractProduct* DoCreate(Type2Type<AbstractProduct>)
- {
- assert(pPrototype_);
- return pPrototype_->Clone();
- }
-
- private:
- AbstractProduct* pPrototype_;
- };
-
- template <class CP, class Base>
- inline void DoGetPrototype(const PrototypeFactoryUnit<CP, Base>& me,
- typename Base::ProductList::Head*& pPrototype)
- { pPrototype = me.pPrototype_; }
-
- template <class CP, class Base>
- inline void DoSetPrototype(PrototypeFactoryUnit<CP, Base>& me,
- typename Base::ProductList::Head* pObj)
- { me.pPrototype_ = pObj; }
+ assert(pPrototype_);
+ return pPrototype_->Clone();
+ }
+
+private:
+ AbstractProduct* pPrototype_;
+};
+
+template <class CP, class Base>
+inline void DoGetPrototype(const PrototypeFactoryUnit<CP, Base>& me,
+ typename Base::ProductList::Head*& pPrototype)
+{ pPrototype = me.pPrototype_; }
+
+template <class CP, class Base>
+inline void DoSetPrototype(PrototypeFactoryUnit<CP, Base>& me,
+ typename Base::ProductList::Head* pObj)
+{ me.pPrototype_ = pObj; }
////////////////////////////////////////////////////////////////////////////////
// class template ConcreteFactory
// Implements an AbstractFactory interface
////////////////////////////////////////////////////////////////////////////////
- template
- <
- class AbstractFact,
- template <class, class> class Creator = OpNewFactoryUnit,
- class TList = typename AbstractFact::ProductList
- >
- class ConcreteFactory
- : public GenLinearHierarchy<
- typename TL::Reverse<TList>::Result, Creator, AbstractFact>
- {
- public:
- typedef typename AbstractFact::ProductList ProductList;
- typedef TList ConcreteProductList;
- };
+template
+<
+class AbstractFact,
+ template <class, class> class Creator = OpNewFactoryUnit,
+ class TList = typename AbstractFact::ProductList
+ >
+class ConcreteFactory
+ : public GenLinearHierarchy<
+ typename TL::Reverse<TList>::Result, Creator, AbstractFact>
+{
+public:
+ typedef typename AbstractFact::ProductList ProductList;
+ typedef TList ConcreteProductList;
+};
} // namespace Loki
diff --git a/shared/loki/Allocator.h b/shared/loki/Allocator.h
index a79ee061..39b63912 100644
--- a/shared/loki/Allocator.h
+++ b/shared/loki/Allocator.h
@@ -2,12 +2,12 @@
// The Loki Library
// Copyright (c) 2008 by Rich Sposato
//
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
@@ -35,26 +35,26 @@ namespace Loki
*/
template
<
- typename Type,
- typename AllocT = Loki::AllocatorSingleton<>
->
+typename Type,
+ typename AllocT = Loki::AllocatorSingleton<>
+ >
class LokiAllocator
{
public:
typedef ::std::size_t size_type;
typedef ::std::ptrdiff_t difference_type;
- typedef Type * pointer;
- typedef const Type * const_pointer;
- typedef Type & reference;
- typedef const Type & const_reference;
+ typedef Type* pointer;
+ typedef const Type* const_pointer;
+ typedef Type& reference;
+ typedef const Type& const_reference;
typedef Type value_type;
/// Default constructor does nothing.
inline LokiAllocator( void ) throw() { }
/// Copy constructor does nothing.
- inline LokiAllocator( const LokiAllocator & ) throw() { }
+ inline LokiAllocator( const LokiAllocator& ) throw() { }
/// Type converting allocator constructor does nothing.
template < typename Type1 >
@@ -84,10 +84,10 @@ public:
@param hint Place where caller thinks allocation should occur.
@return Pointer to block of memory.
*/
- pointer allocate( size_type count, const void * hint = 0 )
+ pointer allocate( size_type count, const void* hint = 0 )
{
(void)hint; // Ignore the hint.
- void * p = AllocT::Instance().Allocate( count * sizeof( Type ), true );
+ void* p = AllocT::Instance().Allocate( count * sizeof( Type ), true );
return reinterpret_cast< pointer >( p );
}
@@ -108,7 +108,7 @@ public:
}
/// Construct an element at the pointer.
- void construct( pointer p, const Type & value )
+ void construct( pointer p, const Type& value )
{
// A call to global placement new forces a call to copy constructor.
::new( p ) Type( value );
diff --git a/shared/loki/AssocVector.h b/shared/loki/AssocVector.h
index 905e0963..ad43d152 100644
--- a/shared/loki/AssocVector.h
+++ b/shared/loki/AssocVector.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_ASSOCVECTOR_INC_
@@ -30,38 +30,38 @@ namespace Loki
// Used by AssocVector
////////////////////////////////////////////////////////////////////////////////
- namespace Private
- {
- template <class Value, class C>
- class AssocVectorCompare : public C
- {
- typedef std::pair<typename C::first_argument_type, Value>
- Data;
- typedef typename C::first_argument_type first_argument_type;
-
- public:
- AssocVectorCompare()
- {}
-
- AssocVectorCompare(const C& src) : C(src)
- {}
-
- bool operator()(const first_argument_type& lhs,
- const first_argument_type& rhs) const
- { return C::operator()(lhs, rhs); }
-
- bool operator()(const Data& lhs, const Data& rhs) const
- { return operator()(lhs.first, rhs.first); }
-
- bool operator()(const Data& lhs,
- const first_argument_type& rhs) const
- { return operator()(lhs.first, rhs); }
-
- bool operator()(const first_argument_type& lhs,
- const Data& rhs) const
- { return operator()(lhs, rhs.first); }
- };
- }
+namespace Private
+{
+template <class Value, class C>
+class AssocVectorCompare : public C
+{
+ typedef std::pair<typename C::first_argument_type, Value>
+ Data;
+ typedef typename C::first_argument_type first_argument_type;
+
+public:
+ AssocVectorCompare()
+ {}
+
+ AssocVectorCompare(const C& src) : C(src)
+ {}
+
+ bool operator()(const first_argument_type& lhs,
+ const first_argument_type& rhs) const
+ { return C::operator()(lhs, rhs); }
+
+ bool operator()(const Data& lhs, const Data& rhs) const
+ { return operator()(lhs.first, rhs.first); }
+
+ bool operator()(const Data& lhs,
+ const first_argument_type& rhs) const
+ { return operator()(lhs.first, rhs); }
+
+ bool operator()(const first_argument_type& lhs,
+ const Data& rhs) const
+ { return operator()(lhs, rhs.first); }
+};
+}
////////////////////////////////////////////////////////////////////////////////
// class template AssocVector
@@ -75,283 +75,283 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
- template
- <
- class K,
- class V,
- class C = std::less<K>,
- class A = std::allocator< std::pair<K, V> >
- >
- class AssocVector
- : private std::vector< std::pair<K, V>, A >
- , private Private::AssocVectorCompare<V, C>
+template
+<
+class K,
+ class V,
+ class C = std::less<K>,
+ class A = std::allocator< std::pair<K, V> >
+ >
+class AssocVector
+ : private std::vector< std::pair<K, V>, A >
+ , private Private::AssocVectorCompare<V, C>
+{
+ typedef std::vector<std::pair<K, V>, A> Base;
+ typedef Private::AssocVectorCompare<V, C> MyCompare;
+
+public:
+ typedef K key_type;
+ typedef V mapped_type;
+ typedef typename Base::value_type value_type;
+
+ typedef C key_compare;
+ typedef A allocator_type;
+ typedef typename A::reference reference;
+ typedef typename A::const_reference const_reference;
+ typedef typename Base::iterator iterator;
+ typedef typename Base::const_iterator const_iterator;
+ typedef typename Base::size_type size_type;
+ typedef typename Base::difference_type difference_type;
+ typedef typename A::pointer pointer;
+ typedef typename A::const_pointer const_pointer;
+ typedef typename Base::reverse_iterator reverse_iterator;
+ typedef typename Base::const_reverse_iterator const_reverse_iterator;
+
+ class value_compare
+ : public std::binary_function<value_type, value_type, bool>
+ , private key_compare
{
- typedef std::vector<std::pair<K, V>, A> Base;
- typedef Private::AssocVectorCompare<V, C> MyCompare;
+ friend class AssocVector;
+
+ protected:
+ value_compare(key_compare pred) : key_compare(pred)
+ {}
public:
- typedef K key_type;
- typedef V mapped_type;
- typedef typename Base::value_type value_type;
-
- typedef C key_compare;
- typedef A allocator_type;
- typedef typename A::reference reference;
- typedef typename A::const_reference const_reference;
- typedef typename Base::iterator iterator;
- typedef typename Base::const_iterator const_iterator;
- typedef typename Base::size_type size_type;
- typedef typename Base::difference_type difference_type;
- typedef typename A::pointer pointer;
- typedef typename A::const_pointer const_pointer;
- typedef typename Base::reverse_iterator reverse_iterator;
- typedef typename Base::const_reverse_iterator const_reverse_iterator;
-
- class value_compare
- : public std::binary_function<value_type, value_type, bool>
- , private key_compare
- {
- friend class AssocVector;
-
- protected:
- value_compare(key_compare pred) : key_compare(pred)
- {}
-
- public:
- bool operator()(const value_type& lhs, const value_type& rhs) const
- { return key_compare::operator()(lhs.first, rhs.first); }
- };
-
- // 23.3.1.1 construct/copy/destroy
-
- explicit AssocVector(const key_compare& comp = key_compare(),
- const A& alloc = A())
+ bool operator()(const value_type& lhs, const value_type& rhs) const
+ { return key_compare::operator()(lhs.first, rhs.first); }
+ };
+
+ // 23.3.1.1 construct/copy/destroy
+
+ explicit AssocVector(const key_compare& comp = key_compare(),
+ const A& alloc = A())
: Base(alloc), MyCompare(comp)
- {}
-
- template <class InputIterator>
- AssocVector(InputIterator first, InputIterator last,
- const key_compare& comp = key_compare(),
- const A& alloc = A())
+ {}
+
+ template <class InputIterator>
+ AssocVector(InputIterator first, InputIterator last,
+ const key_compare& comp = key_compare(),
+ const A& alloc = A())
: Base(first, last, alloc), MyCompare(comp)
- {
- MyCompare& me = *this;
- std::sort(begin(), end(), me);
- }
-
- AssocVector& operator=(const AssocVector& rhs)
- {
- AssocVector(rhs).swap(*this);
- return *this;
- }
+ {
+ MyCompare& me = *this;
+ std::sort(begin(), end(), me);
+ }
- // iterators:
- // The following are here because MWCW gets 'using' wrong
- iterator begin() { return Base::begin(); }
- const_iterator begin() const { return Base::begin(); }
- iterator end() { return Base::end(); }
- const_iterator end() const { return Base::end(); }
- reverse_iterator rbegin() { return Base::rbegin(); }
- const_reverse_iterator rbegin() const { return Base::rbegin(); }
- reverse_iterator rend() { return Base::rend(); }
- const_reverse_iterator rend() const { return Base::rend(); }
-
- // capacity:
- bool empty() const { return Base::empty(); }
- size_type size() const { return Base::size(); }
- size_type max_size() { return Base::max_size(); }
-
- // 23.3.1.2 element access:
- mapped_type& operator[](const key_type& key)
- { return insert(value_type(key, mapped_type())).first->second; }
-
- // modifiers:
- std::pair<iterator, bool> insert(const value_type& val)
- {
- bool found(true);
- iterator i(lower_bound(val.first));
-
- if (i == end() || this->operator()(val.first, i->first))
- {
- i = Base::insert(i, val);
- found = false;
- }
- return std::make_pair(i, !found);
- }
- //Section [23.1.2], Table 69
- //http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/libstdc++/23_containers/howto.html#4
- iterator insert(iterator pos, const value_type& val)
+ AssocVector& operator=(const AssocVector& rhs)
+ {
+ AssocVector(rhs).swap(*this);
+ return *this;
+ }
+
+ // iterators:
+ // The following are here because MWCW gets 'using' wrong
+ iterator begin() { return Base::begin(); }
+ const_iterator begin() const { return Base::begin(); }
+ iterator end() { return Base::end(); }
+ const_iterator end() const { return Base::end(); }
+ reverse_iterator rbegin() { return Base::rbegin(); }
+ const_reverse_iterator rbegin() const { return Base::rbegin(); }
+ reverse_iterator rend() { return Base::rend(); }
+ const_reverse_iterator rend() const { return Base::rend(); }
+
+ // capacity:
+ bool empty() const { return Base::empty(); }
+ size_type size() const { return Base::size(); }
+ size_type max_size() { return Base::max_size(); }
+
+ // 23.3.1.2 element access:
+ mapped_type& operator[](const key_type& key)
+ { return insert(value_type(key, mapped_type())).first->second; }
+
+ // modifiers:
+ std::pair<iterator, bool> insert(const value_type& val)
+ {
+ bool found(true);
+ iterator i(lower_bound(val.first));
+
+ if (i == end() || this->operator()(val.first, i->first))
{
- if( (pos == begin() || this->operator()(*(pos-1),val)) &&
- (pos == end() || this->operator()(val, *pos)) )
- {
- return Base::insert(pos, val);
- }
- return insert(val).first;
+ i = Base::insert(i, val);
+ found = false;
}
-
- template <class InputIterator>
- void insert(InputIterator first, InputIterator last)
- { for (; first != last; ++first) insert(*first); }
-
- void erase(iterator pos)
- { Base::erase(pos); }
-
- size_type erase(const key_type& k)
+ return std::make_pair(i, !found);
+ }
+ //Section [23.1.2], Table 69
+ //http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/libstdc++/23_containers/howto.html#4
+ iterator insert(iterator pos, const value_type& val)
+ {
+ if( (pos == begin() || this->operator()(*(pos-1),val)) &&
+ (pos == end() || this->operator()(val, *pos)) )
{
- iterator i(find(k));
- if (i == end()) return 0;
- erase(i);
- return 1;
+ return Base::insert(pos, val);
}
+ return insert(val).first;
+ }
- void erase(iterator first, iterator last)
- { Base::erase(first, last); }
+ template <class InputIterator>
+ void insert(InputIterator first, InputIterator last)
+ { for (; first != last; ++first) insert(*first); }
- void swap(AssocVector& other)
- {
- Base::swap(other);
- MyCompare& me = *this;
- MyCompare& rhs = other;
- std::swap(me, rhs);
- }
-
- void clear()
- { Base::clear(); }
+ void erase(iterator pos)
+ { Base::erase(pos); }
- // observers:
- key_compare key_comp() const
- { return *this; }
+ size_type erase(const key_type& k)
+ {
+ iterator i(find(k));
+ if (i == end()) return 0;
+ erase(i);
+ return 1;
+ }
- value_compare value_comp() const
- {
- const key_compare& comp = *this;
- return value_compare(comp);
- }
+ void erase(iterator first, iterator last)
+ { Base::erase(first, last); }
- // 23.3.1.3 map operations:
- iterator find(const key_type& k)
- {
- iterator i(lower_bound(k));
- if (i != end() && this->operator()(k, i->first))
- {
- i = end();
- }
- return i;
- }
+ void swap(AssocVector& other)
+ {
+ Base::swap(other);
+ MyCompare& me = *this;
+ MyCompare& rhs = other;
+ std::swap(me, rhs);
+ }
- const_iterator find(const key_type& k) const
- {
- const_iterator i(lower_bound(k));
- if (i != end() && this->operator()(k, i->first))
- {
- i = end();
- }
- return i;
- }
+ void clear()
+ { Base::clear(); }
- size_type count(const key_type& k) const
- { return find(k) != end(); }
+ // observers:
+ key_compare key_comp() const
+ { return *this; }
- iterator lower_bound(const key_type& k)
- {
- MyCompare& me = *this;
- return std::lower_bound(begin(), end(), k, me);
- }
-
- const_iterator lower_bound(const key_type& k) const
- {
- const MyCompare& me = *this;
- return std::lower_bound(begin(), end(), k, me);
- }
+ value_compare value_comp() const
+ {
+ const key_compare& comp = *this;
+ return value_compare(comp);
+ }
- iterator upper_bound(const key_type& k)
+ // 23.3.1.3 map operations:
+ iterator find(const key_type& k)
+ {
+ iterator i(lower_bound(k));
+ if (i != end() && this->operator()(k, i->first))
{
- MyCompare& me = *this;
- return std::upper_bound(begin(), end(), k, me);
+ i = end();
}
+ return i;
+ }
- const_iterator upper_bound(const key_type& k) const
+ const_iterator find(const key_type& k) const
+ {
+ const_iterator i(lower_bound(k));
+ if (i != end() && this->operator()(k, i->first))
{
- const MyCompare& me = *this;
- return std::upper_bound(begin(), end(), k, me);
+ i = end();
}
+ return i;
+ }
- std::pair<iterator, iterator> equal_range(const key_type& k)
- {
- MyCompare& me = *this;
- return std::equal_range(begin(), end(), k, me);
- }
+ size_type count(const key_type& k) const
+ { return find(k) != end(); }
- std::pair<const_iterator, const_iterator> equal_range(
- const key_type& k) const
- {
- const MyCompare& me = *this;
- return std::equal_range(begin(), end(), k, me);
- }
+ iterator lower_bound(const key_type& k)
+ {
+ MyCompare& me = *this;
+ return std::lower_bound(begin(), end(), k, me);
+ }
- template <class K1, class V1, class C1, class A1>
- friend bool operator==(const AssocVector<K1, V1, C1, A1>& lhs,
- const AssocVector<K1, V1, C1, A1>& rhs);
+ const_iterator lower_bound(const key_type& k) const
+ {
+ const MyCompare& me = *this;
+ return std::lower_bound(begin(), end(), k, me);
+ }
- bool operator<(const AssocVector& rhs) const
- {
- const Base& me = *this;
- const Base& yo = rhs;
- return me < yo;
- }
+ iterator upper_bound(const key_type& k)
+ {
+ MyCompare& me = *this;
+ return std::upper_bound(begin(), end(), k, me);
+ }
- template <class K1, class V1, class C1, class A1>
- friend bool operator!=(const AssocVector<K1, V1, C1, A1>& lhs,
- const AssocVector<K1, V1, C1, A1>& rhs);
+ const_iterator upper_bound(const key_type& k) const
+ {
+ const MyCompare& me = *this;
+ return std::upper_bound(begin(), end(), k, me);
+ }
- template <class K1, class V1, class C1, class A1>
- friend bool operator>(const AssocVector<K1, V1, C1, A1>& lhs,
- const AssocVector<K1, V1, C1, A1>& rhs);
+ std::pair<iterator, iterator> equal_range(const key_type& k)
+ {
+ MyCompare& me = *this;
+ return std::equal_range(begin(), end(), k, me);
+ }
- template <class K1, class V1, class C1, class A1>
- friend bool operator>=(const AssocVector<K1, V1, C1, A1>& lhs,
- const AssocVector<K1, V1, C1, A1>& rhs);
+ std::pair<const_iterator, const_iterator> equal_range(
+ const key_type& k) const
+ {
+ const MyCompare& me = *this;
+ return std::equal_range(begin(), end(), k, me);
+ }
- template <class K1, class V1, class C1, class A1>
- friend bool operator<=(const AssocVector<K1, V1, C1, A1>& lhs,
- const AssocVector<K1, V1, C1, A1>& rhs);
- };
+ template <class K1, class V1, class C1, class A1>
+ friend bool operator==(const AssocVector<K1, V1, C1, A1>& lhs,
+ const AssocVector<K1, V1, C1, A1>& rhs);
- template <class K, class V, class C, class A>
- inline bool operator==(const AssocVector<K, V, C, A>& lhs,
- const AssocVector<K, V, C, A>& rhs)
+ bool operator<(const AssocVector& rhs) const
{
- const std::vector<std::pair<K, V>, A>& me = lhs;
- return me == rhs;
+ const Base& me = *this;
+ const Base& yo = rhs;
+ return me < yo;
}
- template <class K, class V, class C, class A>
- inline bool operator!=(const AssocVector<K, V, C, A>& lhs,
- const AssocVector<K, V, C, A>& rhs)
- { return !(lhs == rhs); }
+ template <class K1, class V1, class C1, class A1>
+ friend bool operator!=(const AssocVector<K1, V1, C1, A1>& lhs,
+ const AssocVector<K1, V1, C1, A1>& rhs);
+
+ template <class K1, class V1, class C1, class A1>
+ friend bool operator>(const AssocVector<K1, V1, C1, A1>& lhs,
+ const AssocVector<K1, V1, C1, A1>& rhs);
+
+ template <class K1, class V1, class C1, class A1>
+ friend bool operator>=(const AssocVector<K1, V1, C1, A1>& lhs,
+ const AssocVector<K1, V1, C1, A1>& rhs);
+
+ template <class K1, class V1, class C1, class A1>
+ friend bool operator<=(const AssocVector<K1, V1, C1, A1>& lhs,
+ const AssocVector<K1, V1, C1, A1>& rhs);
+};
+
+template <class K, class V, class C, class A>
+inline bool operator==(const AssocVector<K, V, C, A>& lhs,
+ const AssocVector<K, V, C, A>& rhs)
+{
+ const std::vector<std::pair<K, V>, A>& me = lhs;
+ return me == rhs;
+}
+
+template <class K, class V, class C, class A>
+inline bool operator!=(const AssocVector<K, V, C, A>& lhs,
+ const AssocVector<K, V, C, A>& rhs)
+{ return !(lhs == rhs); }
+
+template <class K, class V, class C, class A>
+inline bool operator>(const AssocVector<K, V, C, A>& lhs,
+ const AssocVector<K, V, C, A>& rhs)
+{ return rhs < lhs; }
- template <class K, class V, class C, class A>
- inline bool operator>(const AssocVector<K, V, C, A>& lhs,
- const AssocVector<K, V, C, A>& rhs)
- { return rhs < lhs; }
+template <class K, class V, class C, class A>
+inline bool operator>=(const AssocVector<K, V, C, A>& lhs,
+ const AssocVector<K, V, C, A>& rhs)
+{ return !(lhs < rhs); }
- template <class K, class V, class C, class A>
- inline bool operator>=(const AssocVector<K, V, C, A>& lhs,
- const AssocVector<K, V, C, A>& rhs)
- { return !(lhs < rhs); }
+template <class K, class V, class C, class A>
+inline bool operator<=(const AssocVector<K, V, C, A>& lhs,
+ const AssocVector<K, V, C, A>& rhs)
+{ return !(rhs < lhs); }
- template <class K, class V, class C, class A>
- inline bool operator<=(const AssocVector<K, V, C, A>& lhs,
- const AssocVector<K, V, C, A>& rhs)
- { return !(rhs < lhs); }
+// specialized algorithms:
+template <class K, class V, class C, class A>
+void swap(AssocVector<K, V, C, A>& lhs, AssocVector<K, V, C, A>& rhs)
+{ lhs.swap(rhs); }
- // specialized algorithms:
- template <class K, class V, class C, class A>
- void swap(AssocVector<K, V, C, A>& lhs, AssocVector<K, V, C, A>& rhs)
- { lhs.swap(rhs); }
-
} // namespace Loki
#endif // end file guardian
diff --git a/shared/loki/CachedFactory.h b/shared/loki/CachedFactory.h
index 15c9a801..567b035c 100644
--- a/shared/loki/CachedFactory.h
+++ b/shared/loki/CachedFactory.h
@@ -4,16 +4,16 @@
//
// Code covered by the MIT License
//
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
//
// The authors make no representations about the suitability of this software
// for any purpose. It is provided "as is" without express or implied warranty.
//
// This code DOES NOT accompany the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
//
////////////////////////////////////////////////////////////////////////////////
@@ -32,9 +32,9 @@
#include <loki/Key.h>
#ifdef DO_EXTRA_LOKI_TESTS
- #define D( x ) x
+#define D( x ) x
#else
- #define D( x ) ;
+#define D( x ) ;
#endif
#if defined(_MSC_VER) || defined(__CYGWIN__)
@@ -47,7 +47,7 @@
* \ingroup FactoriesGroup
* \brief CachedFactory provides an extension of a Factory with caching
* support.
- *
+ *
* Once used objects are returned to the CachedFactory that manages its
* destruction.
* If your code uses lots of "long to construct/destruct objects" using the
@@ -60,231 +60,231 @@ namespace Loki
* \ingroup CachedFactoryGroup
* \brief Defines how the object is returned to the client
*/
- /**
- * \class SimplePointer
- * \ingroup EncapsulationPolicyCachedFactoryGroup
- * \brief No encaspulation : returns the pointer
- *
- * This implementation does not make any encapsulation.
- * It simply returns the object's pointer.
- */
- template<class AbstractProduct>
- class SimplePointer
- {
- protected:
- typedef AbstractProduct* ProductReturn;
- ProductReturn encapsulate(AbstractProduct* pProduct)
- {
- return pProduct;
- }
-
- AbstractProduct* release(ProductReturn &pProduct)
- {
- AbstractProduct* pPointer(pProduct);
- pProduct=NULL;
- return pPointer;
- }
- const char* name(){return "pointer";}
- };
+/**
+ * \class SimplePointer
+ * \ingroup EncapsulationPolicyCachedFactoryGroup
+ * \brief No encaspulation : returns the pointer
+ *
+ * This implementation does not make any encapsulation.
+ * It simply returns the object's pointer.
+ */
+template<class AbstractProduct>
+class SimplePointer
+{
+protected:
+ typedef AbstractProduct* ProductReturn;
+ ProductReturn encapsulate(AbstractProduct* pProduct)
+ {
+ return pProduct;
+ }
+
+ AbstractProduct* release(ProductReturn& pProduct)
+ {
+ AbstractProduct* pPointer(pProduct);
+ pProduct=NULL;
+ return pPointer;
+ }
+ const char* name() {return "pointer";}
+};
/**
* \defgroup CreationPolicyCachedFactoryGroup Creation policies
* \ingroup CachedFactoryGroup
* \brief Defines a way to limit the creation operation.
- *
+ *
* For instance one may want to be alerted (Exception) when
* - Cache has created a more than X object within the last x seconds
* - Cache creation rate has increased dramatically
* .
* which may result from bad caching strategy, or critical overload
*/
- /**
- * \class NeverCreate
- * \ingroup CreationPolicyCachedFactoryGroup
- * \brief Never allows creation. Testing purposes only.
- *
- * Using this policy will throw an exception.
- */
- class NeverCreate
- {
- protected:
- struct Exception : public std::exception
- {
- const char* what() const throw() { return "NeverFetch Policy : No Fetching allowed"; }
- };
-
- bool canCreate()
- {
- throw Exception();
- }
-
- void onCreate(){}
- void onDestroy(){}
- const char* name(){return "never";}
- };
-
- /**
- * \class AlwaysCreate
- * \ingroup CreationPolicyCachedFactoryGroup
- * \brief Always allows creation.
- *
- * Doesn't limit the creation in any way
- */
- class AlwaysCreate
- {
- protected:
- bool canCreate()
- {
- return true;
- }
+/**
+ * \class NeverCreate
+ * \ingroup CreationPolicyCachedFactoryGroup
+ * \brief Never allows creation. Testing purposes only.
+ *
+ * Using this policy will throw an exception.
+ */
+class NeverCreate
+{
+protected:
+ struct Exception : public std::exception
+ {
+ const char* what() const throw() { return "NeverFetch Policy : No Fetching allowed"; }
+ };
- void onCreate(){}
- void onDestroy(){}
- const char* name(){return "always";}
- };
+ bool canCreate()
+ {
+ throw Exception();
+ }
+ void onCreate() {}
+ void onDestroy() {}
+ const char* name() {return "never";}
+};
- /**
- * \class RateLimitedCreation
- * \ingroup CreationPolicyCachedFactoryGroup
- * \brief Limit in rate.
- *
- * This implementation will prevent from Creating more than maxCreation objects
- * within byTime ms by throwing an exception.
- * Could be usefull to detect prevent loads (http connection for instance).
- * Use the setRate method to set the rate parameters.
- * default is 10 objects in a second.
- */
- // !! CAUTION !!
- // The std::clock() function is not quite precise
- // under linux this policy might not work.
- // TODO : get a better implementation (platform dependant)
- class RateLimitedCreation
- {
- private:
- typedef std::vector< clock_t > Vector;
- Vector m_vTimes;
- unsigned maxCreation;
- clock_t timeValidity;
- clock_t lastUpdate;
-
- void cleanVector()
- {
- using namespace std;
- clock_t currentTime = clock();
- D( cout << "currentTime = " << currentTime<< endl; )
- D( cout << "currentTime - lastUpdate = " << currentTime - lastUpdate<< endl; )
- if(currentTime - lastUpdate > timeValidity)
- {
- m_vTimes.clear();
- D( cout << " is less than time validity " << timeValidity; )
- D( cout << " so clearing vector" << endl; )
- }
- else
- {
- D( cout << "Cleaning time less than " << currentTime - timeValidity << endl; )
- D( displayVector(); )
- Vector::iterator newEnd = remove_if(m_vTimes.begin(), m_vTimes.end(), bind2nd(less<clock_t>(), currentTime - timeValidity));
- // this rearrangement might be costly, consider optimization
- // by calling cleanVector in less used onCreate function
- // ... although it may not be correct
- m_vTimes.erase(newEnd, m_vTimes.end());
- D( displayVector(); )
- }
- lastUpdate = currentTime;
- }
-#ifdef DO_EXTRA_LOKI_TESTS
- void displayVector()
- {
- std::cout << "Vector : ";
- copy(m_vTimes.begin(), m_vTimes.end(), std::ostream_iterator<clock_t>(std::cout, " "));
- std::cout << std::endl;
- }
+/**
+ * \class AlwaysCreate
+ * \ingroup CreationPolicyCachedFactoryGroup
+ * \brief Always allows creation.
+ *
+ * Doesn't limit the creation in any way
+ */
+class AlwaysCreate
+{
+protected:
+ bool canCreate()
+ {
+ return true;
+ }
+
+ void onCreate() {}
+ void onDestroy() {}
+ const char* name() {return "always";}
+};
+
+
+/**
+ * \class RateLimitedCreation
+ * \ingroup CreationPolicyCachedFactoryGroup
+ * \brief Limit in rate.
+ *
+ * This implementation will prevent from Creating more than maxCreation objects
+ * within byTime ms by throwing an exception.
+ * Could be usefull to detect prevent loads (http connection for instance).
+ * Use the setRate method to set the rate parameters.
+ * default is 10 objects in a second.
+ */
+// !! CAUTION !!
+// The std::clock() function is not quite precise
+// under linux this policy might not work.
+// TODO : get a better implementation (platform dependant)
+class RateLimitedCreation
+{
+private:
+ typedef std::vector< clock_t > Vector;
+ Vector m_vTimes;
+ unsigned maxCreation;
+ clock_t timeValidity;
+ clock_t lastUpdate;
+
+ void cleanVector()
+ {
+ using namespace std;
+ clock_t currentTime = clock();
+ D( cout << "currentTime = " << currentTime<< endl; )
+ D( cout << "currentTime - lastUpdate = " << currentTime - lastUpdate<< endl; )
+ if(currentTime - lastUpdate > timeValidity)
+ {
+ m_vTimes.clear();
+ D( cout << " is less than time validity " << timeValidity; )
+ D( cout << " so clearing vector" << endl; )
+ }
+ else
+ {
+ D( cout << "Cleaning time less than " << currentTime - timeValidity << endl; )
+ D( displayVector(); )
+ Vector::iterator newEnd = remove_if(m_vTimes.begin(), m_vTimes.end(), bind2nd(less<clock_t>(), currentTime - timeValidity));
+ // this rearrangement might be costly, consider optimization
+ // by calling cleanVector in less used onCreate function
+ // ... although it may not be correct
+ m_vTimes.erase(newEnd, m_vTimes.end());
+ D( displayVector(); )
+ }
+ lastUpdate = currentTime;
+ }
+#ifdef DO_EXTRA_LOKI_TESTS
+ void displayVector()
+ {
+ std::cout << "Vector : ";
+ copy(m_vTimes.begin(), m_vTimes.end(), std::ostream_iterator<clock_t>(std::cout, " "));
+ std::cout << std::endl;
+ }
#endif
- protected:
- RateLimitedCreation() : maxCreation(10), timeValidity(CLOCKS_PER_SEC), lastUpdate(clock())
- {}
-
- struct Exception : public std::exception
- {
- const char* what() const throw() { return "RateLimitedCreation Policy : Exceeded the authorized creation rate"; }
- };
-
- bool canCreate()
- {
- cleanVector();
- if(m_vTimes.size()>maxCreation)
- throw Exception();
- else
- return true;
- }
+protected:
+ RateLimitedCreation() : maxCreation(10), timeValidity(CLOCKS_PER_SEC), lastUpdate(clock())
+ {}
- void onCreate()
- {
- m_vTimes.push_back(clock());
- }
-
- void onDestroy()
- {
- }
- const char* name(){return "rate limited";}
- public:
- // set the creation rate
- // No more than maxCreation within byTime milliseconds
- void setRate(unsigned maxCreation, unsigned byTime)
- {
- assert(byTime>0);
- this->maxCreation = maxCreation;
- this->timeValidity = static_cast<clock_t>(byTime * CLOCKS_PER_SEC / 1000);
- D( std::cout << "Setting no more than "<< maxCreation <<" creation within " << this->timeValidity <<" ms"<< std::endl; )
- }
- };
-
- /**
- * \class AmountLimitedCreation
- * \ingroup CreationPolicyCachedFactoryGroup
- * \brief Limit by number of objects
- *
- * This implementation will prevent from Creating more than maxCreation objects
- * within byTime ms by calling eviction policy.
- * Use the setRate method to set the rate parameters.
- * default is 10 objects.
- */
- class AmountLimitedCreation
- {
- private:
- unsigned maxCreation;
- unsigned created;
-
- protected:
- AmountLimitedCreation() : maxCreation(10), created(0)
- {}
-
- bool canCreate()
- {
- return !(created>=maxCreation);
- }
+ struct Exception : public std::exception
+ {
+ const char* what() const throw() { return "RateLimitedCreation Policy : Exceeded the authorized creation rate"; }
+ };
+
+ bool canCreate()
+ {
+ cleanVector();
+ if(m_vTimes.size()>maxCreation)
+ throw Exception();
+ else
+ return true;
+ }
+
+ void onCreate()
+ {
+ m_vTimes.push_back(clock());
+ }
+
+ void onDestroy()
+ {
+ }
+ const char* name() {return "rate limited";}
+public:
+ // set the creation rate
+ // No more than maxCreation within byTime milliseconds
+ void setRate(unsigned maxCreation, unsigned byTime)
+ {
+ assert(byTime>0);
+ this->maxCreation = maxCreation;
+ this->timeValidity = static_cast<clock_t>(byTime * CLOCKS_PER_SEC / 1000);
+ D( std::cout << "Setting no more than "<< maxCreation <<" creation within " << this->timeValidity <<" ms"<< std::endl; )
+ }
+};
+
+/**
+ * \class AmountLimitedCreation
+ * \ingroup CreationPolicyCachedFactoryGroup
+ * \brief Limit by number of objects
+ *
+ * This implementation will prevent from Creating more than maxCreation objects
+ * within byTime ms by calling eviction policy.
+ * Use the setRate method to set the rate parameters.
+ * default is 10 objects.
+ */
+class AmountLimitedCreation
+{
+private:
+ unsigned maxCreation;
+ unsigned created;
+
+protected:
+ AmountLimitedCreation() : maxCreation(10), created(0)
+ {}
+
+ bool canCreate()
+ {
+ return !(created>=maxCreation);
+ }
+
+ void onCreate()
+ {
+ ++created;
+ }
+
+ void onDestroy()
+ {
+ --created;
+ }
+ const char* name() {return "amount limited";}
+public:
+ // set the creation max amount
+ void setMaxCreation(unsigned maxCreation)
+ {
+ assert(maxCreation>0);
+ this->maxCreation = maxCreation;
+ D( std::cout << "Setting no more than " << maxCreation <<" creation" << std::endl; )
+ }
+};
- void onCreate()
- {
- ++created;
- }
-
- void onDestroy()
- {
- --created;
- }
- const char* name(){return "amount limited";}
- public:
- // set the creation max amount
- void setMaxCreation(unsigned maxCreation)
- {
- assert(maxCreation>0);
- this->maxCreation = maxCreation;
- D( std::cout << "Setting no more than " << maxCreation <<" creation" << std::endl; )
- }
- };
-
/**
* \defgroup EvictionPolicyCachedFactoryGroup Eviction policies
* \ingroup CachedFactoryGroup
@@ -292,875 +292,887 @@ namespace Loki
* candidate for eviction.
*/
- class EvictionException : public std::exception
+class EvictionException : public std::exception
+{
+public:
+ const char* what() const throw() { return "Eviction Policy : trying to make room but no objects are available"; }
+};
+
+// The following class is intented to provide helpers to sort
+// the container that will hold an eviction score
+template
+<
+typename ST, // Score type
+ typename DT // Data type
+ >
+class EvictionHelper
+{
+protected:
+ typedef typename std::map< DT, ST > HitMap;
+ typedef typename HitMap::iterator HitMapItr;
+private:
+ typedef std::pair< ST, DT > SwappedPair;
+ typedef std::multimap< ST, DT > SwappedHitMap;
+ typedef typename SwappedHitMap::iterator SwappedHitMapItr;
+protected:
+ HitMap m_mHitCount;
+
+ // This function sorts the map according to the score
+ // and returns the lower bound of the sorted container
+ DT& getLowerBound()
{
- public:
- const char* what() const throw() { return "Eviction Policy : trying to make room but no objects are available"; }
- };
+ assert(!m_mHitCount.empty());
+ // inserting the swapped pair into a multimap
+ SwappedHitMap copyMap;
+ for(HitMapItr itr = m_mHitCount.begin(); itr != m_mHitCount.end(); ++itr)
+ copyMap.insert(SwappedPair((*itr).second, (*itr).first));
+ if((*copyMap.rbegin()).first == 0) // the higher score is 0 ...
+ throw EvictionException(); // there is no key evict
+ return (*copyMap.begin()).second;
+ }
+};
- // The following class is intented to provide helpers to sort
- // the container that will hold an eviction score
- template
- <
- typename ST, // Score type
- typename DT // Data type
- >
- class EvictionHelper
- {
- protected:
- typedef typename std::map< DT, ST > HitMap;
- typedef typename HitMap::iterator HitMapItr;
- private:
- typedef std::pair< ST, DT > SwappedPair;
- typedef std::multimap< ST, DT > SwappedHitMap;
- typedef typename SwappedHitMap::iterator SwappedHitMapItr;
- protected:
- HitMap m_mHitCount;
-
- // This function sorts the map according to the score
- // and returns the lower bound of the sorted container
- DT& getLowerBound(){
- assert(!m_mHitCount.empty());
- // inserting the swapped pair into a multimap
- SwappedHitMap copyMap;
- for(HitMapItr itr = m_mHitCount.begin(); itr != m_mHitCount.end(); ++itr)
- copyMap.insert(SwappedPair((*itr).second, (*itr).first));
- if((*copyMap.rbegin()).first == 0) // the higher score is 0 ...
- throw EvictionException(); // there is no key evict
- return (*copyMap.begin()).second;
- }
- };
-
- /**
- * \class EvictLRU
- * \ingroup EvictionPolicyCachedFactoryGroup
- * \brief Evicts least accessed objects first.
- *
- * Implementation of the Least recent used algorithm as
- * described in http://en.wikipedia.org/wiki/Page_replacement_algorithms .
- *
- * WARNING : If an object is heavily fetched
- * (more than ULONG_MAX = UINT_MAX = 4294967295U)
- * it could unfortunately be removed from the cache.
- */
- template
- <
- typename DT, // Data Type (AbstractProduct*)
- typename ST = unsigned // default data type to use as Score Type
- >
- class EvictLRU : public EvictionHelper< ST , DT >
+/**
+ * \class EvictLRU
+ * \ingroup EvictionPolicyCachedFactoryGroup
+ * \brief Evicts least accessed objects first.
+ *
+ * Implementation of the Least recent used algorithm as
+ * described in http://en.wikipedia.org/wiki/Page_replacement_algorithms .
+ *
+ * WARNING : If an object is heavily fetched
+ * (more than ULONG_MAX = UINT_MAX = 4294967295U)
+ * it could unfortunately be removed from the cache.
+ */
+template
+<
+typename DT, // Data Type (AbstractProduct*)
+ typename ST = unsigned // default data type to use as Score Type
+ >
+class EvictLRU : public EvictionHelper< ST , DT >
+{
+private:
+ typedef EvictionHelper< ST , DT > EH;
+protected:
+
+ virtual ~EvictLRU() {}
+
+ // OnStore initialize the counter for the new key
+ // If the key already exists, the counter is reseted
+ void onCreate(const DT& key)
{
- private:
- typedef EvictionHelper< ST , DT > EH;
- protected:
-
- virtual ~EvictLRU(){}
-
- // OnStore initialize the counter for the new key
- // If the key already exists, the counter is reseted
- void onCreate(const DT& key)
- {
- EH::m_mHitCount[key] = 0;
- }
-
- void onFetch(const DT&)
- {
- }
-
- // onRelease increments the hit counter associated with the object
- void onRelease(const DT& key)
- {
- ++(EH::m_mHitCount[key]);
- }
+ EH::m_mHitCount[key] = 0;
+ }
- void onDestroy(const DT& key)
- {
- EH::m_mHitCount.erase(key);
- }
-
- // this function is implemented in Cache and redirected
- // to the Storage Policy
- virtual void remove(DT const key)=0;
-
- // LRU Eviction policy
- void evict()
- {
- remove(EH::getLowerBound());
- }
- const char* name(){return "LRU";}
- };
-
- /**
- * \class EvictAging
- * \ingroup EvictionPolicyCachedFactoryGroup
- * \brief LRU aware of the time span of use
- *
- * Implementation of the Aging algorithm as
- * described in http://en.wikipedia.org/wiki/Page_replacement_algorithms .
- *
- * This method is much more costly than evict LRU so
- * if you need extreme performance consider switching to EvictLRU
- */
- template
- <
- typename DT, // Data Type (AbstractProduct*)
- typename ST = unsigned // default data type to use as Score Type
- >
- class EvictAging : public EvictionHelper< ST, DT >
+ void onFetch(const DT&)
{
- private:
- EvictAging(const EvictAging&);
- EvictAging& operator=(const EvictAging&);
- typedef EvictionHelper< ST, DT > EH;
- typedef typename EH::HitMap HitMap;
- typedef typename EH::HitMapItr HitMapItr;
-
- // update the counter
- template<class T> struct updateCounter : public std::unary_function<T, void>
- {
- updateCounter(const DT& key): key_(key){}
- void operator()(T x)
- {
- x.second = (x.first == key_ ? (x.second >> 1) | ( 1 << ((sizeof(ST)-1)*8) ) : x.second >> 1);
- D( std::cout << x.second << std::endl; )
- }
- const DT &key_;
- updateCounter(const updateCounter& rhs) : key_(rhs.key_){}
- private:
- updateCounter& operator=(const updateCounter& rhs);
- };
- protected:
- EvictAging(){}
- virtual ~EvictAging(){}
-
- // OnStore initialize the counter for the new key
- // If the key already exists, the counter is reseted
- void onCreate(const DT& key){
- EH::m_mHitCount[key] = 0;
- }
-
- void onFetch(const DT&){}
-
- // onRelease increments the hit counter associated with the object
- // Updating every counters by iterating over the map
- // If the key is the key of the fetched object :
- // the counter is shifted to the right and it's MSB is set to 1
- // else
- // the counter is shifted to the left
- void onRelease(const DT& key)
- {
- std::for_each(EH::m_mHitCount.begin(), EH::m_mHitCount.end(), updateCounter< typename HitMap::value_type >(key));
- }
-
- void onDestroy(const DT& key)
- {
- EH::m_mHitCount.erase(key);
- }
+ }
- // this function is implemented in Cache and redirected
- // to the Storage Policy
- virtual void remove(DT const key)=0;
+ // onRelease increments the hit counter associated with the object
+ void onRelease(const DT& key)
+ {
+ ++(EH::m_mHitCount[key]);
+ }
- // LRU with Aging Eviction policy
- void evict()
- {
- remove(EH::getLowerBound());
- }
- const char* name(){return "LRU with aging";}
- };
-
- /**
- * \class EvictRandom
- * \ingroup EvictionPolicyCachedFactoryGroup
- * \brief Evicts a random object
- *
- * Implementation of the Random algorithm as
- * described in http://en.wikipedia.org/wiki/Page_replacement_algorithms .
- */
- template
- <
- typename DT, // Data Type (AbstractProduct*)
- typename ST = void // Score Type not used by this policy
- >
- class EvictRandom
+ void onDestroy(const DT& key)
+ {
+ EH::m_mHitCount.erase(key);
+ }
+
+ // this function is implemented in Cache and redirected
+ // to the Storage Policy
+ virtual void remove(DT const key)=0;
+
+ // LRU Eviction policy
+ void evict()
{
+ remove(EH::getLowerBound());
+ }
+ const char* name() {return "LRU";}
+};
+
+/**
+ * \class EvictAging
+ * \ingroup EvictionPolicyCachedFactoryGroup
+ * \brief LRU aware of the time span of use
+ *
+ * Implementation of the Aging algorithm as
+ * described in http://en.wikipedia.org/wiki/Page_replacement_algorithms .
+ *
+ * This method is much more costly than evict LRU so
+ * if you need extreme performance consider switching to EvictLRU
+ */
+template
+<
+typename DT, // Data Type (AbstractProduct*)
+ typename ST = unsigned // default data type to use as Score Type
+ >
+class EvictAging : public EvictionHelper< ST, DT >
+{
+private:
+ EvictAging(const EvictAging&);
+ EvictAging& operator=(const EvictAging&);
+ typedef EvictionHelper< ST, DT > EH;
+ typedef typename EH::HitMap HitMap;
+ typedef typename EH::HitMapItr HitMapItr;
+
+ // update the counter
+ template<class T> struct updateCounter : public std::unary_function<T, void>
+ {
+ updateCounter(const DT& key): key_(key) {}
+ void operator()(T x)
+ {
+ x.second = (x.first == key_ ? (x.second >> 1) | ( 1 << ((sizeof(ST)-1)*8) ) : x.second >> 1);
+ D( std::cout << x.second << std::endl; )
+ }
+ const DT& key_;
+ updateCounter(const updateCounter& rhs) : key_(rhs.key_) {}
private:
- std::vector< DT > m_vKeys;
- typedef typename std::vector< DT >::size_type size_type;
- typedef typename std::vector< DT >::iterator iterator;
-
- protected:
-
- virtual ~EvictRandom(){}
-
- void onCreate(const DT&){
- }
-
- void onFetch(const DT& ){
- }
-
- void onRelease(const DT& key){
- m_vKeys.push_back(key);
- }
-
- void onDestroy(const DT& key){
- using namespace std;
- m_vKeys.erase(remove_if(m_vKeys.begin(), m_vKeys.end(), bind2nd(equal_to< DT >(), key)), m_vKeys.end());
- }
-
- // Implemented in Cache and redirected to the Storage Policy
- virtual void remove(DT const key)=0;
-
- // Random Eviction policy
- void evict()
- {
- if(m_vKeys.empty())
- throw EvictionException();
- size_type random = static_cast<size_type>((m_vKeys.size()*rand())/(static_cast<size_type>(RAND_MAX) + 1));
- remove(*(m_vKeys.begin()+random));
- }
- const char* name(){return "random";}
+ updateCounter& operator=(const updateCounter& rhs);
};
+protected:
+ EvictAging() {}
+ virtual ~EvictAging() {}
+
+ // OnStore initialize the counter for the new key
+ // If the key already exists, the counter is reseted
+ void onCreate(const DT& key)
+ {
+ EH::m_mHitCount[key] = 0;
+ }
+
+ void onFetch(const DT&) {}
+
+ // onRelease increments the hit counter associated with the object
+ // Updating every counters by iterating over the map
+ // If the key is the key of the fetched object :
+ // the counter is shifted to the right and it's MSB is set to 1
+ // else
+ // the counter is shifted to the left
+ void onRelease(const DT& key)
+ {
+ std::for_each(EH::m_mHitCount.begin(), EH::m_mHitCount.end(), updateCounter< typename HitMap::value_type >(key));
+ }
+
+ void onDestroy(const DT& key)
+ {
+ EH::m_mHitCount.erase(key);
+ }
+
+ // this function is implemented in Cache and redirected
+ // to the Storage Policy
+ virtual void remove(DT const key)=0;
+
+ // LRU with Aging Eviction policy
+ void evict()
+ {
+ remove(EH::getLowerBound());
+ }
+ const char* name() {return "LRU with aging";}
+};
+
+/**
+ * \class EvictRandom
+ * \ingroup EvictionPolicyCachedFactoryGroup
+ * \brief Evicts a random object
+ *
+ * Implementation of the Random algorithm as
+ * described in http://en.wikipedia.org/wiki/Page_replacement_algorithms .
+ */
+template
+<
+typename DT, // Data Type (AbstractProduct*)
+ typename ST = void // Score Type not used by this policy
+ >
+class EvictRandom
+{
+private:
+ std::vector< DT > m_vKeys;
+ typedef typename std::vector< DT >::size_type size_type;
+ typedef typename std::vector< DT >::iterator iterator;
+
+protected:
+
+ virtual ~EvictRandom() {}
+
+ void onCreate(const DT&)
+ {
+ }
+
+ void onFetch(const DT& )
+ {
+ }
+
+ void onRelease(const DT& key)
+ {
+ m_vKeys.push_back(key);
+ }
+
+ void onDestroy(const DT& key)
+ {
+ using namespace std;
+ m_vKeys.erase(remove_if(m_vKeys.begin(), m_vKeys.end(), bind2nd(equal_to< DT >(), key)), m_vKeys.end());
+ }
+
+ // Implemented in Cache and redirected to the Storage Policy
+ virtual void remove(DT const key)=0;
+
+ // Random Eviction policy
+ void evict()
+ {
+ if(m_vKeys.empty())
+ throw EvictionException();
+ size_type random = static_cast<size_type>((m_vKeys.size()*rand())/(static_cast<size_type>(RAND_MAX) + 1));
+ remove(*(m_vKeys.begin()+random));
+ }
+ const char* name() {return "random";}
+};
/**
* \defgroup StatisticPolicyCachedFactoryGroup Statistic policies
* \ingroup CachedFactoryGroup
* \brief Gathers information about the cache.
- *
+ *
* For debugging purpose this policy proposes to gather informations
* about the cache. This could be useful to determine whether the cache is
* mandatory or if the policies are well suited to the application.
*/
- /**
- * \class NoStatisticPolicy
- * \ingroup StatisticPolicyCachedFactoryGroup
- * \brief Do nothing
- *
- * Should be used in release code for better performances
- */
- class NoStatisticPolicy
- {
- protected:
- void onDebug(){}
- void onFetch(){}
- void onRelease(){}
- void onCreate(){}
- void onDestroy(){}
- const char* name(){return "no";}
- };
-
- /**
- * \class SimpleStatisticPolicy
- * \ingroup StatisticPolicyCachedFactoryGroup
- * \brief Simple statistics
- *
- * Provides the following informations about the cache :
- * - Created objects
- * - Fetched objects
- * - Destroyed objects
- * - Cache hit
- * - Cache miss
- * - Currently allocated
- * - Currently out
- * - Cache overall efficiency
- */
- class SimpleStatisticPolicy
+/**
+ * \class NoStatisticPolicy
+ * \ingroup StatisticPolicyCachedFactoryGroup
+ * \brief Do nothing
+ *
+ * Should be used in release code for better performances
+ */
+class NoStatisticPolicy
+{
+protected:
+ void onDebug() {}
+ void onFetch() {}
+ void onRelease() {}
+ void onCreate() {}
+ void onDestroy() {}
+ const char* name() {return "no";}
+};
+
+/**
+ * \class SimpleStatisticPolicy
+ * \ingroup StatisticPolicyCachedFactoryGroup
+ * \brief Simple statistics
+ *
+ * Provides the following informations about the cache :
+ * - Created objects
+ * - Fetched objects
+ * - Destroyed objects
+ * - Cache hit
+ * - Cache miss
+ * - Currently allocated
+ * - Currently out
+ * - Cache overall efficiency
+ */
+class SimpleStatisticPolicy
+{
+private:
+ unsigned allocated, created, hit, out, fetched;
+protected:
+ SimpleStatisticPolicy() : allocated(0), created(0), hit(0), out(0), fetched(0)
{
- private:
- unsigned allocated, created, hit, out, fetched;
- protected:
- SimpleStatisticPolicy() : allocated(0), created(0), hit(0), out(0), fetched(0)
- {
- }
-
- void onDebug()
+ }
+
+ void onDebug()
+ {
+ using namespace std;
+ cout << "############################" << endl;
+ cout << "## About this cache " << this << endl;
+ cout << "## + Created objects : " << created << endl;
+ cout << "## + Fetched objects : " << fetched << endl;
+ cout << "## + Destroyed objects : " << created - allocated << endl;
+ cout << "## + Cache hit : " << hit << endl;
+ cout << "## + Cache miss : " << fetched - hit << endl;
+ cout << "## + Currently allocated : " << allocated << endl;
+ cout << "## + Currently out : " << out << endl;
+ cout << "############################" << endl;
+ if(fetched!=0)
{
- using namespace std;
- cout << "############################" << endl;
- cout << "## About this cache " << this << endl;
- cout << "## + Created objects : " << created << endl;
- cout << "## + Fetched objects : " << fetched << endl;
- cout << "## + Destroyed objects : " << created - allocated << endl;
- cout << "## + Cache hit : " << hit << endl;
- cout << "## + Cache miss : " << fetched - hit << endl;
- cout << "## + Currently allocated : " << allocated << endl;
- cout << "## + Currently out : " << out << endl;
+ cout << "## Overall efficiency " << 100*double(hit)/fetched <<"%"<< endl;
cout << "############################" << endl;
- if(fetched!=0){
- cout << "## Overall efficiency " << 100*double(hit)/fetched <<"%"<< endl;
- cout << "############################" << endl;
- }
- cout << endl;
}
-
- void onFetch()
- {
- ++fetched;
- ++out;
- ++hit;
- }
- void onRelease()
- {
- --out;
- }
- void onCreate()
+ cout << endl;
+ }
+
+ void onFetch()
+ {
+ ++fetched;
+ ++out;
+ ++hit;
+ }
+ void onRelease()
+ {
+ --out;
+ }
+ void onCreate()
+ {
+ ++created;
+ ++allocated;
+ --hit;
+ }
+ void onDestroy()
+ {
+ --allocated;
+ }
+
+ const char* name() {return "simple";}
+public:
+ unsigned getCreated() {return created;}
+ unsigned getFetched() {return fetched;}
+ unsigned getHit() {return hit;}
+ unsigned getMissed() {return fetched - hit;}
+ unsigned getAllocated() {return allocated;}
+ unsigned getOut() {return out;}
+ unsigned getDestroyed() {return created-allocated;}
+};
+
+///////////////////////////////////////////////////////////////////////////
+// Cache Factory definition
+///////////////////////////////////////////////////////////////////////////
+class CacheException : public std::exception
+{
+public:
+ const char* what() const throw() { return "Internal Cache Error"; }
+};
+
+/**
+ * \class CachedFactory
+ * \ingroup CachedFactoryGroup
+ * \brief Factory with caching support
+ *
+ * This class acts as a Factory (it creates objects)
+ * but also keeps the already created objects to prevent
+ * long constructions time.
+ *
+ * Note this implementation do not retain ownership.
+ */
+template
+<
+class AbstractProduct,
+ typename IdentifierType,
+ typename CreatorParmTList = NullType,
+ template<class> class EncapsulationPolicy = SimplePointer,
+ class CreationPolicy = AlwaysCreate,
+ template <typename , typename> class EvictionPolicy = EvictRandom,
+ class StatisticPolicy = NoStatisticPolicy,
+ template<typename, class> class FactoryErrorPolicy = DefaultFactoryError,
+ class ObjVector = std::vector<AbstractProduct*>
+ >
+class CachedFactory :
+ protected EncapsulationPolicy<AbstractProduct>,
+ public CreationPolicy, public StatisticPolicy, EvictionPolicy< AbstractProduct* , unsigned >
+{
+private:
+ typedef Factory< AbstractProduct, IdentifierType, CreatorParmTList, FactoryErrorPolicy> MyFactory;
+ typedef FactoryImpl< AbstractProduct, IdentifierType, CreatorParmTList > Impl;
+ typedef Functor< AbstractProduct* , CreatorParmTList > ProductCreator;
+ typedef EncapsulationPolicy<AbstractProduct> NP;
+ typedef CreationPolicy CP;
+ typedef StatisticPolicy SP;
+ typedef EvictionPolicy< AbstractProduct* , unsigned > EP;
+
+ typedef typename Impl::Parm1 Parm1;
+ typedef typename Impl::Parm2 Parm2;
+ typedef typename Impl::Parm3 Parm3;
+ typedef typename Impl::Parm4 Parm4;
+ typedef typename Impl::Parm5 Parm5;
+ typedef typename Impl::Parm6 Parm6;
+ typedef typename Impl::Parm7 Parm7;
+ typedef typename Impl::Parm8 Parm8;
+ typedef typename Impl::Parm9 Parm9;
+ typedef typename Impl::Parm10 Parm10;
+ typedef typename Impl::Parm11 Parm11;
+ typedef typename Impl::Parm12 Parm12;
+ typedef typename Impl::Parm13 Parm13;
+ typedef typename Impl::Parm14 Parm14;
+ typedef typename Impl::Parm15 Parm15;
+
+public:
+ typedef typename NP::ProductReturn ProductReturn;
+private:
+ typedef Key< Impl, IdentifierType > MyKey;
+ typedef std::map< MyKey, ObjVector > KeyToObjVectorMap;
+ typedef std::map< AbstractProduct*, MyKey > FetchedObjToKeyMap;
+
+ MyFactory factory;
+ KeyToObjVectorMap fromKeyToObjVector;
+ FetchedObjToKeyMap providedObjects;
+ unsigned outObjects;
+
+ ObjVector& getContainerFromKey(MyKey key)
+ {
+ return fromKeyToObjVector[key];
+ }
+
+ AbstractProduct* const getPointerToObjectInContainer(ObjVector& entry)
+ {
+ if(entry.empty()) // No object available
{
- ++created;
- ++allocated;
- --hit;
+ // the object will be created in the calling function.
+ // It has to be created in the calling function because of
+ // the variable number of parameters for CreateObject(...) method
+ return NULL;
}
- void onDestroy()
+ else
{
- --allocated;
+ // returning the found object
+ AbstractProduct* pObject(entry.back());
+ assert(pObject!=NULL);
+ entry.pop_back();
+ return pObject;
}
+ }
+
+ bool shouldCreateObject(AbstractProduct* const pProduct)
+ {
+ if(pProduct!=NULL) // object already exists
+ return false;
+ if(CP::canCreate()==false) // Are we allowed to Create ?
+ EP::evict(); // calling Eviction Policy to clean up
+ return true;
+ }
+
+ void ReleaseObjectFromContainer(ObjVector& entry, AbstractProduct* const object)
+ {
+ entry.push_back(object);
+ }
+
+ void onFetch(AbstractProduct* const pProduct)
+ {
+ SP::onFetch();
+ EP::onFetch(pProduct);
+ ++outObjects;
+ }
+
+ void onRelease(AbstractProduct* const pProduct)
+ {
+ SP::onRelease();
+ EP::onRelease(pProduct);
+ --outObjects;
+ }
+
+ void onCreate(AbstractProduct* const pProduct)
+ {
+ CP::onCreate();
+ SP::onCreate();
+ EP::onCreate(pProduct);
+ }
- const char* name(){return "simple";}
- public:
- unsigned getCreated(){return created;}
- unsigned getFetched(){return fetched;}
- unsigned getHit(){return hit;}
- unsigned getMissed(){return fetched - hit;}
- unsigned getAllocated(){return allocated;}
- unsigned getOut(){return out;}
- unsigned getDestroyed(){return created-allocated;}
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // Cache Factory definition
- ///////////////////////////////////////////////////////////////////////////
- class CacheException : public std::exception
- {
- public:
- const char* what() const throw() { return "Internal Cache Error"; }
+ void onDestroy(AbstractProduct* const pProduct)
+ {
+ CP::onDestroy();
+ SP::onDestroy();
+ EP::onDestroy(pProduct);
+ }
+
+ // delete the object
+ template<class T> struct deleteObject : public std::unary_function<T, void>
+ {
+ void operator()(T x) { delete x; }
};
-
- /**
- * \class CachedFactory
- * \ingroup CachedFactoryGroup
- * \brief Factory with caching support
- *
- * This class acts as a Factory (it creates objects)
- * but also keeps the already created objects to prevent
- * long constructions time.
- *
- * Note this implementation do not retain ownership.
- */
- template
- <
- class AbstractProduct,
- typename IdentifierType,
- typename CreatorParmTList = NullType,
- template<class> class EncapsulationPolicy = SimplePointer,
- class CreationPolicy = AlwaysCreate,
- template <typename , typename> class EvictionPolicy = EvictRandom,
- class StatisticPolicy = NoStatisticPolicy,
- template<typename, class> class FactoryErrorPolicy = DefaultFactoryError,
- class ObjVector = std::vector<AbstractProduct*>
- >
- class CachedFactory :
- protected EncapsulationPolicy<AbstractProduct>,
- public CreationPolicy, public StatisticPolicy, EvictionPolicy< AbstractProduct * , unsigned >
- {
- private:
- typedef Factory< AbstractProduct, IdentifierType, CreatorParmTList, FactoryErrorPolicy> MyFactory;
- typedef FactoryImpl< AbstractProduct, IdentifierType, CreatorParmTList > Impl;
- typedef Functor< AbstractProduct* , CreatorParmTList > ProductCreator;
- typedef EncapsulationPolicy<AbstractProduct> NP;
- typedef CreationPolicy CP;
- typedef StatisticPolicy SP;
- typedef EvictionPolicy< AbstractProduct* , unsigned > EP;
-
- typedef typename Impl::Parm1 Parm1;
- typedef typename Impl::Parm2 Parm2;
- typedef typename Impl::Parm3 Parm3;
- typedef typename Impl::Parm4 Parm4;
- typedef typename Impl::Parm5 Parm5;
- typedef typename Impl::Parm6 Parm6;
- typedef typename Impl::Parm7 Parm7;
- typedef typename Impl::Parm8 Parm8;
- typedef typename Impl::Parm9 Parm9;
- typedef typename Impl::Parm10 Parm10;
- typedef typename Impl::Parm11 Parm11;
- typedef typename Impl::Parm12 Parm12;
- typedef typename Impl::Parm13 Parm13;
- typedef typename Impl::Parm14 Parm14;
- typedef typename Impl::Parm15 Parm15;
-
- public:
- typedef typename NP::ProductReturn ProductReturn;
- private:
- typedef Key< Impl, IdentifierType > MyKey;
- typedef std::map< MyKey, ObjVector > KeyToObjVectorMap;
- typedef std::map< AbstractProduct*, MyKey > FetchedObjToKeyMap;
-
- MyFactory factory;
- KeyToObjVectorMap fromKeyToObjVector;
- FetchedObjToKeyMap providedObjects;
- unsigned outObjects;
-
- ObjVector& getContainerFromKey(MyKey key){
- return fromKeyToObjVector[key];
- }
- AbstractProduct* const getPointerToObjectInContainer(ObjVector &entry)
- {
- if(entry.empty()) // No object available
- { // the object will be created in the calling function.
- // It has to be created in the calling function because of
- // the variable number of parameters for CreateObject(...) method
- return NULL;
- }
- else
- { // returning the found object
- AbstractProduct* pObject(entry.back());
- assert(pObject!=NULL);
- entry.pop_back();
- return pObject;
- }
- }
-
- bool shouldCreateObject(AbstractProduct * const pProduct){
- if(pProduct!=NULL) // object already exists
- return false;
- if(CP::canCreate()==false) // Are we allowed to Create ?
- EP::evict(); // calling Eviction Policy to clean up
- return true;
- }
-
- void ReleaseObjectFromContainer(ObjVector &entry, AbstractProduct * const object)
- {
- entry.push_back(object);
- }
-
- void onFetch(AbstractProduct * const pProduct)
- {
- SP::onFetch();
- EP::onFetch(pProduct);
- ++outObjects;
- }
-
- void onRelease(AbstractProduct * const pProduct)
- {
- SP::onRelease();
- EP::onRelease(pProduct);
- --outObjects;
- }
-
- void onCreate(AbstractProduct * const pProduct)
- {
- CP::onCreate();
- SP::onCreate();
- EP::onCreate(pProduct);
- }
-
- void onDestroy(AbstractProduct * const pProduct)
+ // delete the objects in the vector
+ template<class T> struct deleteVectorObjects : public std::unary_function<T, void>
+ {
+ void operator()(T x)
{
- CP::onDestroy();
- SP::onDestroy();
- EP::onDestroy(pProduct);
+ ObjVector& vec(x.second);
+ std::for_each(vec.begin(), vec.end(), deleteObject< typename ObjVector::value_type>());
}
-
- // delete the object
- template<class T> struct deleteObject : public std::unary_function<T, void>
- {
- void operator()(T x){ delete x; }
- };
-
- // delete the objects in the vector
- template<class T> struct deleteVectorObjects : public std::unary_function<T, void>
- {
- void operator()(T x){
- ObjVector &vec(x.second);
- std::for_each(vec.begin(), vec.end(), deleteObject< typename ObjVector::value_type>());
- }
- };
-
- // delete the keys of the map
- template<class T> struct deleteMapKeys : public std::unary_function<T, void>
- {
- void operator()(T x){ delete x.first; }
- };
-
- protected:
- virtual void remove(AbstractProduct * const pProduct)
+ };
+
+ // delete the keys of the map
+ template<class T> struct deleteMapKeys : public std::unary_function<T, void>
+ {
+ void operator()(T x) { delete x.first; }
+ };
+
+protected:
+ virtual void remove(AbstractProduct* const pProduct)
+ {
+ typename FetchedObjToKeyMap::iterator fetchedItr = providedObjects.find(pProduct);
+ if(fetchedItr!=providedObjects.end()) // object is unreleased.
+ throw CacheException();
+ bool productRemoved = false;
+ typename KeyToObjVectorMap::iterator objVectorItr;
+ typename ObjVector::iterator objItr;
+ for(objVectorItr=fromKeyToObjVector.begin(); objVectorItr!=fromKeyToObjVector.end(); ++objVectorItr)
{
- typename FetchedObjToKeyMap::iterator fetchedItr = providedObjects.find(pProduct);
- if(fetchedItr!=providedObjects.end()) // object is unreleased.
- throw CacheException();
- bool productRemoved = false;
- typename KeyToObjVectorMap::iterator objVectorItr;
- typename ObjVector::iterator objItr;
- for(objVectorItr=fromKeyToObjVector.begin();objVectorItr!=fromKeyToObjVector.end();++objVectorItr)
+ ObjVector& v((*objVectorItr).second);
+ objItr = remove_if(v.begin(), v.end(), std::bind2nd(std::equal_to<AbstractProduct*>(), pProduct));
+ if(objItr != v.end()) // we found the vector containing pProduct and removed it
{
- ObjVector &v((*objVectorItr).second);
- objItr = remove_if(v.begin(), v.end(), std::bind2nd(std::equal_to<AbstractProduct*>(), pProduct));
- if(objItr != v.end()) // we found the vector containing pProduct and removed it
- {
- onDestroy(pProduct); // warning policies we are about to destroy an object
- v.erase(objItr, v.end()); // real removing
- productRemoved = true;
- break;
- }
+ onDestroy(pProduct); // warning policies we are about to destroy an object
+ v.erase(objItr, v.end()); // real removing
+ productRemoved = true;
+ break;
}
- if(productRemoved==false)
- throw CacheException(); // the product is not in the cache ?!
- delete pProduct; // deleting it
}
+ if(productRemoved==false)
+ throw CacheException(); // the product is not in the cache ?!
+ delete pProduct; // deleting it
+ }
- public:
- CachedFactory() : factory(), fromKeyToObjVector(), providedObjects(), outObjects(0)
- {
- }
+public:
+ CachedFactory() : factory(), fromKeyToObjVector(), providedObjects(), outObjects(0)
+ {
+ }
- ~CachedFactory()
- {
- using namespace std;
- // debug information
- SP::onDebug();
- // cleaning the Cache
- for_each(fromKeyToObjVector.begin(), fromKeyToObjVector.end(),
- deleteVectorObjects< typename KeyToObjVectorMap::value_type >()
- );
- if(!providedObjects.empty())
- {
- // The factory is responsible for the creation and destruction of objects.
- // If objects are out during the destruction of the Factory : deleting anyway.
- // This might not be a good idea. But throwing an exception in a destructor is
- // considered as a bad pratice and asserting might be too much.
- // What to do ? Leaking memory or corrupting in use pointers ? hmm...
- D( cout << "====>> Cache destructor : deleting "<< providedObjects.size()<<" in use objects <<====" << endl << endl; )
- for_each(providedObjects.begin(), providedObjects.end(),
- deleteMapKeys< typename FetchedObjToKeyMap::value_type >()
+ ~CachedFactory()
+ {
+ using namespace std;
+ // debug information
+ SP::onDebug();
+ // cleaning the Cache
+ for_each(fromKeyToObjVector.begin(), fromKeyToObjVector.end(),
+ deleteVectorObjects< typename KeyToObjVectorMap::value_type >()
);
- }
- }
-
- ///////////////////////////////////
- // Acts as the proxy pattern and //
- // forwards factory methods //
- ///////////////////////////////////
-
- bool Register(const IdentifierType& id, ProductCreator creator)
+ if(!providedObjects.empty())
{
- return factory.Register(id, creator);
- }
-
- template <class PtrObj, typename CreaFn>
- bool Register(const IdentifierType& id, const PtrObj& p, CreaFn fn)
- {
- return factory.Register(id, p, fn);
- }
-
- bool Unregister(const IdentifierType& id)
- {
- return factory.Unregister(id);
+ // The factory is responsible for the creation and destruction of objects.
+ // If objects are out during the destruction of the Factory : deleting anyway.
+ // This might not be a good idea. But throwing an exception in a destructor is
+ // considered as a bad pratice and asserting might be too much.
+ // What to do ? Leaking memory or corrupting in use pointers ? hmm...
+ D( cout << "====>> Cache destructor : deleting "<< providedObjects.size()<<" in use objects <<====" << endl << endl; )
+ for_each(providedObjects.begin(), providedObjects.end(),
+ deleteMapKeys< typename FetchedObjToKeyMap::value_type >()
+ );
}
+ }
- /// Return the registered ID in this Factory
- std::vector<IdentifierType>& RegisteredIds()
- {
- return factory.RegisteredIds();
- }
+ ///////////////////////////////////
+ // Acts as the proxy pattern and //
+ // forwards factory methods //
+ ///////////////////////////////////
- ProductReturn CreateObject(const IdentifierType& id)
- {
- MyKey key(id);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
- }
-
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1)
- {
- MyKey key(id,p1);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
- }
+ bool Register(const IdentifierType& id, ProductCreator creator)
+ {
+ return factory.Register(id, creator);
+ }
+
+ template <class PtrObj, typename CreaFn>
+ bool Register(const IdentifierType& id, const PtrObj& p, CreaFn fn)
+ {
+ return factory.Register(id, p, fn);
+ }
+
+ bool Unregister(const IdentifierType& id)
+ {
+ return factory.Unregister(id);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2)
+ /// Return the registered ID in this Factory
+ std::vector<IdentifierType>& RegisteredIds()
+ {
+ return factory.RegisteredIds();
+ }
+
+ ProductReturn CreateObject(const IdentifierType& id)
+ {
+ MyKey key(id);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1)
+ {
+ MyKey key(id,p1);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2)
+ {
+ MyKey key(id,p1,p2);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3)
+ {
+ MyKey key(id,p1,p2,p3);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
+ {
+ MyKey key(id,p1,p2,p3,p4);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5,p6);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5,key.p6);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7 )
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
+ {
+ MyKey key(id,p1,p2,p3,p4,p5);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5,p6,p7);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5,key.p6,key.p7);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6)
+ {
+ MyKey key(id,p1,p2,p3,p4,p5,p6);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5,key.p6,key.p7,key.p8);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5,key.p6);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7 )
+ {
+ MyKey key(id,p1,p2,p3,p4,p5,p6,p7);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5,key.p6,key.p7);
+ onCreate(pProduct);
}
-
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9,Parm10 p10)
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
+
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8)
+ {
+ MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5,key.p6,key.p7,key.p8);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
- Parm11 p11)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
+ {
+ MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
- Parm11 p11, Parm12 p12)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9,Parm10 p10)
+ {
+ MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
- Parm11 p11, Parm12 p12, Parm13 p13)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
+ Parm11 p11)
+ {
+ MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12
- ,key.p13);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
- Parm11 p11, Parm12 p12, Parm13 p13, Parm14 p14)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
+ Parm11 p11, Parm12 p12)
+ {
+ MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12
- ,key.p13,key.p14);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- ProductReturn CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
- Parm11 p11, Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
+ Parm11 p11, Parm12 p12, Parm13 p13)
+ {
+ MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15);
- AbstractProduct *pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
- if(shouldCreateObject(pProduct))
- {
- pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
- ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12
- ,key.p13,key.p14,key.p15);
- onCreate(pProduct);
- }
- onFetch(pProduct);
- providedObjects[pProduct] = key;
- return NP::encapsulate(pProduct);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12
+ ,key.p13);
+ onCreate(pProduct);
}
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
- /// Use this function to release the object
- /**
- * if execution brakes in this function then you tried
- * to release an object that wasn't provided by this Cache
- * ... which is bad :-)
- */
- void ReleaseObject(ProductReturn &object)
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
+ Parm11 p11, Parm12 p12, Parm13 p13, Parm14 p14)
+ {
+ MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- AbstractProduct* pProduct(NP::release(object));
- typename FetchedObjToKeyMap::iterator itr = providedObjects.find(pProduct);
- if(itr == providedObjects.end())
- throw CacheException();
- onRelease(pProduct);
- ReleaseObjectFromContainer(getContainerFromKey((*itr).second), pProduct);
- providedObjects.erase(itr);
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12
+ ,key.p13,key.p14);
+ onCreate(pProduct);
}
-
- /// display the cache configuration
- void displayCacheType()
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
+
+ ProductReturn CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
+ Parm11 p11, Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
+ {
+ MyKey key(id,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15);
+ AbstractProduct* pProduct(getPointerToObjectInContainer(getContainerFromKey(key)));
+ if(shouldCreateObject(pProduct))
{
- using namespace std;
- cout << "############################" << endl;
- cout << "## Cache configuration" << endl;
- cout << "## + Encapsulation " << NP::name() << endl;
- cout << "## + Creating " << CP::name() << endl;
- cout << "## + Eviction " << EP::name() << endl;
- cout << "## + Statistics " << SP::name() << endl;
- cout << "############################" << endl;
+ pProduct = factory.CreateObject(key.id,key.p1,key.p2,key.p3
+ ,key.p4,key.p5,key.p6,key.p7,key.p8,key.p9,key.p10,key.p11,key.p12
+ ,key.p13,key.p14,key.p15);
+ onCreate(pProduct);
}
- };
+ onFetch(pProduct);
+ providedObjects[pProduct] = key;
+ return NP::encapsulate(pProduct);
+ }
+
+ /// Use this function to release the object
+ /**
+ * if execution brakes in this function then you tried
+ * to release an object that wasn't provided by this Cache
+ * ... which is bad :-)
+ */
+ void ReleaseObject(ProductReturn& object)
+ {
+ AbstractProduct* pProduct(NP::release(object));
+ typename FetchedObjToKeyMap::iterator itr = providedObjects.find(pProduct);
+ if(itr == providedObjects.end())
+ throw CacheException();
+ onRelease(pProduct);
+ ReleaseObjectFromContainer(getContainerFromKey((*itr).second), pProduct);
+ providedObjects.erase(itr);
+ }
+
+ /// display the cache configuration
+ void displayCacheType()
+ {
+ using namespace std;
+ cout << "############################" << endl;
+ cout << "## Cache configuration" << endl;
+ cout << "## + Encapsulation " << NP::name() << endl;
+ cout << "## + Creating " << CP::name() << endl;
+ cout << "## + Eviction " << EP::name() << endl;
+ cout << "## + Statistics " << SP::name() << endl;
+ cout << "############################" << endl;
+ }
+};
} // namespace Loki
#endif // end file guardian
diff --git a/shared/loki/CheckReturn.h b/shared/loki/CheckReturn.h
index fbe63ed0..c0a65aa5 100644
--- a/shared/loki/CheckReturn.h
+++ b/shared/loki/CheckReturn.h
@@ -65,46 +65,46 @@ namespace Loki
template<class T>
struct IgnoreReturnValue
{
- static void run(const T&)
- {
- /// Do nothing at all.
- }
+ static void run(const T&)
+ {
+ /// Do nothing at all.
+ }
};
template<class T>
struct ThrowTheValue
{
- static void run(const T & value )
- {
- throw value;
- }
+ static void run(const T& value )
+ {
+ throw value;
+ }
};
template<class T>
struct ThrowLogicError
{
- static void run( const T & )
- {
- throw ::std::logic_error( "CheckReturn: return value was not checked.\n" );
- }
+ static void run( const T& )
+ {
+ throw ::std::logic_error( "CheckReturn: return value was not checked.\n" );
+ }
};
template<class T>
struct TriggerAssert
{
- static void run(const T&)
- {
- assert( 0 );
- }
+ static void run(const T&)
+ {
+ assert( 0 );
+ }
};
template<class T>
struct FprintfStderr
{
- static void run(const T&)
- {
- fprintf(stderr, "CheckReturn: return value was not checked.\n");
- }
+ static void run(const T&)
+ {
+ fprintf(stderr, "CheckReturn: return value was not checked.\n");
+ }
};
@@ -114,45 +114,45 @@ class CheckReturn
{
public:
- /// Conversion constructor changes Value type to CheckReturn type.
- inline CheckReturn( const Value & value ) :
- m_value( value ), m_checked( false ) {}
-
- /// Copy-constructor allows functions to call another function within the
- /// return statement. The other CheckReturn's m_checked flag is set since
- /// its duty has been passed to the m_checked flag in this one.
- inline CheckReturn( const CheckReturn & that ) :
- m_value( that.m_value ), m_checked( false )
- { that.m_checked = true; }
-
- /// Destructor checks if return value was used.
- inline ~CheckReturn( void )
- {
- // If m_checked is false, then a function failed to check the
- // return value from a function call.
- if (!m_checked)
- OnError<Value>::run(m_value);
- }
-
- /// Conversion operator changes CheckReturn back to Value type.
- inline operator Value ( void )
- {
- m_checked = true;
- return m_value;
- }
+ /// Conversion constructor changes Value type to CheckReturn type.
+ inline CheckReturn( const Value& value ) :
+ m_value( value ), m_checked( false ) {}
+
+ /// Copy-constructor allows functions to call another function within the
+ /// return statement. The other CheckReturn's m_checked flag is set since
+ /// its duty has been passed to the m_checked flag in this one.
+ inline CheckReturn( const CheckReturn& that ) :
+ m_value( that.m_value ), m_checked( false )
+ { that.m_checked = true; }
+
+ /// Destructor checks if return value was used.
+ inline ~CheckReturn( void )
+ {
+ // If m_checked is false, then a function failed to check the
+ // return value from a function call.
+ if (!m_checked)
+ OnError<Value>::run(m_value);
+ }
+
+ /// Conversion operator changes CheckReturn back to Value type.
+ inline operator Value ( void )
+ {
+ m_checked = true;
+ return m_value;
+ }
private:
- /// Default constructor not implemented.
- CheckReturn( void );
+ /// Default constructor not implemented.
+ CheckReturn( void );
- /// Copy-assignment operator not implemented.
- CheckReturn & operator = ( const CheckReturn & that );
+ /// Copy-assignment operator not implemented.
+ CheckReturn& operator = ( const CheckReturn& that );
- /// Copy of returned value.
- Value m_value;
+ /// Copy of returned value.
+ Value m_value;
- /// Flag for whether calling function checked return value yet.
- mutable bool m_checked;
+ /// Flag for whether calling function checked return value yet.
+ mutable bool m_checked;
};
// ----------------------------------------------------------------------------
diff --git a/shared/loki/Checker.h b/shared/loki/Checker.h
index 19350679..64579d2f 100644
--- a/shared/loki/Checker.h
+++ b/shared/loki/Checker.h
@@ -86,9 +86,9 @@ class CheckForNoThrow
{
public:
- inline explicit CheckForNoThrow( const Host * ) {}
+ inline explicit CheckForNoThrow( const Host* ) {}
- inline bool Check( const Host * ) const
+ inline bool Check( const Host* ) const
{
const bool okay = ( !::std::uncaught_exception() );
assert( okay );
@@ -117,13 +117,13 @@ class CheckForNoChange
{
public:
- inline explicit CheckForNoChange( const Host * host ) :
+ inline explicit CheckForNoChange( const Host* host ) :
m_compare( *host ) {}
- inline bool Check( const Host * host ) const
+ inline bool Check( const Host* host ) const
{
const bool okay = ( !::std::uncaught_exception() )
- || ( m_compare == *host );
+ || ( m_compare == *host );
assert( okay );
return okay;
}
@@ -152,10 +152,10 @@ class CheckForNoChangeOrThrow
{
public:
- inline explicit CheckForNoChangeOrThrow( const Host * host ) :
+ inline explicit CheckForNoChangeOrThrow( const Host* host ) :
m_compare( *host ) {}
- inline bool Check( const Host * host ) const
+ inline bool Check( const Host* host ) const
{
bool okay = ( !::std::uncaught_exception() );
assert( okay );
@@ -187,10 +187,10 @@ class CheckForEquality
{
public:
- inline explicit CheckForEquality( const Host * host ) :
+ inline explicit CheckForEquality( const Host* host ) :
m_compare( *host ) {}
- inline bool Check( const Host * host ) const
+ inline bool Check( const Host* host ) const
{
const bool okay = ( m_compare == *host );
assert( okay );
@@ -219,8 +219,8 @@ template < class Host >
class CheckForNothing
{
public:
- inline explicit CheckForNothing( const Host * ) {}
- inline bool Check( const Host * ) const { return true; }
+ inline explicit CheckForNothing( const Host* ) {}
+ inline bool Check( const Host* ) const { return true; }
};
// ----------------------------------------------------------------------------
@@ -271,9 +271,9 @@ public:
template
<
- class Host,
- template < class > class ExceptionPolicy
->
+class Host,
+ template < class > class ExceptionPolicy
+ >
class ContractChecker : public ExceptionPolicy< Host >
{
/// Shorthand for the ExceptionPolicy class.
@@ -291,8 +291,8 @@ public:
@par pre Optional pointer to function that checks pre-conditions.
@par post Optional pointer to function that checks post-conditions.
*/
- inline ContractChecker( const Host * host, Validator validator,
- Validator pre = 0, Validator post = 0 ) :
+ inline ContractChecker( const Host* host, Validator validator,
+ Validator pre = 0, Validator post = 0 ) :
Ep( host ),
m_host( host ),
m_validator( validator ),
@@ -342,12 +342,12 @@ private:
/// Default constructor is not implemented.
ContractChecker( void );
/// Copy constructor is not implemented.
- ContractChecker( const ContractChecker & );
+ ContractChecker( const ContractChecker& );
/// Copy-assignment operator is not implemented.
- ContractChecker & operator = ( const ContractChecker & );
+ ContractChecker& operator = ( const ContractChecker& );
/// Pointer to the host object.
- const Host * m_host;
+ const Host* m_host;
/// Pointer to member function that checks Host object's invariants.
Validator m_validator;
@@ -428,7 +428,7 @@ public:
template
<
- class ExceptionPolicy
+class ExceptionPolicy
>
class StaticChecker : public ExceptionPolicy
{
@@ -447,7 +447,7 @@ public:
@par post Optional pointer to function that checks post-conditions.
*/
inline explicit StaticChecker( Validator validator,
- Validator pre = 0, Validator post = 0 ) :
+ Validator pre = 0, Validator post = 0 ) :
Ep(),
m_validator( validator ),
m_pre( pre ),
@@ -494,9 +494,9 @@ private:
/// Default constructor is not implemented.
StaticChecker( void );
/// Copy constructor is not implemented.
- StaticChecker( const StaticChecker & );
+ StaticChecker( const StaticChecker& );
/// Copy-assignment operator is not implemented.
- StaticChecker & operator = ( const StaticChecker & );
+ StaticChecker& operator = ( const StaticChecker& );
/// Pointer to member function that checks Host object's invariants.
Validator m_validator;
diff --git a/shared/loki/ConstPolicy.h b/shared/loki/ConstPolicy.h
index 74c9e5aa..1adb227a 100644
--- a/shared/loki/ConstPolicy.h
+++ b/shared/loki/ConstPolicy.h
@@ -2,12 +2,12 @@
// The Loki Library
// Copyright (c) 2006 Richard Sposato
// Copyright (c) 2006 Peter Kümmel
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The authors make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The authors make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_CONST_POLICY_INC_
@@ -32,11 +32,11 @@ namespace Loki
/// Don't propagate constness of pointed or referred object.
////////////////////////////////////////////////////////////////////////////////
- template< class T >
- struct DontPropagateConst
- {
- typedef T Type;
- };
+template< class T >
+struct DontPropagateConst
+{
+ typedef T Type;
+};
////////////////////////////////////////////////////////////////////////////////
/// \class PropagateConst
@@ -45,11 +45,11 @@ namespace Loki
/// Propagate constness of pointed or referred object.
////////////////////////////////////////////////////////////////////////////////
- template< class T >
- struct PropagateConst
- {
- typedef const T Type;
- };
+template< class T >
+struct PropagateConst
+{
+ typedef const T Type;
+};
// default will not break existing code
#ifndef LOKI_DEFAULT_CONSTNESS
diff --git a/shared/loki/DataGenerators.h b/shared/loki/DataGenerators.h
index 1c8e2df0..7ac697af 100644
--- a/shared/loki/DataGenerators.h
+++ b/shared/loki/DataGenerators.h
@@ -2,7 +2,7 @@
// The Loki Library
// Data Generator by Shannon Barber
// This code DOES NOT accompany the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
//
// Code covered by the MIT License
@@ -44,69 +44,69 @@ gendata(std::back_inserter(stuff));
*******************************************************************************/
namespace Loki
{
- namespace TL
- {
- template<typename T>
- struct nameof_type
- {
- const char* operator()()
- {
- return typeid(T).name();
- }
- };
- template<typename T>
- struct sizeof_type
- {
- size_t operator()()
- {
- return sizeof(T);
- }
- };
- template <class TList, template <class> class GenFunc>
- struct IterateTypes;
-
- template <class T1, class T2, template <class> class GenFunc>
- struct IterateTypes<Typelist<T1, T2>, GenFunc>
+namespace TL
+{
+template<typename T>
+struct nameof_type
+{
+ const char* operator()()
+ {
+ return typeid(T).name();
+ }
+};
+template<typename T>
+struct sizeof_type
+{
+ size_t operator()()
{
+ return sizeof(T);
+ }
+};
+template <class TList, template <class> class GenFunc>
+struct IterateTypes;
+
+template <class T1, class T2, template <class> class GenFunc>
+struct IterateTypes<Typelist<T1, T2>, GenFunc>
+{
typedef IterateTypes<T1, GenFunc> head_t;
head_t head;
typedef IterateTypes<T2, GenFunc> tail_t;
tail_t tail;
template<class II>
void operator()(II ii)
- {
+ {
head.operator()(ii);
tail.operator()(ii);
- }
- };
-
- template <class AtomicType, template <class> class GenFunc>
- struct IterateTypes
- {
+ }
+};
+
+template <class AtomicType, template <class> class GenFunc>
+struct IterateTypes
+{
template<class II>
void operator()(II ii)
- {
+ {
GenFunc<AtomicType> genfunc;
*ii = genfunc();
++ii; //Is this even needed?
- }
- };
-
- template <template <class> class GenFunc>
- struct IterateTypes<NullType, GenFunc>
- {
+ }
+};
+
+template <template <class> class GenFunc>
+struct IterateTypes<NullType, GenFunc>
+{
template<class II>
void operator()(II ii)
- {}
- };
-
- template<typename Types, template <class> class UnitFunc, typename II>
- void iterate_types(II ii)
- {
- Loki::TL::IterateTypes<Types, UnitFunc> it;
- it(ii);
- }
- }//ns TL
+ {}
+};
+
+template<typename Types, template <class> class UnitFunc, typename II>
+void iterate_types(II ii)
+{
+ Loki::TL::IterateTypes<Types, UnitFunc> it;
+ it(ii);
+}
+}//ns TL
}//ns Loki
#endif // end file guardian
diff --git a/shared/loki/EmptyType.h b/shared/loki/EmptyType.h
index b228e2e8..0f60c894 100644
--- a/shared/loki/EmptyType.h
+++ b/shared/loki/EmptyType.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_EMPTYTYPE_INC_
@@ -26,23 +26,23 @@ namespace Loki
// Useful as a strawman class
////////////////////////////////////////////////////////////////////////////////
- class EmptyType {};
-
-
- inline bool operator==(const EmptyType&, const EmptyType&)
- {
- return true;
- }
-
- inline bool operator<(const EmptyType&, const EmptyType&)
- {
- return false;
- }
-
- inline bool operator>(const EmptyType&, const EmptyType&)
- {
- return false;
- }
+class EmptyType {};
+
+
+inline bool operator==(const EmptyType&, const EmptyType&)
+{
+ return true;
+}
+
+inline bool operator<(const EmptyType&, const EmptyType&)
+{
+ return false;
+}
+
+inline bool operator>(const EmptyType&, const EmptyType&)
+{
+ return false;
+}
}
#endif // end file guardian
diff --git a/shared/loki/Factory.h b/shared/loki/Factory.h
index c4c3b22a..6a1ac6b7 100644
--- a/shared/loki/Factory.h
+++ b/shared/loki/Factory.h
@@ -33,7 +33,7 @@
* \defgroup FactoryGroup Factory
* \ingroup FactoriesGroup
* \brief Implements a generic object factory.
- *
+ *
* <i>The Factory Method pattern is an object-oriented design pattern.
* Like other creational patterns, it deals with the problem of creating objects
* (products) without specifying the exact class of object that will be created.
@@ -46,7 +46,7 @@
* whose main purpose is creation of objects.</i>
* <div ALIGN="RIGHT"><a href="http://en.wikipedia.org/wiki/Factory_method_pattern">
* Wikipedia</a></div>
- *
+ *
* Loki proposes a generic version of the Factory. Here is a typical use.<br>
* <code><br>
* 1. Factory< AbstractProduct, int > aFactory;<br>
@@ -62,7 +62,7 @@
* ProductCreator by registering them into the Factory.<br>
* A ProductCreator is a just a function that will return the right object. ie <br>
* <code>
- * Product* createProductNull()<br>
+ * Product* createProductNull()<br>
* {<br>
* return new Product<br>
* }<br>
@@ -80,27 +80,27 @@ namespace Loki
* \defgroup FactoryErrorPoliciesGroup Factory Error Policies
* \ingroup FactoryGroup
* \brief Manages the "Unknown Type" error in an object factory
- *
+ *
* \class DefaultFactoryError
* \ingroup FactoryErrorPoliciesGroup
- * \brief Default policy that throws an exception
- *
+ * \brief Default policy that throws an exception
+ *
*/
- template <typename IdentifierType, class AbstractProduct>
- struct DefaultFactoryError
+template <typename IdentifierType, class AbstractProduct>
+struct DefaultFactoryError
+{
+ struct Exception : public std::exception
{
- struct Exception : public std::exception
- {
- const char* what() const throw() { return "Unknown Type"; }
- };
-
- static AbstractProduct* OnUnknownType(IdentifierType)
- {
- throw Exception();
- }
+ const char* what() const throw() { return "Unknown Type"; }
};
+ static AbstractProduct* OnUnknownType(IdentifierType)
+ {
+ throw Exception();
+ }
+};
+
#define LOKI_ENABLE_NEW_FACTORY_CODE
#ifdef LOKI_ENABLE_NEW_FACTORY_CODE
@@ -110,911 +110,911 @@ namespace Loki
// class template FunctorImpl
////////////////////////////////////////////////////////////////////////////////
- struct FactoryImplBase
- {
- typedef EmptyType Parm1;
- typedef EmptyType Parm2;
- typedef EmptyType Parm3;
- typedef EmptyType Parm4;
- typedef EmptyType Parm5;
- typedef EmptyType Parm6;
- typedef EmptyType Parm7;
- typedef EmptyType Parm8;
- typedef EmptyType Parm9;
- typedef EmptyType Parm10;
- typedef EmptyType Parm11;
- typedef EmptyType Parm12;
- typedef EmptyType Parm13;
- typedef EmptyType Parm14;
- typedef EmptyType Parm15;
- };
-
- template <typename AP, typename Id, typename TList >
- struct FactoryImpl;
-
- template<typename AP, typename Id>
- struct FactoryImpl<AP, Id, NullType>
- : public FactoryImplBase
- {
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id & id ) = 0;
- };
+struct FactoryImplBase
+{
+ typedef EmptyType Parm1;
+ typedef EmptyType Parm2;
+ typedef EmptyType Parm3;
+ typedef EmptyType Parm4;
+ typedef EmptyType Parm5;
+ typedef EmptyType Parm6;
+ typedef EmptyType Parm7;
+ typedef EmptyType Parm8;
+ typedef EmptyType Parm9;
+ typedef EmptyType Parm10;
+ typedef EmptyType Parm11;
+ typedef EmptyType Parm12;
+ typedef EmptyType Parm13;
+ typedef EmptyType Parm14;
+ typedef EmptyType Parm15;
+};
+
+template <typename AP, typename Id, typename TList >
+struct FactoryImpl;
+
+template<typename AP, typename Id>
+struct FactoryImpl<AP, Id, NullType>
+ : public FactoryImplBase
+{
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id ) = 0;
+};
template <typename AP, typename Id, typename P1 >
- struct FactoryImpl<AP,Id, Seq<P1> >
- : public FactoryImplBase
- {
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1 ) = 0;
- };
+struct FactoryImpl<AP,Id, Seq<P1> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1 ) = 0;
+};
+
+template<typename AP, typename Id, typename P1,typename P2 >
+struct FactoryImpl<AP, Id, Seq<P1, P2> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2 ) = 0;
+};
+
+template<typename AP, typename Id, typename P1,typename P2,typename P3 >
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3 ) = 0;
+};
+
+template<typename AP, typename Id, typename P1,typename P2,typename P3,typename P4 >
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4 ) = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5 >
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5 ) = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6>
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6 )
+ = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7>
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7 )
+ = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8>
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8)
+ = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9>
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9)
+ = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10>
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9,Parm10)
+ = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10,
+ typename P11>
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9,Parm10,
+ Parm11)
+ = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10,
+ typename P11,typename P12>
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9,Parm10,
+ Parm11,Parm12)
+ = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10,
+ typename P11,typename P12,typename P13>
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9,Parm10,
+ Parm11,Parm12,Parm13)
+ = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10,
+ typename P11,typename P12,typename P13,typename P14>
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ typedef typename TypeTraits<P14>::ParameterType Parm14;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm8,Parm10,
+ Parm11,Parm12,Parm13,Parm14)
+ = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10,
+ typename P11,typename P12,typename P13,typename P14,typename P15 >
+struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15> >
+ : public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ typedef typename TypeTraits<P14>::ParameterType Parm14;
+ typedef typename TypeTraits<P15>::ParameterType Parm15;
+ virtual ~FactoryImpl() {}
+ virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9,Parm10,
+ Parm11,Parm12,Parm13,Parm14,Parm15 )
+ = 0;
+};
- template<typename AP, typename Id, typename P1,typename P2 >
- struct FactoryImpl<AP, Id, Seq<P1, P2> >
- : public FactoryImplBase
- {
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2 ) = 0;
- };
+#ifndef LOKI_DISABLE_TYPELIST_MACROS
- template<typename AP, typename Id, typename P1,typename P2,typename P3 >
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3> >
- : public FactoryImplBase
- {
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3 ) = 0;
- };
+template <typename AP, typename Id, typename P1 >
+struct FactoryImpl<AP,Id, LOKI_TYPELIST_1( P1 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1 ) = 0;
+};
+
+template<typename AP, typename Id, typename P1,typename P2 >
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_2( P1, P2 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2 ) = 0;
+};
+
+template<typename AP, typename Id, typename P1,typename P2,typename P3 >
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_3( P1, P2, P3 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3 ) = 0;
+};
+
+template<typename AP, typename Id, typename P1,typename P2,typename P3,typename P4 >
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_4( P1, P2, P3, P4 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4 ) = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5 >
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_5( P1, P2, P3, P4, P5 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5 ) = 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6>
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_6( P1, P2, P3, P4, P5, P6 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6 )
+= 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7>
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_7( P1, P2, P3, P4, P5, P6, P7 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7 )
+= 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8>
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_8( P1, P2, P3, P4, P5, P6, P7, P8 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8)
+= 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9>
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_9( P1, P2, P3, P4, P5, P6, P7, P8, P9 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9)
+= 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10>
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_10( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9,Parm10)
+= 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10,
+ typename P11>
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_11( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9,Parm10,
+ Parm11)
+= 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10,
+ typename P11,typename P12>
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_12( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9,Parm10,
+ Parm11,Parm12)
+= 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10,
+ typename P11,typename P12,typename P13>
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_13( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9,Parm10,
+ Parm11,Parm12,Parm13)
+= 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10,
+ typename P11,typename P12,typename P13,typename P14>
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_14( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ typedef typename TypeTraits<P14>::ParameterType Parm14;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm8,Parm10,
+ Parm11,Parm12,Parm13,Parm14)
+= 0;
+};
+
+template<typename AP, typename Id,
+ typename P1,typename P2,typename P3,typename P4,typename P5,
+ typename P6,typename P7,typename P8,typename P9,typename P10,
+ typename P11,typename P12,typename P13,typename P14,typename P15 >
+struct FactoryImpl<AP, Id, LOKI_TYPELIST_15( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15 )>
+: public FactoryImplBase
+{
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ typedef typename TypeTraits<P14>::ParameterType Parm14;
+ typedef typename TypeTraits<P15>::ParameterType Parm15;
+virtual ~FactoryImpl() {}
+virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
+ Parm6, Parm7, Parm8, Parm9,Parm10,
+ Parm11,Parm12,Parm13,Parm14,Parm15 )
+= 0;
+};
- template<typename AP, typename Id, typename P1,typename P2,typename P3,typename P4 >
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4> >
- : public FactoryImplBase
- {
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4 ) = 0;
- };
+#endif //LOKI_DISABLE_TYPELIST_MACROS
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5 >
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5> >
- : public FactoryImplBase
- {
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5 ) = 0;
- };
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6>
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6> >
- : public FactoryImplBase
+////////////////////////////////////////////////////////////////////////////////
+/// \class Factory
+///
+/// \ingroup FactoryGroup
+/// Implements a generic object factory.
+///
+/// Create functions can have up to 15 parameters.
+///
+/// \par Singleton lifetime when used with Loki::SingletonHolder
+/// Because Factory uses internally Functors which inherits from
+/// SmallObject you must use the singleton lifetime
+/// \code Loki::LongevityLifetime::DieAsSmallObjectChild \endcode
+/// Alternatively you could suppress for Functor the inheritance
+/// from SmallObject by defining the macro:
+/// \code LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT \endcode
+////////////////////////////////////////////////////////////////////////////////
+template
+<
+class AbstractProduct,
+ typename IdentifierType,
+ typename CreatorParmTList = NullType,
+ template<typename, class> class FactoryErrorPolicy = DefaultFactoryError
+ >
+class Factory : public FactoryErrorPolicy<IdentifierType, AbstractProduct>
+{
+ typedef FactoryImpl< AbstractProduct, IdentifierType, CreatorParmTList > Impl;
+
+ typedef typename Impl::Parm1 Parm1;
+ typedef typename Impl::Parm2 Parm2;
+ typedef typename Impl::Parm3 Parm3;
+ typedef typename Impl::Parm4 Parm4;
+ typedef typename Impl::Parm5 Parm5;
+ typedef typename Impl::Parm6 Parm6;
+ typedef typename Impl::Parm7 Parm7;
+ typedef typename Impl::Parm8 Parm8;
+ typedef typename Impl::Parm9 Parm9;
+ typedef typename Impl::Parm10 Parm10;
+ typedef typename Impl::Parm11 Parm11;
+ typedef typename Impl::Parm12 Parm12;
+ typedef typename Impl::Parm13 Parm13;
+ typedef typename Impl::Parm14 Parm14;
+ typedef typename Impl::Parm15 Parm15;
+
+ typedef Functor<AbstractProduct*, CreatorParmTList> ProductCreator;
+
+ typedef AssocVector<IdentifierType, ProductCreator> IdToProductMap;
+
+ IdToProductMap associations_;
+
+public:
+
+ Factory()
+ : associations_()
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6 )
- = 0;
- };
+ }
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7>
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7> >
- : public FactoryImplBase
+ ~Factory()
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7 )
- = 0;
- };
+ associations_.erase(associations_.begin(), associations_.end());
+ }
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8>
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8> >
- : public FactoryImplBase
+ bool Register(const IdentifierType& id, ProductCreator creator)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8)
- = 0;
- };
+ return associations_.insert(
+ typename IdToProductMap::value_type(id, creator)).second != 0;
+ }
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9>
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9> >
- : public FactoryImplBase
+ template <class PtrObj, typename CreaFn>
+ bool Register(const IdentifierType& id, const PtrObj& p, CreaFn fn)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9)
- = 0;
- };
+ ProductCreator creator( p, fn );
+ return associations_.insert(
+ typename IdToProductMap::value_type(id, creator)).second != 0;
+ }
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10>
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> >
- : public FactoryImplBase
+ bool Unregister(const IdentifierType& id)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9,Parm10)
- = 0;
- };
+ return associations_.erase(id) != 0;
+ }
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10,
- typename P11>
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11> >
- : public FactoryImplBase
+ std::vector<IdentifierType> RegisteredIds()
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9,Parm10,
- Parm11)
- = 0;
- };
+ std::vector<IdentifierType> ids;
+ for(typename IdToProductMap::iterator it = associations_.begin();
+ it != associations_.end(); ++it)
+ {
+ ids.push_back(it->first);
+ }
+ return ids;
+ }
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10,
- typename P11,typename P12>
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12> >
- : public FactoryImplBase
+ AbstractProduct* CreateObject(const IdentifierType& id)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9,Parm10,
- Parm11,Parm12)
- = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10,
- typename P11,typename P12,typename P13>
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13> >
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9,Parm10,
- Parm11,Parm12,Parm13)
- = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10,
- typename P11,typename P12,typename P13,typename P14>
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14> >
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- typedef typename TypeTraits<P14>::ParameterType Parm14;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm8,Parm10,
- Parm11,Parm12,Parm13,Parm14)
- = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10,
- typename P11,typename P12,typename P13,typename P14,typename P15 >
- struct FactoryImpl<AP, Id, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15> >
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- typedef typename TypeTraits<P14>::ParameterType Parm14;
- typedef typename TypeTraits<P15>::ParameterType Parm15;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9,Parm10,
- Parm11,Parm12,Parm13,Parm14,Parm15 )
- = 0;
- };
-
-#ifndef LOKI_DISABLE_TYPELIST_MACROS
-
- template <typename AP, typename Id, typename P1 >
- struct FactoryImpl<AP,Id, LOKI_TYPELIST_1( P1 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1 ) = 0;
- };
-
- template<typename AP, typename Id, typename P1,typename P2 >
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_2( P1, P2 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2 ) = 0;
- };
-
- template<typename AP, typename Id, typename P1,typename P2,typename P3 >
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_3( P1, P2, P3 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3 ) = 0;
- };
-
- template<typename AP, typename Id, typename P1,typename P2,typename P3,typename P4 >
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_4( P1, P2, P3, P4 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5,p6 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7 )
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4 ) = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5 >
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_5( P1, P2, P3, P4, P5 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5,p6,p7 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5 ) = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6>
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_6( P1, P2, P3, P4, P5, P6 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6 )
- = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7>
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_7( P1, P2, P3, P4, P5, P6, P7 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9 );
+ return this->OnUnknownType(id);
+ }
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9,Parm10 p10)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7 )
- = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8>
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_8( P1, P2, P3, P4, P5, P6, P7, P8 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
+ Parm11 p11)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8)
- = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9>
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_9( P1, P2, P3, P4, P5, P6, P7, P8, P9 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
+ Parm11 p11, Parm12 p12)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9)
- = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10>
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_10( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
+ Parm11 p11, Parm12 p12, Parm13 p13)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9,Parm10)
- = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10,
- typename P11>
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_11( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
+ Parm11 p11, Parm12 p12, Parm13 p13, Parm14 p14)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9,Parm10,
- Parm11)
- = 0;
- };
-
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10,
- typename P11,typename P12>
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_12( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12 )>
- : public FactoryImplBase
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14 );
+ return this->OnUnknownType(id);
+ }
+
+ AbstractProduct* CreateObject(const IdentifierType& id,
+ Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
+ Parm11 p11, Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9,Parm10,
- Parm11,Parm12)
- = 0;
- };
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
+ return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15 );
+ return this->OnUnknownType(id);
+ }
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10,
- typename P11,typename P12,typename P13>
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_13( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13 )>
- : public FactoryImplBase
- {
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9,Parm10,
- Parm11,Parm12,Parm13)
- = 0;
- };
+};
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10,
- typename P11,typename P12,typename P13,typename P14>
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_14( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14 )>
- : public FactoryImplBase
- {
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- typedef typename TypeTraits<P14>::ParameterType Parm14;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm8,Parm10,
- Parm11,Parm12,Parm13,Parm14)
- = 0;
- };
+#else
- template<typename AP, typename Id,
- typename P1,typename P2,typename P3,typename P4,typename P5,
- typename P6,typename P7,typename P8,typename P9,typename P10,
- typename P11,typename P12,typename P13,typename P14,typename P15 >
- struct FactoryImpl<AP, Id, LOKI_TYPELIST_15( P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13, P14, P15 )>
- : public FactoryImplBase
+template
+<
+class AbstractProduct,
+ typename IdentifierType,
+ typename ProductCreator = AbstractProduct* (*)(),
+ template<typename, class>
+ class FactoryErrorPolicy = DefaultFactoryError
+ >
+class Factory
+ : public FactoryErrorPolicy<IdentifierType, AbstractProduct>
+{
+public:
+ bool Register(const IdentifierType& id, ProductCreator creator)
{
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- typedef typename TypeTraits<P14>::ParameterType Parm14;
- typedef typename TypeTraits<P15>::ParameterType Parm15;
- virtual ~FactoryImpl() {}
- virtual AP* CreateObject(const Id& id,Parm1, Parm2, Parm3, Parm4, Parm5,
- Parm6, Parm7, Parm8, Parm9,Parm10,
- Parm11,Parm12,Parm13,Parm14,Parm15 )
- = 0;
- };
-
-#endif //LOKI_DISABLE_TYPELIST_MACROS
-
+ return associations_.insert(
+ typename IdToProductMap::value_type(id, creator)).second != 0;
+ }
-////////////////////////////////////////////////////////////////////////////////
-/// \class Factory
-///
-/// \ingroup FactoryGroup
-/// Implements a generic object factory.
-///
-/// Create functions can have up to 15 parameters.
-///
-/// \par Singleton lifetime when used with Loki::SingletonHolder
-/// Because Factory uses internally Functors which inherits from
-/// SmallObject you must use the singleton lifetime
-/// \code Loki::LongevityLifetime::DieAsSmallObjectChild \endcode
-/// Alternatively you could suppress for Functor the inheritance
-/// from SmallObject by defining the macro:
-/// \code LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT \endcode
-////////////////////////////////////////////////////////////////////////////////
- template
- <
- class AbstractProduct,
- typename IdentifierType,
- typename CreatorParmTList = NullType,
- template<typename, class> class FactoryErrorPolicy = DefaultFactoryError
- >
- class Factory : public FactoryErrorPolicy<IdentifierType, AbstractProduct>
+ bool Unregister(const IdentifierType& id)
{
- typedef FactoryImpl< AbstractProduct, IdentifierType, CreatorParmTList > Impl;
-
- typedef typename Impl::Parm1 Parm1;
- typedef typename Impl::Parm2 Parm2;
- typedef typename Impl::Parm3 Parm3;
- typedef typename Impl::Parm4 Parm4;
- typedef typename Impl::Parm5 Parm5;
- typedef typename Impl::Parm6 Parm6;
- typedef typename Impl::Parm7 Parm7;
- typedef typename Impl::Parm8 Parm8;
- typedef typename Impl::Parm9 Parm9;
- typedef typename Impl::Parm10 Parm10;
- typedef typename Impl::Parm11 Parm11;
- typedef typename Impl::Parm12 Parm12;
- typedef typename Impl::Parm13 Parm13;
- typedef typename Impl::Parm14 Parm14;
- typedef typename Impl::Parm15 Parm15;
-
- typedef Functor<AbstractProduct*, CreatorParmTList> ProductCreator;
-
- typedef AssocVector<IdentifierType, ProductCreator> IdToProductMap;
-
- IdToProductMap associations_;
-
- public:
-
- Factory()
- : associations_()
- {
- }
+ return associations_.erase(id) != 0;
+ }
- ~Factory()
- {
- associations_.erase(associations_.begin(), associations_.end());
- }
-
- bool Register(const IdentifierType& id, ProductCreator creator)
- {
- return associations_.insert(
- typename IdToProductMap::value_type(id, creator)).second != 0;
- }
-
- template <class PtrObj, typename CreaFn>
- bool Register(const IdentifierType& id, const PtrObj& p, CreaFn fn)
- {
- ProductCreator creator( p, fn );
- return associations_.insert(
- typename IdToProductMap::value_type(id, creator)).second != 0;
- }
-
- bool Unregister(const IdentifierType& id)
- {
- return associations_.erase(id) != 0;
- }
-
- std::vector<IdentifierType> RegisteredIds()
- {
- std::vector<IdentifierType> ids;
- for(typename IdToProductMap::iterator it = associations_.begin();
- it != associations_.end(); ++it)
- {
- ids.push_back(it->first);
- }
- return ids;
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5,p6 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7 )
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5,p6,p7 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9 );
- return this->OnUnknownType(id);
- }
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9,Parm10 p10)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
- Parm11 p11)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
- Parm11 p11, Parm12 p12)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
- Parm11 p11, Parm12 p12, Parm13 p13)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
- Parm11 p11, Parm12 p12, Parm13 p13, Parm14 p14)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14 );
- return this->OnUnknownType(id);
- }
-
- AbstractProduct* CreateObject(const IdentifierType& id,
- Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10,
- Parm11 p11, Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- return (i->second)( p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15 );
- return this->OnUnknownType(id);
- }
-
- };
-
-#else
-
- template
- <
- class AbstractProduct,
- typename IdentifierType,
- typename ProductCreator = AbstractProduct* (*)(),
- template<typename, class>
- class FactoryErrorPolicy = DefaultFactoryError
- >
- class Factory
- : public FactoryErrorPolicy<IdentifierType, AbstractProduct>
+ AbstractProduct* CreateObject(const IdentifierType& id)
{
- public:
- bool Register(const IdentifierType& id, ProductCreator creator)
- {
- return associations_.insert(
- typename IdToProductMap::value_type(id, creator)).second != 0;
- }
-
- bool Unregister(const IdentifierType& id)
+ typename IdToProductMap::iterator i = associations_.find(id);
+ if (i != associations_.end())
{
- return associations_.erase(id) != 0;
+ return (i->second)();
}
+ return this->OnUnknownType(id);
+ }
- AbstractProduct* CreateObject(const IdentifierType& id)
- {
- typename IdToProductMap::iterator i = associations_.find(id);
- if (i != associations_.end())
- {
- return (i->second)();
- }
- return this->OnUnknownType(id);
- }
-
- private:
- typedef AssocVector<IdentifierType, ProductCreator> IdToProductMap;
- IdToProductMap associations_;
- };
+private:
+ typedef AssocVector<IdentifierType, ProductCreator> IdToProductMap;
+ IdToProductMap associations_;
+};
#endif //#define ENABLE_NEW_FACTORY_CODE
@@ -1028,51 +1028,51 @@ template <typename AP, typename Id, typename P1 >
* \brief Creates a copy from a polymorphic object.
*/
- template
- <
- class AbstractProduct,
- class ProductCreator =
- AbstractProduct* (*)(const AbstractProduct*),
- template<typename, class>
- class FactoryErrorPolicy = DefaultFactoryError
- >
- class CloneFactory
- : public FactoryErrorPolicy<TypeInfo, AbstractProduct>
+template
+<
+class AbstractProduct,
+ class ProductCreator =
+ AbstractProduct* (*)(const AbstractProduct*),
+ template<typename, class>
+ class FactoryErrorPolicy = DefaultFactoryError
+ >
+class CloneFactory
+ : public FactoryErrorPolicy<TypeInfo, AbstractProduct>
+{
+public:
+ bool Register(const TypeInfo& ti, ProductCreator creator)
{
- public:
- bool Register(const TypeInfo& ti, ProductCreator creator)
- {
- return associations_.insert(
- typename IdToProductMap::value_type(ti, creator)).second != 0;
- }
+ return associations_.insert(
+ typename IdToProductMap::value_type(ti, creator)).second != 0;
+ }
+
+ bool Unregister(const TypeInfo& id)
+ {
+ return associations_.erase(id) != 0;
+ }
- bool Unregister(const TypeInfo& id)
+ AbstractProduct* CreateObject(const AbstractProduct* model)
+ {
+ if (model == NULL)
{
- return associations_.erase(id) != 0;
+ return NULL;
}
- AbstractProduct* CreateObject(const AbstractProduct* model)
+ typename IdToProductMap::iterator i =
+ associations_.find(typeid(*model));
+
+ if (i != associations_.end())
{
- if (model == NULL)
- {
- return NULL;
- }
-
- typename IdToProductMap::iterator i =
- associations_.find(typeid(*model));
-
- if (i != associations_.end())
- {
- return (i->second)(model);
- }
- return this->OnUnknownType(typeid(*model));
+ return (i->second)(model);
}
+ return this->OnUnknownType(typeid(*model));
+ }
+
+private:
+ typedef AssocVector<TypeInfo, ProductCreator> IdToProductMap;
+ IdToProductMap associations_;
+};
- private:
- typedef AssocVector<TypeInfo, ProductCreator> IdToProductMap;
- IdToProductMap associations_;
- };
-
} // namespace Loki
diff --git a/shared/loki/Function.h b/shared/loki/Function.h
index 2d0ad4bb..f2badfe9 100644
--- a/shared/loki/Function.h
+++ b/shared/loki/Function.h
@@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
// The Loki Library
// Copyright (c) 2005 Peter Kümmel
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_FUNCTION_INC_
@@ -25,63 +25,63 @@
namespace Loki
{
- ////////////////////////////////////////////////////////////////////////////////
- /// \struct Function
- ///
- /// \ingroup FunctorGroup
- /// Allows a boost/TR1 like usage of Functor.
- ///
- /// \par Usage
- ///
- /// - free functions: e.g. \code Function<int(int,int)> f(&freeFunction);
- /// \endcode
- /// - member functions: e.g \code Function<int()> f(&object,&ObjectType::memberFunction);
- /// \endcode
- ///
- /// see also test/Function/FunctionTest.cpp (the modified test program from boost)
- ////////////////////////////////////////////////////////////////////////////////
-
- template<class R = void()>
- struct Function;
-
-
- template<class R>
- struct Function<R()> : public Functor<R>
- {
- typedef Functor<R> FBase;
-
- Function() : FBase() {}
-
- Function(const Function& func) : FBase()
- {
- if( !func.empty())
- FBase::operator=(func);
- }
-
- // test on emptiness
- template<class R2>
- Function(Function<R2()> func) : FBase()
- {
- if(!func.empty())
- FBase::operator=(func);
- }
-
- // clear by '= 0'
- Function(const int i) : FBase()
- {
- if(i==0)
- FBase::clear();
- else
- throw std::runtime_error("Loki::Function(const int i): i!=0");
- }
-
- template<class Func>
- Function(Func func) : FBase(func) {}
+////////////////////////////////////////////////////////////////////////////////
+/// \struct Function
+///
+/// \ingroup FunctorGroup
+/// Allows a boost/TR1 like usage of Functor.
+///
+/// \par Usage
+///
+/// - free functions: e.g. \code Function<int(int,int)> f(&freeFunction);
+/// \endcode
+/// - member functions: e.g \code Function<int()> f(&object,&ObjectType::memberFunction);
+/// \endcode
+///
+/// see also test/Function/FunctionTest.cpp (the modified test program from boost)
+////////////////////////////////////////////////////////////////////////////////
+
+template<class R = void()>
+struct Function;
+
+
+template<class R>
+struct Function<R()> : public Functor<R>
+{
+ typedef Functor<R> FBase;
- template<class Host, class Func>
- Function(const Host& host, const Func& func) : FBase(host,func) {}
+ Function() : FBase() {}
- };
+Function(const Function& func) : FBase()
+{
+ if( !func.empty())
+ FBase::operator=(func);
+}
+
+// test on emptiness
+template<class R2>
+Function(Function<R2()> func) : FBase()
+{
+ if(!func.empty())
+ FBase::operator=(func);
+}
+
+// clear by '= 0'
+Function(const int i) : FBase()
+{
+ if(i==0)
+ FBase::clear();
+ else
+ throw std::runtime_error("Loki::Function(const int i): i!=0");
+}
+
+template<class Func>
+Function(Func func) : FBase(func) {}
+
+template<class Host, class Func>
+Function(const Host& host, const Func& func) : FBase(host,func) {}
+
+};
////////////////////////////////////////////////////////////////////////////////
@@ -113,7 +113,7 @@ namespace Loki
template<class Host, class Func> \
Function(const Host& host, const Func& func): FBase(host,func) {}
-
+
#define LOKI_FUNCTION_R2_CTOR_BODY \
\
: FBase() \
@@ -127,245 +127,245 @@ namespace Loki
// repetitions
////////////////////////////////////////////////////////////////////////////////
- template<>
- struct Function<>
+template<>
+struct Function<>
: public Loki::Functor<>
- {
- typedef Functor<> FBase;
-
- template<class R2>
- Function(Function<R2()> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY // if compilation breaks here then
- // Function.h was not included before
- // Functor.h, check your include order
- // or define LOKI_ENABLE_FUNCTION
- };
-
- template<class R,class P01>
- struct Function<R(P01)>
- : public Loki::Functor<R, Seq<P01> >
- {
- typedef Functor<R, Seq<P01> > FBase;
-
- template<class R2,class Q01>
- Function(Function<R2(Q01)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R,class P01,class P02>
- struct Function<R(P01,P02)>
- : public Functor<R, Seq<P01,P02> >
- {
- typedef Functor<R, Seq<P01,P02> > FBase;
-
- template<class R2,class Q01, class Q02>
- Function(Function<R2(Q01,Q02)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R,class P01,class P02, class P03>
- struct Function<R(P01,P02,P03)>
- : public Functor<R, Seq<P01,P02,P03> >
- {
- typedef Functor<R, Seq<P01,P02,P03> > FBase;
-
- template<class R2,class Q01, class Q02,class Q03>
- Function(Function<R2(Q01,Q02,Q03)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R,class P01,class P02, class P03,class P04>
- struct Function<R(P01,P02,P03,P04)>
- : public Functor<R, Seq<P01,P02,P03,P04> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04> > FBase;
-
- template<class R2,class Q01,class Q02, class Q03,class Q04>
- Function(Function<R2(Q01,Q02,Q03,Q04)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R,class P01,class P02, class P03,class P04,class P05>
- struct Function<R(P01,P02,P03,P04,P05)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05> > FBase;
-
- template<class R2,class Q01,class Q02, class Q03,class Q04,class Q05>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R, class P01,class P02, class P03,class P04,class P05,
- class P06>
- struct Function<R(P01,P02,P03,P04,P05,P06)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05,P06> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06> > FBase;
-
- template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
- class Q06>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R, class P01,class P02, class P03,class P04,class P05,
- class P06,class P07>
- struct Function<R(P01,P02,P03,P04,P05,P06,P07)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> > FBase;
-
- template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
- class Q06,class Q07>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R, class P01,class P02, class P03,class P04,class P05,
- class P06,class P07, class P08>
- struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> > FBase;
-
- template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
- class Q06,class Q07, class Q08>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R, class P01,class P02, class P03,class P04,class P05,
- class P06,class P07, class P08,class P09>
- struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09 > > FBase;
-
- template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
- class Q06,class Q07, class Q08,class Q09>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R, class P01,class P02, class P03,class P04,class P05,
- class P06,class P07, class P08,class P09,class P10>
- struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> > FBase;
-
- template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
- class Q06,class Q07, class Q08,class Q09,class Q10>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R, class P01,class P02, class P03,class P04,class P05,
- class P06,class P07, class P08,class P09,class P10,
- class P11>
- struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >FBase;
-
- template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
- class Q06,class Q07, class Q08,class Q09,class Q10,
- class Q11>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R, class P01,class P02, class P03,class P04,class P05,
- class P06,class P07, class P08,class P09,class P10,
- class P11,class P12>
- struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> > FBase;
-
- template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
- class Q06,class Q07, class Q08,class Q09,class Q10,
- class Q11,class Q12>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R, class P01,class P02, class P03,class P04,class P05,
- class P06,class P07, class P08,class P09,class P10,
- class P11,class P12, class P13>
- struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> > FBase;
-
- template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
- class Q06,class Q07, class Q08,class Q09,class Q10,
- class Q11,class Q12, class Q13>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R, class P01,class P02, class P03,class P04,class P05,
- class P06,class P07, class P08,class P09,class P10,
- class P11,class P12, class P13,class P14>
- struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> > FBase;
- template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
- class Q06,class Q07, class Q08,class Q09,class Q10,
- class Q11,class Q12, class Q13,class Q14>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
-
- template<class R, class P01,class P02, class P03,class P04,class P05,
- class P06,class P07, class P08,class P09,class P10,
- class P11,class P12, class P13,class P14,class P15>
- struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15)>
- : public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> >
- {
- typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> > FBase;
-
- template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
- class Q06,class Q07, class Q08,class Q09,class Q10,
- class Q11,class Q12, class Q13,class Q14,class Q15>
- Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14,Q15)> func)
- LOKI_FUNCTION_R2_CTOR_BODY
-
- LOKI_FUNCTION_BODY
- };
+{
+ typedef Functor<> FBase;
+
+ template<class R2>
+ Function(Function<R2()> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY // if compilation breaks here then
+ // Function.h was not included before
+ // Functor.h, check your include order
+ // or define LOKI_ENABLE_FUNCTION
+};
+
+template<class R,class P01>
+struct Function<R(P01)>
+: public Loki::Functor<R, Seq<P01> >
+{
+ typedef Functor<R, Seq<P01> > FBase;
+
+ template<class R2,class Q01>
+ Function(Function<R2(Q01)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R,class P01,class P02>
+struct Function<R(P01,P02)>
+: public Functor<R, Seq<P01,P02> >
+{
+ typedef Functor<R, Seq<P01,P02> > FBase;
+
+ template<class R2,class Q01, class Q02>
+ Function(Function<R2(Q01,Q02)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R,class P01,class P02, class P03>
+struct Function<R(P01,P02,P03)>
+: public Functor<R, Seq<P01,P02,P03> >
+{
+ typedef Functor<R, Seq<P01,P02,P03> > FBase;
+
+ template<class R2,class Q01, class Q02,class Q03>
+ Function(Function<R2(Q01,Q02,Q03)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R,class P01,class P02, class P03,class P04>
+struct Function<R(P01,P02,P03,P04)>
+: public Functor<R, Seq<P01,P02,P03,P04> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04> > FBase;
+
+ template<class R2,class Q01,class Q02, class Q03,class Q04>
+ Function(Function<R2(Q01,Q02,Q03,Q04)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R,class P01,class P02, class P03,class P04,class P05>
+struct Function<R(P01,P02,P03,P04,P05)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05> > FBase;
+
+ template<class R2,class Q01,class Q02, class Q03,class Q04,class Q05>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R, class P01,class P02, class P03,class P04,class P05,
+ class P06>
+struct Function<R(P01,P02,P03,P04,P05,P06)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05,P06> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06> > FBase;
+
+ template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
+ class Q06>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R, class P01,class P02, class P03,class P04,class P05,
+ class P06,class P07>
+struct Function<R(P01,P02,P03,P04,P05,P06,P07)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07> > FBase;
+
+ template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
+ class Q06,class Q07>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R, class P01,class P02, class P03,class P04,class P05,
+ class P06,class P07, class P08>
+struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08> > FBase;
+
+ template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
+ class Q06,class Q07, class Q08>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R, class P01,class P02, class P03,class P04,class P05,
+ class P06,class P07, class P08,class P09>
+struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09 > > FBase;
+
+ template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
+ class Q06,class Q07, class Q08,class Q09>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R, class P01,class P02, class P03,class P04,class P05,
+ class P06,class P07, class P08,class P09,class P10>
+struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10> > FBase;
+
+ template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
+ class Q06,class Q07, class Q08,class Q09,class Q10>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R, class P01,class P02, class P03,class P04,class P05,
+ class P06,class P07, class P08,class P09,class P10,
+ class P11>
+struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11> >FBase;
+
+ template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
+ class Q06,class Q07, class Q08,class Q09,class Q10,
+ class Q11>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R, class P01,class P02, class P03,class P04,class P05,
+ class P06,class P07, class P08,class P09,class P10,
+ class P11,class P12>
+struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12> > FBase;
+
+ template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
+ class Q06,class Q07, class Q08,class Q09,class Q10,
+ class Q11,class Q12>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R, class P01,class P02, class P03,class P04,class P05,
+ class P06,class P07, class P08,class P09,class P10,
+ class P11,class P12, class P13>
+struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13> > FBase;
+
+ template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
+ class Q06,class Q07, class Q08,class Q09,class Q10,
+ class Q11,class Q12, class Q13>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R, class P01,class P02, class P03,class P04,class P05,
+ class P06,class P07, class P08,class P09,class P10,
+ class P11,class P12, class P13,class P14>
+struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14> > FBase;
+ template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
+ class Q06,class Q07, class Q08,class Q09,class Q10,
+ class Q11,class Q12, class Q13,class Q14>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
+
+template<class R, class P01,class P02, class P03,class P04,class P05,
+ class P06,class P07, class P08,class P09,class P10,
+ class P11,class P12, class P13,class P14,class P15>
+struct Function<R(P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15)>
+: public Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> >
+{
+ typedef Functor<R, Seq<P01,P02,P03,P04,P05,P06,P07,P08,P09,P10,P11,P12,P13,P14,P15> > FBase;
+
+ template<class R2, class Q01,class Q02, class Q03,class Q04,class Q05,
+ class Q06,class Q07, class Q08,class Q09,class Q10,
+ class Q11,class Q12, class Q13,class Q14,class Q15>
+ Function(Function<R2(Q01,Q02,Q03,Q04,Q05,Q06,Q07,Q08,Q09,Q10,Q11,Q12,Q13,Q14,Q15)> func)
+ LOKI_FUNCTION_R2_CTOR_BODY
+
+ LOKI_FUNCTION_BODY
+};
}// namespace Loki
diff --git a/shared/loki/Functor.h b/shared/loki/Functor.h
index bcba855d..a03f87c8 100644
--- a/shared/loki/Functor.h
+++ b/shared/loki/Functor.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_FUNCTOR_INC_
@@ -45,65 +45,66 @@ namespace Loki
// class template FunctorImpl (internal)
////////////////////////////////////////////////////////////////////////////////
- namespace Private
- {
- template <typename R, template <class, class> class ThreadingModel>
- struct FunctorImplBase
+namespace Private
+{
+template <typename R, template <class, class> class ThreadingModel>
+struct FunctorImplBase
#ifdef LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT
- {
+{
#else
- : public SmallValueObject<ThreadingModel>
- {
- inline FunctorImplBase() :
- SmallValueObject<ThreadingModel>() {}
- inline FunctorImplBase(const FunctorImplBase&) :
- SmallValueObject<ThreadingModel>() {}
+ :
+ public SmallValueObject<ThreadingModel>
+{
+ inline FunctorImplBase() :
+ SmallValueObject<ThreadingModel>() {}
+ inline FunctorImplBase(const FunctorImplBase&) :
+ SmallValueObject<ThreadingModel>() {}
#endif
- typedef R ResultType;
- typedef FunctorImplBase<R, ThreadingModel> FunctorImplBaseType;
-
- typedef EmptyType Parm1;
- typedef EmptyType Parm2;
- typedef EmptyType Parm3;
- typedef EmptyType Parm4;
- typedef EmptyType Parm5;
- typedef EmptyType Parm6;
- typedef EmptyType Parm7;
- typedef EmptyType Parm8;
- typedef EmptyType Parm9;
- typedef EmptyType Parm10;
- typedef EmptyType Parm11;
- typedef EmptyType Parm12;
- typedef EmptyType Parm13;
- typedef EmptyType Parm14;
- typedef EmptyType Parm15;
-
-
- virtual ~FunctorImplBase()
- {}
-
- virtual FunctorImplBase* DoClone() const = 0;
-
- template <class U>
- static U* Clone(U* pObj)
- {
- if (!pObj) return 0;
- U* pClone = static_cast<U*>(pObj->DoClone());
- assert(typeid(*pClone) == typeid(*pObj));
- return pClone;
- }
+ typedef R ResultType;
+ typedef FunctorImplBase<R, ThreadingModel> FunctorImplBaseType;
+
+ typedef EmptyType Parm1;
+ typedef EmptyType Parm2;
+ typedef EmptyType Parm3;
+ typedef EmptyType Parm4;
+ typedef EmptyType Parm5;
+ typedef EmptyType Parm6;
+ typedef EmptyType Parm7;
+ typedef EmptyType Parm8;
+ typedef EmptyType Parm9;
+ typedef EmptyType Parm10;
+ typedef EmptyType Parm11;
+ typedef EmptyType Parm12;
+ typedef EmptyType Parm13;
+ typedef EmptyType Parm14;
+ typedef EmptyType Parm15;
+
+
+ virtual ~FunctorImplBase()
+ {}
+
+ virtual FunctorImplBase* DoClone() const = 0;
+
+ template <class U>
+ static U* Clone(U* pObj)
+ {
+ if (!pObj) return 0;
+ U* pClone = static_cast<U*>(pObj->DoClone());
+ assert(typeid(*pClone) == typeid(*pObj));
+ return pClone;
+ }
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
- virtual bool operator==(const FunctorImplBase&) const = 0;
-
-#endif
-
- };
- }
-
+ virtual bool operator==(const FunctorImplBase&) const = 0;
+
+#endif
+
+};
+}
+
////////////////////////////////////////////////////////////////////////////////
// macro LOKI_DEFINE_CLONE_FUNCTORIMPL
// Implements the DoClone function for a functor implementation
@@ -121,409 +122,409 @@ namespace Loki
// Specializations of FunctorImpl for up to 15 parameters follow
////////////////////////////////////////////////////////////////////////////////
- template <typename R, class TList,
- template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>
- class FunctorImpl;
+template <typename R, class TList,
+ template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>
+class FunctorImpl;
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 0 (zero) parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, template <class, class> class ThreadingModel>
- class FunctorImpl<R, NullType, ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- virtual R operator()() = 0;
- };
+template <typename R, template <class, class> class ThreadingModel>
+class FunctorImpl<R, NullType, ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ virtual R operator()() = 0;
+};
- ////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 1 parameter
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, template <class, class> class ThreadingModel>
- class FunctorImpl<R, Seq<P1>, ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- virtual R operator()(Parm1) = 0;
- };
+template <typename R, typename P1, template <class, class> class ThreadingModel>
+class FunctorImpl<R, Seq<P1>, ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ virtual R operator()(Parm1) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 2 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, Seq<P1, P2>, ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- virtual R operator()(Parm1, Parm2) = 0;
- };
+template <typename R, typename P1, typename P2,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, Seq<P1, P2>, ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ virtual R operator()(Parm1, Parm2) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 3 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, Seq<P1, P2, P3>, ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- virtual R operator()(Parm1, Parm2, Parm3) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, Seq<P1, P2, P3>, ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ virtual R operator()(Parm1, Parm2, Parm3) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 4 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, Seq<P1, P2, P3, P4>, ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, Seq<P1, P2, P3, P4>, ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 5 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, Seq<P1, P2, P3, P4, P5>, ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, Seq<P1, P2, P3, P4, P5>, ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 6 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6>, ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6>, ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 7 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7>, ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7>, ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 8 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8>,
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8>,
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 9 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9>,
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9>,
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 10 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>,
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10>,
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 11 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10, typename P11,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R,
- Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>,
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10, Parm11) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10, typename P11,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R,
+ Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11>,
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10, Parm11) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 12 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10, typename P11, typename P12,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R,
- Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>,
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10, Parm11, Parm12) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10, typename P11, typename P12,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R,
+ Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12>,
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10, Parm11, Parm12) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 13 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10, typename P11, typename P12, typename P13,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R,
- Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>,
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10, typename P11, typename P12, typename P13,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R,
+ Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13>,
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 14 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10, typename P11, typename P12, typename P13, typename P14,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R,
- Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
- P14>,
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- typedef typename TypeTraits<P14>::ParameterType Parm14;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10, typename P11, typename P12, typename P13, typename P14,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R,
+ Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
+ P14>,
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ typedef typename TypeTraits<P14>::ParameterType Parm14;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 15 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10, typename P11, typename P12, typename P13, typename P14,
- typename P15, template <class, class> class ThreadingModel>
- class FunctorImpl<R,
- Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
- P14, P15>,
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- typedef typename TypeTraits<P14>::ParameterType Parm14;
- typedef typename TypeTraits<P15>::ParameterType Parm15;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14,
- Parm15) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10, typename P11, typename P12, typename P13, typename P14,
+ typename P15, template <class, class> class ThreadingModel>
+class FunctorImpl<R,
+ Seq<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
+ P14, P15>,
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ typedef typename TypeTraits<P14>::ParameterType Parm14;
+ typedef typename TypeTraits<P15>::ParameterType Parm15;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14,
+ Parm15) = 0;
+};
#ifndef LOKI_DISABLE_TYPELIST_MACROS
@@ -532,386 +533,386 @@ namespace Loki
// Specialization for 1 parameter
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, template <class, class> class ThreadingModel>
- class FunctorImpl<R, LOKI_TYPELIST_1(P1), ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- virtual R operator()(Parm1) = 0;
- };
+template <typename R, typename P1, template <class, class> class ThreadingModel>
+class FunctorImpl<R, LOKI_TYPELIST_1(P1), ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ virtual R operator()(Parm1) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 2 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, LOKI_TYPELIST_2(P1, P2), ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- virtual R operator()(Parm1, Parm2) = 0;
- };
+template <typename R, typename P1, typename P2,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, LOKI_TYPELIST_2(P1, P2), ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ virtual R operator()(Parm1, Parm2) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 3 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, LOKI_TYPELIST_3(P1, P2, P3), ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- virtual R operator()(Parm1, Parm2, Parm3) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, LOKI_TYPELIST_3(P1, P2, P3), ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ virtual R operator()(Parm1, Parm2, Parm3) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 4 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, LOKI_TYPELIST_4(P1, P2, P3, P4), ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, LOKI_TYPELIST_4(P1, P2, P3, P4), ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 5 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, LOKI_TYPELIST_5(P1, P2, P3, P4, P5), ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, LOKI_TYPELIST_5(P1, P2, P3, P4, P5), ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 6 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, LOKI_TYPELIST_6(P1, P2, P3, P4, P5, P6), ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, LOKI_TYPELIST_6(P1, P2, P3, P4, P5, P6), ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 7 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, LOKI_TYPELIST_7(P1, P2, P3, P4, P5, P6, P7), ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, LOKI_TYPELIST_7(P1, P2, P3, P4, P5, P6, P7), ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 8 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, LOKI_TYPELIST_8(P1, P2, P3, P4, P5, P6, P7, P8),
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, LOKI_TYPELIST_8(P1, P2, P3, P4, P5, P6, P7, P8),
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 9 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, LOKI_TYPELIST_9(P1, P2, P3, P4, P5, P6, P7, P8, P9),
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, LOKI_TYPELIST_9(P1, P2, P3, P4, P5, P6, P7, P8, P9),
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 10 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R, LOKI_TYPELIST_10(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10),
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R, LOKI_TYPELIST_10(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10),
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 11 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10, typename P11,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R,
- LOKI_TYPELIST_11(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11),
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10, Parm11) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10, typename P11,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R,
+ LOKI_TYPELIST_11(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11),
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10, Parm11) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 12 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10, typename P11, typename P12,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R,
- LOKI_TYPELIST_12(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12),
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10, Parm11, Parm12) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10, typename P11, typename P12,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R,
+ LOKI_TYPELIST_12(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12),
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10, Parm11, Parm12) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 13 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10, typename P11, typename P12, typename P13,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R,
- LOKI_TYPELIST_13(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13),
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10, typename P11, typename P12, typename P13,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R,
+ LOKI_TYPELIST_13(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13),
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 14 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10, typename P11, typename P12, typename P13, typename P14,
- template <class, class> class ThreadingModel>
- class FunctorImpl<R,
- LOKI_TYPELIST_14(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
- P14),
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- typedef typename TypeTraits<P14>::ParameterType Parm14;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10, typename P11, typename P12, typename P13, typename P14,
+ template <class, class> class ThreadingModel>
+class FunctorImpl<R,
+ LOKI_TYPELIST_14(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
+ P14),
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ typedef typename TypeTraits<P14>::ParameterType Parm14;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorImpl
// Specialization for 15 parameters
////////////////////////////////////////////////////////////////////////////////
- template <typename R, typename P1, typename P2, typename P3, typename P4,
- typename P5, typename P6, typename P7, typename P8, typename P9,
- typename P10, typename P11, typename P12, typename P13, typename P14,
- typename P15, template <class, class> class ThreadingModel>
- class FunctorImpl<R,
- LOKI_TYPELIST_15(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
- P14, P15),
- ThreadingModel>
- : public Private::FunctorImplBase<R, ThreadingModel>
- {
- public:
- typedef R ResultType;
- typedef typename TypeTraits<P1>::ParameterType Parm1;
- typedef typename TypeTraits<P2>::ParameterType Parm2;
- typedef typename TypeTraits<P3>::ParameterType Parm3;
- typedef typename TypeTraits<P4>::ParameterType Parm4;
- typedef typename TypeTraits<P5>::ParameterType Parm5;
- typedef typename TypeTraits<P6>::ParameterType Parm6;
- typedef typename TypeTraits<P7>::ParameterType Parm7;
- typedef typename TypeTraits<P8>::ParameterType Parm8;
- typedef typename TypeTraits<P9>::ParameterType Parm9;
- typedef typename TypeTraits<P10>::ParameterType Parm10;
- typedef typename TypeTraits<P11>::ParameterType Parm11;
- typedef typename TypeTraits<P12>::ParameterType Parm12;
- typedef typename TypeTraits<P13>::ParameterType Parm13;
- typedef typename TypeTraits<P14>::ParameterType Parm14;
- typedef typename TypeTraits<P15>::ParameterType Parm15;
- virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
- Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14,
- Parm15) = 0;
- };
+template <typename R, typename P1, typename P2, typename P3, typename P4,
+ typename P5, typename P6, typename P7, typename P8, typename P9,
+ typename P10, typename P11, typename P12, typename P13, typename P14,
+ typename P15, template <class, class> class ThreadingModel>
+class FunctorImpl<R,
+ LOKI_TYPELIST_15(P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, P13,
+ P14, P15),
+ ThreadingModel>
+ : public Private::FunctorImplBase<R, ThreadingModel>
+{
+public:
+ typedef R ResultType;
+ typedef typename TypeTraits<P1>::ParameterType Parm1;
+ typedef typename TypeTraits<P2>::ParameterType Parm2;
+ typedef typename TypeTraits<P3>::ParameterType Parm3;
+ typedef typename TypeTraits<P4>::ParameterType Parm4;
+ typedef typename TypeTraits<P5>::ParameterType Parm5;
+ typedef typename TypeTraits<P6>::ParameterType Parm6;
+ typedef typename TypeTraits<P7>::ParameterType Parm7;
+ typedef typename TypeTraits<P8>::ParameterType Parm8;
+ typedef typename TypeTraits<P9>::ParameterType Parm9;
+ typedef typename TypeTraits<P10>::ParameterType Parm10;
+ typedef typename TypeTraits<P11>::ParameterType Parm11;
+ typedef typename TypeTraits<P12>::ParameterType Parm12;
+ typedef typename TypeTraits<P13>::ParameterType Parm13;
+ typedef typename TypeTraits<P14>::ParameterType Parm14;
+ typedef typename TypeTraits<P15>::ParameterType Parm15;
+ virtual R operator()(Parm1, Parm2, Parm3, Parm4, Parm5, Parm6,
+ Parm7, Parm8, Parm9, Parm10, Parm11, Parm12, Parm13, Parm14,
+ Parm15) = 0;
+};
#endif //LOKI_DISABLE_TYPELIST_MACROS
@@ -920,275 +921,275 @@ namespace Loki
// Wraps functors and pointers to functions
////////////////////////////////////////////////////////////////////////////////
- template <class ParentFunctor, typename Fun>
- class FunctorHandler
- : public ParentFunctor::Impl
- {
- typedef typename ParentFunctor::Impl Base;
-
- public:
- typedef typename Base::ResultType ResultType;
- typedef typename Base::Parm1 Parm1;
- typedef typename Base::Parm2 Parm2;
- typedef typename Base::Parm3 Parm3;
- typedef typename Base::Parm4 Parm4;
- typedef typename Base::Parm5 Parm5;
- typedef typename Base::Parm6 Parm6;
- typedef typename Base::Parm7 Parm7;
- typedef typename Base::Parm8 Parm8;
- typedef typename Base::Parm9 Parm9;
- typedef typename Base::Parm10 Parm10;
- typedef typename Base::Parm11 Parm11;
- typedef typename Base::Parm12 Parm12;
- typedef typename Base::Parm13 Parm13;
- typedef typename Base::Parm14 Parm14;
- typedef typename Base::Parm15 Parm15;
-
- FunctorHandler(const Fun& fun) : f_(fun) {}
-
- LOKI_DEFINE_CLONE_FUNCTORIMPL(FunctorHandler)
+template <class ParentFunctor, typename Fun>
+class FunctorHandler
+ : public ParentFunctor::Impl
+{
+ typedef typename ParentFunctor::Impl Base;
+
+public:
+ typedef typename Base::ResultType ResultType;
+ typedef typename Base::Parm1 Parm1;
+ typedef typename Base::Parm2 Parm2;
+ typedef typename Base::Parm3 Parm3;
+ typedef typename Base::Parm4 Parm4;
+ typedef typename Base::Parm5 Parm5;
+ typedef typename Base::Parm6 Parm6;
+ typedef typename Base::Parm7 Parm7;
+ typedef typename Base::Parm8 Parm8;
+ typedef typename Base::Parm9 Parm9;
+ typedef typename Base::Parm10 Parm10;
+ typedef typename Base::Parm11 Parm11;
+ typedef typename Base::Parm12 Parm12;
+ typedef typename Base::Parm13 Parm13;
+ typedef typename Base::Parm14 Parm14;
+ typedef typename Base::Parm15 Parm15;
+
+ FunctorHandler(const Fun& fun) : f_(fun) {}
+
+ LOKI_DEFINE_CLONE_FUNCTORIMPL(FunctorHandler)
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
- bool operator==(const typename Base::FunctorImplBaseType& rhs) const
- {
- // there is no static information if Functor holds a member function
- // or a free function; this is the main difference to tr1::function
- if(typeid(*this) != typeid(rhs))
- return false; // cannot be equal
-
- const FunctorHandler& fh = static_cast<const FunctorHandler&>(rhs);
- // if this line gives a compiler error, you are using a function object.
- // you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
- return f_==fh.f_;
- }
+ bool operator==(const typename Base::FunctorImplBaseType& rhs) const
+ {
+ // there is no static information if Functor holds a member function
+ // or a free function; this is the main difference to tr1::function
+ if(typeid(*this) != typeid(rhs))
+ return false; // cannot be equal
+
+ const FunctorHandler& fh = static_cast<const FunctorHandler&>(rhs);
+ // if this line gives a compiler error, you are using a function object.
+ // you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
+ return f_==fh.f_;
+ }
#endif
- // operator() implementations for up to 15 arguments
-
- ResultType operator()()
- { return f_(); }
-
- ResultType operator()(Parm1 p1)
- { return f_(p1); }
-
- ResultType operator()(Parm1 p1, Parm2 p2)
- { return f_(p1, p2); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
- { return f_(p1, p2, p3); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
- { return f_(p1, p2, p3, p4); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
- { return f_(p1, p2, p3, p4, p5); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6)
- { return f_(p1, p2, p3, p4, p5, p6); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7)
- { return f_(p1, p2, p3, p4, p5, p6, p7); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8)
- { return f_(p1, p2, p3, p4, p5, p6, p7, p8); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
- { return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
- { return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
- { return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12)
- { return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13)
- { return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13, Parm14 p14)
- {
- return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
- p14);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
- {
- return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
- p14, p15);
- }
-
- private:
- Fun f_;
- };
-
+ // operator() implementations for up to 15 arguments
+
+ ResultType operator()()
+ { return f_(); }
+
+ ResultType operator()(Parm1 p1)
+ { return f_(p1); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2)
+ { return f_(p1, p2); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
+ { return f_(p1, p2, p3); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
+ { return f_(p1, p2, p3, p4); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
+ { return f_(p1, p2, p3, p4, p5); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6)
+ { return f_(p1, p2, p3, p4, p5, p6); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7)
+ { return f_(p1, p2, p3, p4, p5, p6, p7); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8)
+ { return f_(p1, p2, p3, p4, p5, p6, p7, p8); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
+ { return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
+ { return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
+ { return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12)
+ { return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13)
+ { return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13, Parm14 p14)
+ {
+ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
+ p14);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
+ {
+ return f_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
+ p14, p15);
+ }
+
+private:
+ Fun f_;
+};
+
////////////////////////////////////////////////////////////////////////////////
// class template FunctorHandler
// Wraps pointers to member functions
////////////////////////////////////////////////////////////////////////////////
- template <class ParentFunctor, typename PointerToObj,
- typename PointerToMemFn>
- class MemFunHandler : public ParentFunctor::Impl
- {
- typedef typename ParentFunctor::Impl Base;
-
- public:
- typedef typename Base::ResultType ResultType;
- typedef typename Base::Parm1 Parm1;
- typedef typename Base::Parm2 Parm2;
- typedef typename Base::Parm3 Parm3;
- typedef typename Base::Parm4 Parm4;
- typedef typename Base::Parm5 Parm5;
- typedef typename Base::Parm6 Parm6;
- typedef typename Base::Parm7 Parm7;
- typedef typename Base::Parm8 Parm8;
- typedef typename Base::Parm9 Parm9;
- typedef typename Base::Parm10 Parm10;
- typedef typename Base::Parm11 Parm11;
- typedef typename Base::Parm12 Parm12;
- typedef typename Base::Parm13 Parm13;
- typedef typename Base::Parm14 Parm14;
- typedef typename Base::Parm15 Parm15;
-
- MemFunHandler(const PointerToObj& pObj, PointerToMemFn pMemFn)
+template <class ParentFunctor, typename PointerToObj,
+ typename PointerToMemFn>
+class MemFunHandler : public ParentFunctor::Impl
+{
+ typedef typename ParentFunctor::Impl Base;
+
+public:
+ typedef typename Base::ResultType ResultType;
+ typedef typename Base::Parm1 Parm1;
+ typedef typename Base::Parm2 Parm2;
+ typedef typename Base::Parm3 Parm3;
+ typedef typename Base::Parm4 Parm4;
+ typedef typename Base::Parm5 Parm5;
+ typedef typename Base::Parm6 Parm6;
+ typedef typename Base::Parm7 Parm7;
+ typedef typename Base::Parm8 Parm8;
+ typedef typename Base::Parm9 Parm9;
+ typedef typename Base::Parm10 Parm10;
+ typedef typename Base::Parm11 Parm11;
+ typedef typename Base::Parm12 Parm12;
+ typedef typename Base::Parm13 Parm13;
+ typedef typename Base::Parm14 Parm14;
+ typedef typename Base::Parm15 Parm15;
+
+ MemFunHandler(const PointerToObj& pObj, PointerToMemFn pMemFn)
: pObj_(pObj), pMemFn_(pMemFn)
- {}
-
- LOKI_DEFINE_CLONE_FUNCTORIMPL(MemFunHandler)
+ {}
+
+ LOKI_DEFINE_CLONE_FUNCTORIMPL(MemFunHandler)
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
- bool operator==(const typename Base::FunctorImplBaseType& rhs) const
- {
- if(typeid(*this) != typeid(rhs))
- return false; // cannot be equal
-
- const MemFunHandler& mfh = static_cast<const MemFunHandler&>(rhs);
- // if this line gives a compiler error, you are using a function object.
- // you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
- return pObj_==mfh.pObj_ && pMemFn_==mfh.pMemFn_;
- }
-#endif
-
- ResultType operator()()
- { return ((*pObj_).*pMemFn_)(); }
-
- ResultType operator()(Parm1 p1)
- { return ((*pObj_).*pMemFn_)(p1); }
-
- ResultType operator()(Parm1 p1, Parm2 p2)
- { return ((*pObj_).*pMemFn_)(p1, p2); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
- { return ((*pObj_).*pMemFn_)(p1, p2, p3); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
- { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
- { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6)
- { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7)
- { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8)
- { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
- { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
- { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
- {
- return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
- p11);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12)
- {
- return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
- p11, p12);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13)
- {
- return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
- p11, p12, p13);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13, Parm14 p14)
- {
- return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
- p11, p12, p13, p14);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
- {
- return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
- p11, p12, p13, p14, p15);
- }
-
- private:
- PointerToObj pObj_;
- PointerToMemFn pMemFn_;
- };
-
+ bool operator==(const typename Base::FunctorImplBaseType& rhs) const
+ {
+ if(typeid(*this) != typeid(rhs))
+ return false; // cannot be equal
+
+ const MemFunHandler& mfh = static_cast<const MemFunHandler&>(rhs);
+ // if this line gives a compiler error, you are using a function object.
+ // you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
+ return pObj_==mfh.pObj_ && pMemFn_==mfh.pMemFn_;
+ }
+#endif
+
+ ResultType operator()()
+ { return ((*pObj_).*pMemFn_)(); }
+
+ ResultType operator()(Parm1 p1)
+ { return ((*pObj_).*pMemFn_)(p1); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2)
+ { return ((*pObj_).*pMemFn_)(p1, p2); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
+ { return ((*pObj_).*pMemFn_)(p1, p2, p3); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
+ { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
+ { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6)
+ { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7)
+ { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8)
+ { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
+ { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
+ { return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
+ {
+ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
+ p11);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12)
+ {
+ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
+ p11, p12);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13)
+ {
+ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
+ p11, p12, p13);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13, Parm14 p14)
+ {
+ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
+ p11, p12, p13, p14);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
+ {
+ return ((*pObj_).*pMemFn_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10,
+ p11, p12, p13, p14, p15);
+ }
+
+private:
+ PointerToObj pObj_;
+ PointerToMemFn pMemFn_;
+};
+
////////////////////////////////////////////////////////////////////////////////
// TR1 exception
//////////////////////////////////////////////////////////////////////////////////
#ifdef LOKI_ENABLE_FUNCTION
- class bad_function_call : public std::runtime_error
- {
- public:
- bad_function_call() : std::runtime_error("bad_function_call in Loki::Functor")
- {}
- };
+class bad_function_call : public std::runtime_error
+{
+public:
+ bad_function_call() : std::runtime_error("bad_function_call in Loki::Functor")
+ {}
+};
#define LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL if(empty()) throw bad_function_call();
#else
-#define LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+#define LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
#endif
@@ -1199,9 +1200,9 @@ namespace Loki
/// A generalized functor implementation with value semantics
///
/// \par Macro: LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT
-/// Define
+/// Define
/// \code LOKI_FUNCTOR_IS_NOT_A_SMALLOBJECT \endcode
-/// to avoid static instantiation/delete
+/// to avoid static instantiation/delete
/// order problems.
/// It often helps against crashes when using static Functors and multi threading.
/// Defining also removes problems when unloading Dlls which hosts
@@ -1210,415 +1211,415 @@ namespace Loki
/// \par Macro: LOKI_FUNCTORS_ARE_COMPARABLE
/// To enable the operator== define the macro
/// \code LOKI_FUNCTORS_ARE_COMPARABLE \endcode
-/// The macro is disabled by default, because it breaks compiling functor
+/// The macro is disabled by default, because it breaks compiling functor
/// objects which have no operator== implemented, keep in mind when you enable
/// operator==.
////////////////////////////////////////////////////////////////////////////////
- template <typename R = void, class TList = NullType,
- template<class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>
- class Functor
- {
- public:
- // Handy type definitions for the body type
- typedef FunctorImpl<R, TList, ThreadingModel> Impl;
- typedef R ResultType;
- typedef TList ParmList;
- typedef typename Impl::Parm1 Parm1;
- typedef typename Impl::Parm2 Parm2;
- typedef typename Impl::Parm3 Parm3;
- typedef typename Impl::Parm4 Parm4;
- typedef typename Impl::Parm5 Parm5;
- typedef typename Impl::Parm6 Parm6;
- typedef typename Impl::Parm7 Parm7;
- typedef typename Impl::Parm8 Parm8;
- typedef typename Impl::Parm9 Parm9;
- typedef typename Impl::Parm10 Parm10;
- typedef typename Impl::Parm11 Parm11;
- typedef typename Impl::Parm12 Parm12;
- typedef typename Impl::Parm13 Parm13;
- typedef typename Impl::Parm14 Parm14;
- typedef typename Impl::Parm15 Parm15;
-
- // Member functions
-
- Functor() : spImpl_(0)
- {}
-
- Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get()))
- {}
-
- Functor(std::auto_ptr<Impl> spImpl) : spImpl_(spImpl)
- {}
-
- template <typename Fun>
- Functor(Fun fun)
+template <typename R = void, class TList = NullType,
+ template<class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>
+class Functor
+{
+public:
+ // Handy type definitions for the body type
+ typedef FunctorImpl<R, TList, ThreadingModel> Impl;
+ typedef R ResultType;
+ typedef TList ParmList;
+ typedef typename Impl::Parm1 Parm1;
+ typedef typename Impl::Parm2 Parm2;
+ typedef typename Impl::Parm3 Parm3;
+ typedef typename Impl::Parm4 Parm4;
+ typedef typename Impl::Parm5 Parm5;
+ typedef typename Impl::Parm6 Parm6;
+ typedef typename Impl::Parm7 Parm7;
+ typedef typename Impl::Parm8 Parm8;
+ typedef typename Impl::Parm9 Parm9;
+ typedef typename Impl::Parm10 Parm10;
+ typedef typename Impl::Parm11 Parm11;
+ typedef typename Impl::Parm12 Parm12;
+ typedef typename Impl::Parm13 Parm13;
+ typedef typename Impl::Parm14 Parm14;
+ typedef typename Impl::Parm15 Parm15;
+
+ // Member functions
+
+ Functor() : spImpl_(0)
+ {}
+
+ Functor(const Functor& rhs) : spImpl_(Impl::Clone(rhs.spImpl_.get()))
+ {}
+
+ Functor(std::auto_ptr<Impl> spImpl) : spImpl_(spImpl)
+ {}
+
+ template <typename Fun>
+ Functor(Fun fun)
: spImpl_(new FunctorHandler<Functor, Fun>(fun))
- {}
+ {}
- template <class PtrObj, typename MemFn>
- Functor(const PtrObj& p, MemFn memFn)
+ template <class PtrObj, typename MemFn>
+ Functor(const PtrObj& p, MemFn memFn)
: spImpl_(new MemFunHandler<Functor, PtrObj, MemFn>(p, memFn))
- {}
+ {}
- typedef Impl * (std::auto_ptr<Impl>::*unspecified_bool_type)() const;
+ typedef Impl* (std::auto_ptr<Impl>::*unspecified_bool_type)() const;
- operator unspecified_bool_type() const
- {
- return spImpl_.get() ? &std::auto_ptr<Impl>::get : 0;
- }
+ operator unspecified_bool_type() const
+ {
+ return spImpl_.get() ? &std::auto_ptr<Impl>::get : 0;
+ }
- Functor& operator=(const Functor& rhs)
- {
- Functor copy(rhs);
- // swap auto_ptrs by hand
- Impl* p = spImpl_.release();
- spImpl_.reset(copy.spImpl_.release());
- copy.spImpl_.reset(p);
- return *this;
- }
+ Functor& operator=(const Functor& rhs)
+ {
+ Functor copy(rhs);
+ // swap auto_ptrs by hand
+ Impl* p = spImpl_.release();
+ spImpl_.reset(copy.spImpl_.release());
+ copy.spImpl_.reset(p);
+ return *this;
+ }
#ifdef LOKI_ENABLE_FUNCTION
- bool empty() const
- {
- return spImpl_.get() == 0;
- }
+ bool empty() const
+ {
+ return spImpl_.get() == 0;
+ }
- void clear()
- {
- spImpl_.reset(0);
- }
+ void clear()
+ {
+ spImpl_.reset(0);
+ }
#endif
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
- bool operator==(const Functor& rhs) const
- {
- if(spImpl_.get()==0 && rhs.spImpl_.get()==0)
- return true;
- if(spImpl_.get()!=0 && rhs.spImpl_.get()!=0)
- return *spImpl_.get() == *rhs.spImpl_.get();
- else
- return false;
- }
-
- bool operator!=(const Functor& rhs) const
- {
- return !(*this==rhs);
- }
+ bool operator==(const Functor& rhs) const
+ {
+ if(spImpl_.get()==0 && rhs.spImpl_.get()==0)
+ return true;
+ if(spImpl_.get()!=0 && rhs.spImpl_.get()!=0)
+ return *spImpl_.get() == *rhs.spImpl_.get();
+ else
+ return false;
+ }
+
+ bool operator!=(const Functor& rhs) const
+ {
+ return !(*this==rhs);
+ }
#endif
- // operator() implementations for up to 15 arguments
-
- ResultType operator()() const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)();
- }
-
- ResultType operator()(Parm1 p1) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5, p6);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
- p12);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
- p12, p13);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13, Parm14 p14) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
- p12, p13, p14);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15) const
- {
- LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
- return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
- p12, p13, p14, p15);
- }
-
- private:
- std::auto_ptr<Impl> spImpl_;
- };
-
-
-////////////////////////////////////////////////////////////////////////////////
-//
-// BindersFirst and Chainer
+ // operator() implementations for up to 15 arguments
+
+ ResultType operator()() const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)();
+ }
+
+ ResultType operator()(Parm1 p1) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5, p6);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
+ p12);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
+ p12, p13);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13, Parm14 p14) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
+ p12, p13, p14);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15) const
+ {
+ LOKI_FUNCTION_THROW_BAD_FUNCTION_CALL
+ return (*spImpl_)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
+ p12, p13, p14, p15);
+ }
+
+private:
+ std::auto_ptr<Impl> spImpl_;
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// BindersFirst and Chainer
//
////////////////////////////////////////////////////////////////////////////////
- namespace Private
- {
- template <class Fctor> struct BinderFirstTraits;
+namespace Private
+{
+template <class Fctor> struct BinderFirstTraits;
+
+template <typename R, class TList, template <class, class> class ThreadingModel>
+struct BinderFirstTraits< Functor<R, TList, ThreadingModel> >
+{
+ typedef Functor<R, TList, ThreadingModel> OriginalFunctor;
- template <typename R, class TList, template <class, class> class ThreadingModel>
- struct BinderFirstTraits< Functor<R, TList, ThreadingModel> >
- {
- typedef Functor<R, TList, ThreadingModel> OriginalFunctor;
+ typedef typename TL::Erase<TList,typename TL::TypeAt<TList, 0>::Result>
+ ::Result
+ ParmList;
- typedef typename TL::Erase<TList,typename TL::TypeAt<TList, 0>::Result>
- ::Result
- ParmList;
+ typedef typename TL::TypeAt<TList, 0>::Result OriginalParm1;
- typedef typename TL::TypeAt<TList, 0>::Result OriginalParm1;
+ typedef Functor<R, ParmList, ThreadingModel> BoundFunctorType;
- typedef Functor<R, ParmList, ThreadingModel> BoundFunctorType;
+ typedef typename BoundFunctorType::Impl Impl;
- typedef typename BoundFunctorType::Impl Impl;
+};
- };
+template<class T>
+struct BinderFirstBoundTypeStorage;
- template<class T>
- struct BinderFirstBoundTypeStorage;
+template<class T>
+struct BinderFirstBoundTypeStorage
+{
+ typedef typename TypeTraits<T>::ParameterType RefOrValue;
+};
- template<class T>
- struct BinderFirstBoundTypeStorage
- {
- typedef typename TypeTraits<T>::ParameterType RefOrValue;
- };
-
- template <typename R, class TList, template <class, class> class ThreadingModel>
- struct BinderFirstBoundTypeStorage< Functor<R, TList, ThreadingModel> >
- {
- typedef Functor<R, TList, ThreadingModel> OriginalFunctor;
- typedef const typename TypeTraits<OriginalFunctor>::ReferredType RefOrValue;
- };
+template <typename R, class TList, template <class, class> class ThreadingModel>
+struct BinderFirstBoundTypeStorage< Functor<R, TList, ThreadingModel> >
+{
+ typedef Functor<R, TList, ThreadingModel> OriginalFunctor;
+ typedef const typename TypeTraits<OriginalFunctor>::ReferredType RefOrValue;
+};
- } // namespace Private
+} // namespace Private
////////////////////////////////////////////////////////////////////////////////
/// \class BinderFirst
-///
+///
/// \ingroup FunctorGroup
/// Binds the first parameter of a Functor object to a specific value
////////////////////////////////////////////////////////////////////////////////
- template <class OriginalFunctor>
- class BinderFirst
- : public Private::BinderFirstTraits<OriginalFunctor>::Impl
- {
- typedef typename Private::BinderFirstTraits<OriginalFunctor>::Impl Base;
- typedef typename OriginalFunctor::ResultType ResultType;
-
- typedef typename OriginalFunctor::Parm1 BoundType;
-
- typedef typename Private::BinderFirstBoundTypeStorage<
- typename Private::BinderFirstTraits<OriginalFunctor>
- ::OriginalParm1>
- ::RefOrValue
- BoundTypeStorage;
-
- typedef typename OriginalFunctor::Parm2 Parm1;
- typedef typename OriginalFunctor::Parm3 Parm2;
- typedef typename OriginalFunctor::Parm4 Parm3;
- typedef typename OriginalFunctor::Parm5 Parm4;
- typedef typename OriginalFunctor::Parm6 Parm5;
- typedef typename OriginalFunctor::Parm7 Parm6;
- typedef typename OriginalFunctor::Parm8 Parm7;
- typedef typename OriginalFunctor::Parm9 Parm8;
- typedef typename OriginalFunctor::Parm10 Parm9;
- typedef typename OriginalFunctor::Parm11 Parm10;
- typedef typename OriginalFunctor::Parm12 Parm11;
- typedef typename OriginalFunctor::Parm13 Parm12;
- typedef typename OriginalFunctor::Parm14 Parm13;
- typedef typename OriginalFunctor::Parm15 Parm14;
- typedef EmptyType Parm15;
-
- public:
-
- BinderFirst(const OriginalFunctor& fun, BoundType bound)
+template <class OriginalFunctor>
+class BinderFirst
+ : public Private::BinderFirstTraits<OriginalFunctor>::Impl
+{
+ typedef typename Private::BinderFirstTraits<OriginalFunctor>::Impl Base;
+ typedef typename OriginalFunctor::ResultType ResultType;
+
+ typedef typename OriginalFunctor::Parm1 BoundType;
+
+ typedef typename Private::BinderFirstBoundTypeStorage<
+ typename Private::BinderFirstTraits<OriginalFunctor>
+ ::OriginalParm1>
+ ::RefOrValue
+ BoundTypeStorage;
+
+ typedef typename OriginalFunctor::Parm2 Parm1;
+ typedef typename OriginalFunctor::Parm3 Parm2;
+ typedef typename OriginalFunctor::Parm4 Parm3;
+ typedef typename OriginalFunctor::Parm5 Parm4;
+ typedef typename OriginalFunctor::Parm6 Parm5;
+ typedef typename OriginalFunctor::Parm7 Parm6;
+ typedef typename OriginalFunctor::Parm8 Parm7;
+ typedef typename OriginalFunctor::Parm9 Parm8;
+ typedef typename OriginalFunctor::Parm10 Parm9;
+ typedef typename OriginalFunctor::Parm11 Parm10;
+ typedef typename OriginalFunctor::Parm12 Parm11;
+ typedef typename OriginalFunctor::Parm13 Parm12;
+ typedef typename OriginalFunctor::Parm14 Parm13;
+ typedef typename OriginalFunctor::Parm15 Parm14;
+ typedef EmptyType Parm15;
+
+public:
+
+ BinderFirst(const OriginalFunctor& fun, BoundType bound)
: f_(fun), b_(bound)
- {}
+ {}
- LOKI_DEFINE_CLONE_FUNCTORIMPL(BinderFirst)
+ LOKI_DEFINE_CLONE_FUNCTORIMPL(BinderFirst)
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
-
- bool operator==(const typename Base::FunctorImplBaseType& rhs) const
- {
- if(typeid(*this) != typeid(rhs))
- return false; // cannot be equal
- // if this line gives a compiler error, you are using a function object.
- // you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
- return f_ == ((static_cast<const BinderFirst&> (rhs)).f_) &&
- b_ == ((static_cast<const BinderFirst&> (rhs)).b_);
- }
+
+ bool operator==(const typename Base::FunctorImplBaseType& rhs) const
+ {
+ if(typeid(*this) != typeid(rhs))
+ return false; // cannot be equal
+ // if this line gives a compiler error, you are using a function object.
+ // you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
+ return f_ == ((static_cast<const BinderFirst&> (rhs)).f_) &&
+ b_ == ((static_cast<const BinderFirst&> (rhs)).b_);
+ }
#endif
- // operator() implementations for up to 15 arguments
-
- ResultType operator()()
- { return f_(b_); }
-
- ResultType operator()(Parm1 p1)
- { return f_(b_, p1); }
-
- ResultType operator()(Parm1 p1, Parm2 p2)
- { return f_(b_, p1, p2); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
- { return f_(b_, p1, p2, p3); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
- { return f_(b_, p1, p2, p3, p4); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
- { return f_(b_, p1, p2, p3, p4, p5); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6)
- { return f_(b_, p1, p2, p3, p4, p5, p6); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7)
- { return f_(b_, p1, p2, p3, p4, p5, p6, p7); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8)
- { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
- { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
- { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
- { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12)
- { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13)
- { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13, Parm14 p14)
- {
- return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
- p14);
- }
-
- private:
- OriginalFunctor f_;
- BoundTypeStorage b_;
- };
-
+ // operator() implementations for up to 15 arguments
+
+ ResultType operator()()
+ { return f_(b_); }
+
+ ResultType operator()(Parm1 p1)
+ { return f_(b_, p1); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2)
+ { return f_(b_, p1, p2); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
+ { return f_(b_, p1, p2, p3); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
+ { return f_(b_, p1, p2, p3, p4); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
+ { return f_(b_, p1, p2, p3, p4, p5); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6)
+ { return f_(b_, p1, p2, p3, p4, p5, p6); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7)
+ { return f_(b_, p1, p2, p3, p4, p5, p6, p7); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8)
+ { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
+ { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
+ { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
+ { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12)
+ { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13)
+ { return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13, Parm14 p14)
+ {
+ return f_(b_, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
+ p14);
+ }
+
+private:
+ OriginalFunctor f_;
+ BoundTypeStorage b_;
+};
+
////////////////////////////////////////////////////////////////////////////////
/// Binds the first parameter of a Functor object to a specific value
/// \ingroup FunctorGroup
////////////////////////////////////////////////////////////////////////////////
- template <class Fctor>
- typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
- BindFirst(
- const Fctor& fun,
- typename Fctor::Parm1 bound)
- {
- typedef typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
- Outgoing;
-
- return Outgoing(std::auto_ptr<typename Outgoing::Impl>(
- new BinderFirst<Fctor>(fun, bound)));
- }
+template <class Fctor>
+typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
+BindFirst(
+ const Fctor& fun,
+ typename Fctor::Parm1 bound)
+{
+ typedef typename Private::BinderFirstTraits<Fctor>::BoundFunctorType
+ Outgoing;
+
+ return Outgoing(std::auto_ptr<typename Outgoing::Impl>(
+ new BinderFirst<Fctor>(fun, bound)));
+}
////////////////////////////////////////////////////////////////////////////////
/// \class Chainer
@@ -1627,160 +1628,160 @@ namespace Loki
/// Chains two functor calls one after another
////////////////////////////////////////////////////////////////////////////////
- template <typename Fun1, typename Fun2>
- class Chainer : public Fun2::Impl
- {
- typedef Fun2 Base;
-
- public:
- typedef typename Base::ResultType ResultType;
- typedef typename Base::Parm1 Parm1;
- typedef typename Base::Parm2 Parm2;
- typedef typename Base::Parm3 Parm3;
- typedef typename Base::Parm4 Parm4;
- typedef typename Base::Parm5 Parm5;
- typedef typename Base::Parm6 Parm6;
- typedef typename Base::Parm7 Parm7;
- typedef typename Base::Parm8 Parm8;
- typedef typename Base::Parm9 Parm9;
- typedef typename Base::Parm10 Parm10;
- typedef typename Base::Parm11 Parm11;
- typedef typename Base::Parm12 Parm12;
- typedef typename Base::Parm13 Parm13;
- typedef typename Base::Parm14 Parm14;
- typedef typename Base::Parm15 Parm15;
-
- Chainer(const Fun1& fun1, const Fun2& fun2) : f1_(fun1), f2_(fun2) {}
-
- LOKI_DEFINE_CLONE_FUNCTORIMPL(Chainer)
+template <typename Fun1, typename Fun2>
+class Chainer : public Fun2::Impl
+{
+ typedef Fun2 Base;
+
+public:
+ typedef typename Base::ResultType ResultType;
+ typedef typename Base::Parm1 Parm1;
+ typedef typename Base::Parm2 Parm2;
+ typedef typename Base::Parm3 Parm3;
+ typedef typename Base::Parm4 Parm4;
+ typedef typename Base::Parm5 Parm5;
+ typedef typename Base::Parm6 Parm6;
+ typedef typename Base::Parm7 Parm7;
+ typedef typename Base::Parm8 Parm8;
+ typedef typename Base::Parm9 Parm9;
+ typedef typename Base::Parm10 Parm10;
+ typedef typename Base::Parm11 Parm11;
+ typedef typename Base::Parm12 Parm12;
+ typedef typename Base::Parm13 Parm13;
+ typedef typename Base::Parm14 Parm14;
+ typedef typename Base::Parm15 Parm15;
+
+ Chainer(const Fun1& fun1, const Fun2& fun2) : f1_(fun1), f2_(fun2) {}
+
+ LOKI_DEFINE_CLONE_FUNCTORIMPL(Chainer)
#ifdef LOKI_FUNCTORS_ARE_COMPARABLE
-
- bool operator==(const typename Base::Impl::FunctorImplBaseType& rhs) const
- {
- if(typeid(*this) != typeid(rhs))
- return false; // cannot be equal
- // if this line gives a compiler error, you are using a function object.
- // you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
- return f1_ == ((static_cast<const Chainer&> (rhs)).f2_) &&
- f2_ == ((static_cast<const Chainer&> (rhs)).f1_);
- }
+
+ bool operator==(const typename Base::Impl::FunctorImplBaseType& rhs) const
+ {
+ if(typeid(*this) != typeid(rhs))
+ return false; // cannot be equal
+ // if this line gives a compiler error, you are using a function object.
+ // you need to implement bool MyFnObj::operator == (const MyFnObj&) const;
+ return f1_ == ((static_cast<const Chainer&> (rhs)).f2_) &&
+ f2_ == ((static_cast<const Chainer&> (rhs)).f1_);
+ }
#endif
- // operator() implementations for up to 15 arguments
-
- ResultType operator()()
- { return f1_(), f2_(); }
-
- ResultType operator()(Parm1 p1)
- { return f1_(p1), f2_(p1); }
-
- ResultType operator()(Parm1 p1, Parm2 p2)
- { return f1_(p1, p2), f2_(p1, p2); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
- { return f1_(p1, p2, p3), f2_(p1, p2, p3); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
- { return f1_(p1, p2, p3, p4), f2_(p1, p2, p3, p4); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
- { return f1_(p1, p2, p3, p4, p5), f2_(p1, p2, p3, p4, p5); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6)
- { return f1_(p1, p2, p3, p4, p5, p6), f2_(p1, p2, p3, p4, p5, p6); }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7)
- {
- return f1_(p1, p2, p3, p4, p5, p6, p7),
- f2_(p1, p2, p3, p4, p5, p6, p7);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8)
- {
- return f1_(p1, p2, p3, p4, p5, p6, p7, p8),
- f2_(p1, p2, p3, p4, p5, p6, p7, p8);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
- {
- return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9),
- f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
- {
- return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10),
- f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
- {
- return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11),
- f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12)
- {
- return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12),
- f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13)
- {
- return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13),
- f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13, Parm14 p14)
- {
- return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
- p14),
- f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
+ // operator() implementations for up to 15 arguments
+
+ ResultType operator()()
+ { return f1_(), f2_(); }
+
+ ResultType operator()(Parm1 p1)
+ { return f1_(p1), f2_(p1); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2)
+ { return f1_(p1, p2), f2_(p1, p2); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3)
+ { return f1_(p1, p2, p3), f2_(p1, p2, p3); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4)
+ { return f1_(p1, p2, p3, p4), f2_(p1, p2, p3, p4); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5)
+ { return f1_(p1, p2, p3, p4, p5), f2_(p1, p2, p3, p4, p5); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6)
+ { return f1_(p1, p2, p3, p4, p5, p6), f2_(p1, p2, p3, p4, p5, p6); }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7)
+ {
+ return f1_(p1, p2, p3, p4, p5, p6, p7),
+ f2_(p1, p2, p3, p4, p5, p6, p7);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8)
+ {
+ return f1_(p1, p2, p3, p4, p5, p6, p7, p8),
+ f2_(p1, p2, p3, p4, p5, p6, p7, p8);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9)
+ {
+ return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9),
+ f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10)
+ {
+ return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10),
+ f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11)
+ {
+ return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11),
+ f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12)
+ {
+ return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12),
+ f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13)
+ {
+ return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13),
+ f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13);
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13, Parm14 p14)
+ {
+ return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
+ p14),
+ f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
p14);
- }
-
- ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
- Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
- Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
- {
- return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
- p14, p15),
- f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
- p14, p15);
- }
-
- private:
- Fun1 f1_;
- Fun2 f2_;
- };
-
+ }
+
+ ResultType operator()(Parm1 p1, Parm2 p2, Parm3 p3, Parm4 p4, Parm5 p5,
+ Parm6 p6, Parm7 p7, Parm8 p8, Parm9 p9, Parm10 p10, Parm11 p11,
+ Parm12 p12, Parm13 p13, Parm14 p14, Parm15 p15)
+ {
+ return f1_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
+ p14, p15),
+ f2_(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13,
+ p14, p15);
+ }
+
+private:
+ Fun1 f1_;
+ Fun2 f2_;
+};
+
////////////////////////////////////////////////////////////////////////////////
/// Chains two functor calls one after another
/// \ingroup FunctorGroup
////////////////////////////////////////////////////////////////////////////////
- template <class Fun1, class Fun2>
- Fun2 Chain(
- const Fun1& fun1,
- const Fun2& fun2)
- {
- return Fun2(std::auto_ptr<typename Fun2::Impl>(
- new Chainer<Fun1, Fun2>(fun1, fun2)));
- }
+template <class Fun1, class Fun2>
+Fun2 Chain(
+ const Fun1& fun1,
+ const Fun2& fun2)
+{
+ return Fun2(std::auto_ptr<typename Fun2::Impl>(
+ new Chainer<Fun1, Fun2>(fun1, fun2)));
+}
} // namespace Loki
diff --git a/shared/loki/HierarchyGenerators.h b/shared/loki/HierarchyGenerators.h
index 3fa11ffc..83ec194c 100644
--- a/shared/loki/HierarchyGenerators.h
+++ b/shared/loki/HierarchyGenerators.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_HIERARCHYGENERATORS_INC_
@@ -25,8 +25,8 @@
namespace Loki
{
#if defined(_MSC_VER) && _MSC_VER >= 1300
-#pragma warning( push )
- // 'class1' : base-class 'class2' is already a base-class of 'class3'
+#pragma warning( push )
+// 'class1' : base-class 'class2' is already a base-class of 'class3'
#pragma warning( disable : 4584 )
#endif // _MSC_VER
@@ -35,180 +35,180 @@ namespace Loki
// Generates a scattered hierarchy starting from a typelist and a template
// Invocation (TList is a typelist, Unit is a template of one arg):
// GenScatterHierarchy<TList, Unit>
-// The generated class inherits all classes generated by instantiating the
-// template 'Unit' with the types contained in TList
+// The generated class inherits all classes generated by instantiating the
+// template 'Unit' with the types contained in TList
////////////////////////////////////////////////////////////////////////////////
- namespace Private
- {
- // The following type helps to overcome subtle flaw in the original
- // implementation of GenScatterHierarchy.
- // The flaw is revealed when the input type list of GenScatterHierarchy
- // contains more then one element of the same type (e.g. LOKI_TYPELIST_2(int, int)).
- // In this case GenScatterHierarchy will contain multiple bases of the same
- // type and some of them will not be reachable (per 10.3).
- // For example before the fix the first element of Tuple<LOKI_TYPELIST_2(int, int)>
- // is not reachable in any way!
- template<class, class>
- struct ScatterHierarchyTag;
- }
+namespace Private
+{
+// The following type helps to overcome subtle flaw in the original
+// implementation of GenScatterHierarchy.
+// The flaw is revealed when the input type list of GenScatterHierarchy
+// contains more then one element of the same type (e.g. LOKI_TYPELIST_2(int, int)).
+// In this case GenScatterHierarchy will contain multiple bases of the same
+// type and some of them will not be reachable (per 10.3).
+// For example before the fix the first element of Tuple<LOKI_TYPELIST_2(int, int)>
+// is not reachable in any way!
+template<class, class>
+struct ScatterHierarchyTag;
+}
- template <class TList, template <class> class Unit>
- class GenScatterHierarchy;
-
- template <class T1, class T2, template <class> class Unit>
- class GenScatterHierarchy<Typelist<T1, T2>, Unit>
- : public GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit>
- , public GenScatterHierarchy<T2, Unit>
- {
- public:
- typedef Typelist<T1, T2> TList;
- // Insure that LeftBase is unique and therefore reachable
- typedef GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit> LeftBase;
- typedef GenScatterHierarchy<T2, Unit> RightBase;
- template <typename T> struct Rebind
- {
- typedef Unit<T> Result;
- };
- };
-
- // In the middle *unique* class that resolve possible ambiguity
- template <class T1, class T2, template <class> class Unit>
- class GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit>
- : public GenScatterHierarchy<T1, Unit>
+template <class TList, template <class> class Unit>
+class GenScatterHierarchy;
+
+template <class T1, class T2, template <class> class Unit>
+class GenScatterHierarchy<Typelist<T1, T2>, Unit>
+ : public GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit>
+ , public GenScatterHierarchy<T2, Unit>
+{
+public:
+ typedef Typelist<T1, T2> TList;
+ // Insure that LeftBase is unique and therefore reachable
+ typedef GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit> LeftBase;
+ typedef GenScatterHierarchy<T2, Unit> RightBase;
+ template <typename T> struct Rebind
{
+ typedef Unit<T> Result;
};
+};
+
+// In the middle *unique* class that resolve possible ambiguity
+template <class T1, class T2, template <class> class Unit>
+class GenScatterHierarchy<Private::ScatterHierarchyTag<T1, T2>, Unit>
+ : public GenScatterHierarchy<T1, Unit>
+{
+};
- template <class AtomicType, template <class> class Unit>
- class GenScatterHierarchy : public Unit<AtomicType>
+template <class AtomicType, template <class> class Unit>
+class GenScatterHierarchy : public Unit<AtomicType>
+{
+ typedef Unit<AtomicType> LeftBase;
+ template <typename T> struct Rebind
{
- typedef Unit<AtomicType> LeftBase;
- template <typename T> struct Rebind
- {
- typedef Unit<T> Result;
- };
+ typedef Unit<T> Result;
};
-
- template <template <class> class Unit>
- class GenScatterHierarchy<NullType, Unit>
+};
+
+template <template <class> class Unit>
+class GenScatterHierarchy<NullType, Unit>
+{
+ template <typename T> struct Rebind
{
- template <typename T> struct Rebind
- {
- typedef Unit<T> Result;
- };
+ typedef Unit<T> Result;
};
-
+};
+
////////////////////////////////////////////////////////////////////////////////
// function template Field
// Accesses a field in an object of a type generated with GenScatterHierarchy
// Invocation (obj is an object of a type H generated with GenScatterHierarchy,
// T is a type in the typelist used to generate H):
// Field<T>(obj)
-// returns a reference to Unit<T>, where Unit is the template used to generate H
+// returns a reference to Unit<T>, where Unit is the template used to generate H
////////////////////////////////////////////////////////////////////////////////
- template <class T, class H>
- typename H::template Rebind<T>::Result& Field(H& obj)
- {
- return obj;
- }
-
- template <class T, class H>
- const typename H::template Rebind<T>::Result& Field(const H& obj)
- {
- return obj;
- }
-
+template <class T, class H>
+typename H::template Rebind<T>::Result& Field(H& obj)
+{
+ return obj;
+}
+
+template <class T, class H>
+const typename H::template Rebind<T>::Result& Field(const H& obj)
+{
+ return obj;
+}
+
////////////////////////////////////////////////////////////////////////////////
// function template TupleUnit
-// The building block of tuples
+// The building block of tuples
////////////////////////////////////////////////////////////////////////////////
- template <class T>
- struct TupleUnit
- {
- T value_;
- operator T&() { return value_; }
- operator const T&() const { return value_; }
- };
+template <class T>
+struct TupleUnit
+{
+ T value_;
+ operator T& () { return value_; }
+ operator const T& () const { return value_; }
+};
////////////////////////////////////////////////////////////////////////////////
// class template Tuple
-// Implements a tuple class that holds a number of values and provides field
-// access to them via the Field function (below)
+// Implements a tuple class that holds a number of values and provides field
+// access to them via the Field function (below)
////////////////////////////////////////////////////////////////////////////////
- template <class TList>
- struct Tuple : public GenScatterHierarchy<TList, TupleUnit>
- {
- };
+template <class TList>
+struct Tuple : public GenScatterHierarchy<TList, TupleUnit>
+{
+};
////////////////////////////////////////////////////////////////////////////////
// helper class template FieldHelper
// See Field below
////////////////////////////////////////////////////////////////////////////////
- template <class H, unsigned int i> struct FieldHelper;
-
- template <class H>
- struct FieldHelper<H, 0>
+template <class H, unsigned int i> struct FieldHelper;
+
+template <class H>
+struct FieldHelper<H, 0>
+{
+ typedef typename H::TList::Head ElementType;
+ typedef typename H::template Rebind<ElementType>::Result UnitType;
+
+ enum
{
- typedef typename H::TList::Head ElementType;
- typedef typename H::template Rebind<ElementType>::Result UnitType;
-
- enum
- {
- isTuple = Conversion<UnitType, TupleUnit<ElementType> >::sameType,
- isConst = TypeTraits<H>::isConst
- };
-
- typedef const typename H::LeftBase ConstLeftBase;
-
- typedef typename Select<isConst, ConstLeftBase,
+ isTuple = Conversion<UnitType, TupleUnit<ElementType> >::sameType,
+ isConst = TypeTraits<H>::isConst
+ };
+
+ typedef const typename H::LeftBase ConstLeftBase;
+
+ typedef typename Select<isConst, ConstLeftBase,
typename H::LeftBase>::Result LeftBase;
-
- typedef typename Select<isTuple, ElementType,
+
+ typedef typename Select<isTuple, ElementType,
UnitType>::Result UnqualifiedResultType;
- typedef typename Select<isConst, const UnqualifiedResultType,
- UnqualifiedResultType>::Result ResultType;
-
- static ResultType& Do(H& obj)
- {
- LeftBase& leftBase = obj;
- return leftBase;
- }
- };
+ typedef typename Select<isConst, const UnqualifiedResultType,
+ UnqualifiedResultType>::Result ResultType;
+
+ static ResultType& Do(H& obj)
+ {
+ LeftBase& leftBase = obj;
+ return leftBase;
+ }
+};
+
+template <class H, unsigned int i>
+struct FieldHelper
+{
+ typedef typename TL::TypeAt<typename H::TList, i>::Result ElementType;
+ typedef typename H::template Rebind<ElementType>::Result UnitType;
- template <class H, unsigned int i>
- struct FieldHelper
+ enum
{
- typedef typename TL::TypeAt<typename H::TList, i>::Result ElementType;
- typedef typename H::template Rebind<ElementType>::Result UnitType;
-
- enum
- {
- isTuple = Conversion<UnitType, TupleUnit<ElementType> >::sameType,
- isConst = TypeTraits<H>::isConst
- };
-
- typedef const typename H::RightBase ConstRightBase;
-
- typedef typename Select<isConst, ConstRightBase,
+ isTuple = Conversion<UnitType, TupleUnit<ElementType> >::sameType,
+ isConst = TypeTraits<H>::isConst
+ };
+
+ typedef const typename H::RightBase ConstRightBase;
+
+ typedef typename Select<isConst, ConstRightBase,
typename H::RightBase>::Result RightBase;
- typedef typename Select<isTuple, ElementType,
+ typedef typename Select<isTuple, ElementType,
UnitType>::Result UnqualifiedResultType;
- typedef typename Select<isConst, const UnqualifiedResultType,
- UnqualifiedResultType>::Result ResultType;
-
- static ResultType& Do(H& obj)
- {
- RightBase& rightBase = obj;
- return FieldHelper<RightBase, i - 1>::Do(rightBase);
- }
- };
+ typedef typename Select<isConst, const UnqualifiedResultType,
+ UnqualifiedResultType>::Result ResultType;
+
+ static ResultType& Do(H& obj)
+ {
+ RightBase& rightBase = obj;
+ return FieldHelper<RightBase, i - 1>::Do(rightBase);
+ }
+};
////////////////////////////////////////////////////////////////////////////////
// function template Field
@@ -217,23 +217,23 @@ namespace Loki
// i is the index of a type in the typelist used to generate H):
// Field<i>(obj)
// returns a reference to Unit<T>, where Unit is the template used to generate H
-// and T is the i-th type in the typelist
+// and T is the i-th type in the typelist
////////////////////////////////////////////////////////////////////////////////
- template <int i, class H>
- typename FieldHelper<H, i>::ResultType&
- Field(H& obj)
- {
- return FieldHelper<H, i>::Do(obj);
- }
-
+template <int i, class H>
+typename FieldHelper<H, i>::ResultType&
+Field(H& obj)
+{
+ return FieldHelper<H, i>::Do(obj);
+}
+
// template <int i, class H>
// const typename FieldHelper<H, i>::ResultType&
// Field(const H& obj)
// {
// return FieldHelper<H, i>::Do(obj);
// }
-
+
////////////////////////////////////////////////////////////////////////////////
// class template GenLinearHierarchy
// Generates a linear hierarchy starting from a typelist and a template
@@ -241,49 +241,49 @@ namespace Loki
// GenScatterHierarchy<TList, Unit>
////////////////////////////////////////////////////////////////////////////////
- template
- <
- class TList,
- template <class AtomicType, class Base> class Unit,
- class Root = EmptyType
- >
- class GenLinearHierarchy;
-
- template
- <
- class T1,
- class T2,
- template <class, class> class Unit,
- class Root
- >
- class GenLinearHierarchy<Typelist<T1, T2>, Unit, Root>
- : public Unit< T1, GenLinearHierarchy<T2, Unit, Root> >
- {
- };
+template
+<
+class TList,
+ template <class AtomicType, class Base> class Unit,
+ class Root = EmptyType
+ >
+class GenLinearHierarchy;
- template
- <
- class T,
- template <class, class> class Unit,
- class Root
- >
- class GenLinearHierarchy<Typelist<T, NullType>, Unit, Root>
- : public Unit<T, Root>
- {
- };
+template
+<
+class T1,
+ class T2,
+ template <class, class> class Unit,
+ class Root
+ >
+class GenLinearHierarchy<Typelist<T1, T2>, Unit, Root>
+ : public Unit< T1, GenLinearHierarchy<T2, Unit, Root> >
+{
+};
- template
- <
- template <class, class> class Unit,
- class Root
- >
- class GenLinearHierarchy<NullType , Unit, Root>
- : public Root // is this better: Unit<NullType, Root> ?
- {
- };
+template
+<
+class T,
+ template <class, class> class Unit,
+ class Root
+ >
+class GenLinearHierarchy<Typelist<T, NullType>, Unit, Root>
+ : public Unit<T, Root>
+{
+};
+
+template
+<
+template <class, class> class Unit,
+ class Root
+ >
+class GenLinearHierarchy<NullType , Unit, Root>
+ : public Root // is this better: Unit<NullType, Root> ?
+{
+};
#if defined(_MSC_VER) && _MSC_VER >= 1300
-#pragma warning( pop )
+#pragma warning( pop )
#endif
} // namespace Loki
diff --git a/shared/loki/Key.h b/shared/loki/Key.h
index 4daaa603..c80d6f4e 100644
--- a/shared/loki/Key.h
+++ b/shared/loki/Key.h
@@ -4,16 +4,16 @@
//
// Code covered by the MIT License
//
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
//
// The authors make no representations about the suitability of this software
// for any purpose. It is provided "as is" without express or implied warranty.
//
// This code DOES NOT accompany the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
//
////////////////////////////////////////////////////////////////////////////////
@@ -28,735 +28,737 @@
namespace Loki
{
- template<
- class Factory,
- typename IdentifierType
- >
- class Key;
+template<
+class Factory,
+ typename IdentifierType
+ >
+class Key;
- template<class F, typename I>
- bool operator==(const Key<F, I> &k1, const Key<F, I> &k2);
+template<class F, typename I>
+bool operator==(const Key<F, I> &k1, const Key<F, I> &k2);
+
+template<class F, typename I>
+bool operator<(const Key<F, I> &k1, const Key<F, I> &k2);
+
+
+/**
+ * A Key class
+ */
+template<
+class Factory,
+ typename IdentifierType
+ >
+class Key
+{
+ typedef typename Factory::Parm1 Parm1;
+ typedef typename Factory::Parm2 Parm2;
+ typedef typename Factory::Parm3 Parm3;
+ typedef typename Factory::Parm4 Parm4;
+ typedef typename Factory::Parm5 Parm5;
+ typedef typename Factory::Parm6 Parm6;
+ typedef typename Factory::Parm7 Parm7;
+ typedef typename Factory::Parm8 Parm8;
+ typedef typename Factory::Parm9 Parm9;
+ typedef typename Factory::Parm10 Parm10;
+ typedef typename Factory::Parm11 Parm11;
+ typedef typename Factory::Parm12 Parm12;
+ typedef typename Factory::Parm13 Parm13;
+ typedef typename Factory::Parm14 Parm14;
+ typedef typename Factory::Parm15 Parm15;
+public:
+ // member variables
+ int count; // should be const, but constness prevent default copy ctor
+ IdentifierType id;
+ Parm1 p1;
+ Parm2 p2;
+ Parm3 p3;
+ Parm4 p4;
+ Parm5 p5;
+ Parm6 p6;
+ Parm7 p7;
+ Parm8 p8;
+ Parm9 p9;
+ Parm10 p10;
+ Parm11 p11;
+ Parm12 p12;
+ Parm13 p13;
+ Parm14 p14;
+ Parm15 p15;
+
+ // member functions
+ Key() : count(-1)
+ {
+ }
+
+ Key(const IdentifierType& id) : count(0)
+ {
+ this->id = id;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1) : count(1)
+ {
+ this->id = id;
+ this->p1 = p1;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2) : count(2)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3) : count(3)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4) : count(4)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5) : count(5)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5,
+ Parm6& p6) : count(6)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ this->p6 = p6;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5,
+ Parm6& p6, Parm7& p7 ) : count(7)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ this->p6 = p6;
+ this->p7 = p7;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5,
+ Parm6& p6, Parm7& p7, Parm8& p8) : count(8)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ this->p6 = p6;
+ this->p7 = p7;
+ this->p8 = p8;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5,
+ Parm6& p6, Parm7& p7, Parm8& p8, Parm9& p9) : count(9)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ this->p6 = p6;
+ this->p7 = p7;
+ this->p8 = p8;
+ this->p9 = p9;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5,
+ Parm6& p6, Parm7& p7, Parm8& p8, Parm9& p9,Parm10& p10) : count(10)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ this->p6 = p6;
+ this->p7 = p7;
+ this->p8 = p8;
+ this->p9 = p9;
+ this->p10 = p10;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5,
+ Parm6& p6, Parm7& p7, Parm8& p8, Parm9& p9, Parm10& p10,
+ Parm11& p11) : count(11)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ this->p6 = p6;
+ this->p7 = p7;
+ this->p8 = p8;
+ this->p9 = p9;
+ this->p10 = p10;
+ this->p11 = p11;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5,
+ Parm6& p6, Parm7& p7, Parm8& p8, Parm9& p9, Parm10& p10,
+ Parm11& p11, Parm12& p12) : count(12)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ this->p6 = p6;
+ this->p7 = p7;
+ this->p8 = p8;
+ this->p9 = p9;
+ this->p10 = p10;
+ this->p11 = p11;
+ this->p12 = p12;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5,
+ Parm6& p6, Parm7& p7, Parm8& p8, Parm9& p9, Parm10& p10,
+ Parm11& p11, Parm12& p12, Parm13& p13) : count(13)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ this->p6 = p6;
+ this->p7 = p7;
+ this->p8 = p8;
+ this->p9 = p9;
+ this->p10 = p10;
+ this->p11 = p11;
+ this->p12 = p12;
+ this->p13 = p13;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5,
+ Parm6& p6, Parm7& p7, Parm8& p8, Parm9& p9, Parm10& p10,
+ Parm11& p11, Parm12& p12, Parm13& p13, Parm14& p14) : count(14)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ this->p6 = p6;
+ this->p7 = p7;
+ this->p8 = p8;
+ this->p9 = p9;
+ this->p10 = p10;
+ this->p11 = p11;
+ this->p12 = p12;
+ this->p13 = p13;
+ this->p14 = p14;
+ }
+
+ Key(const IdentifierType& id,
+ Parm1& p1, Parm2& p2, Parm3& p3, Parm4& p4, Parm5& p5,
+ Parm6& p6, Parm7& p7, Parm8& p8, Parm9& p9, Parm10& p10,
+ Parm11& p11, Parm12& p12, Parm13& p13, Parm14& p14, Parm15& p15) : count(15)
+ {
+ this->id = id;
+ this->p1 = p1;
+ this->p2 = p2;
+ this->p3 = p3;
+ this->p4 = p4;
+ this->p5 = p5;
+ this->p6 = p6;
+ this->p7 = p7;
+ this->p8 = p8;
+ this->p9 = p9;
+ this->p10 = p10;
+ this->p11 = p11;
+ this->p12 = p12;
+ this->p13 = p13;
+ this->p14 = p14;
+ this->p15 = p15;
+ }
template<class F, typename I>
- bool operator<(const Key<F, I> &k1, const Key<F, I> &k2);
-
-
- /**
- * A Key class
- */
- template<
- class Factory,
- typename IdentifierType
- >
- class Key
- {
- typedef typename Factory::Parm1 Parm1;
- typedef typename Factory::Parm2 Parm2;
- typedef typename Factory::Parm3 Parm3;
- typedef typename Factory::Parm4 Parm4;
- typedef typename Factory::Parm5 Parm5;
- typedef typename Factory::Parm6 Parm6;
- typedef typename Factory::Parm7 Parm7;
- typedef typename Factory::Parm8 Parm8;
- typedef typename Factory::Parm9 Parm9;
- typedef typename Factory::Parm10 Parm10;
- typedef typename Factory::Parm11 Parm11;
- typedef typename Factory::Parm12 Parm12;
- typedef typename Factory::Parm13 Parm13;
- typedef typename Factory::Parm14 Parm14;
- typedef typename Factory::Parm15 Parm15;
- public:
- // member variables
- int count; // should be const, but constness prevent default copy ctor
- IdentifierType id;
- Parm1 p1;
- Parm2 p2;
- Parm3 p3;
- Parm4 p4;
- Parm5 p5;
- Parm6 p6;
- Parm7 p7;
- Parm8 p8;
- Parm9 p9;
- Parm10 p10;
- Parm11 p11;
- Parm12 p12;
- Parm13 p13;
- Parm14 p14;
- Parm15 p15;
-
- // member functions
- Key() : count(-1)
- {
- }
-
- Key(const IdentifierType& id) : count(0)
- {
- this->id = id;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1) : count(1)
- {
- this->id = id;
- this->p1 = p1;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2) : count(2)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3) : count(3)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4) : count(4)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5) : count(5)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
- Parm6 &p6) : count(6)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- this->p6 = p6;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
- Parm6 &p6, Parm7 &p7 ) : count(7)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- this->p6 = p6;
- this->p7 = p7;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
- Parm6 &p6, Parm7 &p7, Parm8 &p8) : count(8)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- this->p6 = p6;
- this->p7 = p7;
- this->p8 = p8;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
- Parm6 &p6, Parm7 &p7, Parm8 &p8, Parm9 &p9) : count(9)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- this->p6 = p6;
- this->p7 = p7;
- this->p8 = p8;
- this->p9 = p9;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
- Parm6 &p6, Parm7 &p7, Parm8 &p8, Parm9 &p9,Parm10 &p10) : count(10)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- this->p6 = p6;
- this->p7 = p7;
- this->p8 = p8;
- this->p9 = p9;
- this->p10 = p10;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
- Parm6 &p6, Parm7 &p7, Parm8 &p8, Parm9 &p9, Parm10 &p10,
- Parm11 &p11) : count(11)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- this->p6 = p6;
- this->p7 = p7;
- this->p8 = p8;
- this->p9 = p9;
- this->p10 = p10;
- this->p11 = p11;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
- Parm6 &p6, Parm7 &p7, Parm8 &p8, Parm9 &p9, Parm10 &p10,
- Parm11 &p11, Parm12 &p12) : count(12)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- this->p6 = p6;
- this->p7 = p7;
- this->p8 = p8;
- this->p9 = p9;
- this->p10 = p10;
- this->p11 = p11;
- this->p12 = p12;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
- Parm6 &p6, Parm7 &p7, Parm8 &p8, Parm9 &p9, Parm10 &p10,
- Parm11 &p11, Parm12 &p12, Parm13 &p13) : count(13)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- this->p6 = p6;
- this->p7 = p7;
- this->p8 = p8;
- this->p9 = p9;
- this->p10 = p10;
- this->p11 = p11;
- this->p12 = p12;
- this->p13 = p13;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
- Parm6 &p6, Parm7 &p7, Parm8 &p8, Parm9 &p9, Parm10 &p10,
- Parm11 &p11, Parm12 &p12, Parm13 &p13, Parm14 &p14) : count(14)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- this->p6 = p6;
- this->p7 = p7;
- this->p8 = p8;
- this->p9 = p9;
- this->p10 = p10;
- this->p11 = p11;
- this->p12 = p12;
- this->p13 = p13;
- this->p14 = p14;
- }
-
- Key(const IdentifierType& id,
- Parm1 &p1, Parm2 &p2, Parm3 &p3, Parm4 &p4, Parm5 &p5,
- Parm6 &p6, Parm7 &p7, Parm8 &p8, Parm9 &p9, Parm10 &p10,
- Parm11 &p11, Parm12 &p12, Parm13 &p13, Parm14 &p14, Parm15 &p15) : count(15)
- {
- this->id = id;
- this->p1 = p1;
- this->p2 = p2;
- this->p3 = p3;
- this->p4 = p4;
- this->p5 = p5;
- this->p6 = p6;
- this->p7 = p7;
- this->p8 = p8;
- this->p9 = p9;
- this->p10 = p10;
- this->p11 = p11;
- this->p12 = p12;
- this->p13 = p13;
- this->p14 = p14;
- this->p15 = p15;
- }
-
- template<class F, typename I>
- friend bool operator==(const Key<F, I> &k1, const Key<F, I> &k2);
-
- template<class F, typename I>
- friend bool operator<(const Key<F, I> &k1, const Key<F, I> &k2);
- };
-
-
+ friend bool operator==(const Key<F, I> &k1, const Key<F, I> &k2);
+
template<class F, typename I>
- bool operator==(const Key<F, I> &k1, const Key<F, I> &k2)
+ friend bool operator<(const Key<F, I> &k1, const Key<F, I> &k2);
+};
+
+
+template<class F, typename I>
+bool operator==(const Key<F, I> &k1, const Key<F, I> &k2)
+{
+ if( k1.count != k2.count )
+ return false;
+ switch(k1.count)
{
- if( k1.count != k2.count )
+ case -1:
+ return true;
+ case 0:
+ if( k1.id == k2.id )
+ return true;
+ else
+ return false;
+ case 1:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) )
+ return true;
+ else
+ return false;
+ case 2:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) )
+ return true;
+ else
+ return false;
+ case 3:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) )
+ return true;
+ else
+ return false;
+ case 4:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) )
+ return true;
+ else
+ return false;
+ case 5:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) )
+ return true;
+ else
+ return false;
+ case 6:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) &&
+ (k1.p6 == k2.p6) )
+ return true;
+ else
+ return false;
+ case 7:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) &&
+ (k1.p6 == k2.p6) &&
+ (k1.p7 == k2.p7) )
+ return true;
+ else
+ return false;
+ case 8:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) &&
+ (k1.p6 == k2.p6) &&
+ (k1.p7 == k2.p7) &&
+ (k1.p8 == k2.p8) )
+ return true;
+ else
+ return false;
+ case 9:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) &&
+ (k1.p6 == k2.p6) &&
+ (k1.p7 == k2.p7) &&
+ (k1.p8 == k2.p8) &&
+ (k1.p9 == k2.p9) )
+ return true;
+ else
+ return false;
+ case 10:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) &&
+ (k1.p6 == k2.p6) &&
+ (k1.p7 == k2.p7) &&
+ (k1.p8 == k2.p8) &&
+ (k1.p9 == k2.p9) &&
+ (k1.p10 == k2.p10) )
+ return true;
+ else
+ return false;
+ case 11:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) &&
+ (k1.p6 == k2.p6) &&
+ (k1.p7 == k2.p7) &&
+ (k1.p8 == k2.p8) &&
+ (k1.p9 == k2.p9) &&
+ (k1.p10 == k2.p10) &&
+ (k1.p11 == k2.p11) )
+ return true;
+ else
+ return false;
+ case 12:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) &&
+ (k1.p6 == k2.p6) &&
+ (k1.p7 == k2.p7) &&
+ (k1.p8 == k2.p8) &&
+ (k1.p9 == k2.p9) &&
+ (k1.p10 == k2.p10) &&
+ (k1.p11 == k2.p11) &&
+ (k1.p12 == k2.p12) )
+ return true;
+ else
+ return false;
+ case 13:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) &&
+ (k1.p6 == k2.p6) &&
+ (k1.p7 == k2.p7) &&
+ (k1.p8 == k2.p8) &&
+ (k1.p9 == k2.p9) &&
+ (k1.p10 == k2.p10) &&
+ (k1.p11 == k2.p11) &&
+ (k1.p12 == k2.p12) &&
+ (k1.p13 == k2.p13) )
+ return true;
+ else
+ return false;
+ case 14:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) &&
+ (k1.p6 == k2.p6) &&
+ (k1.p7 == k2.p7) &&
+ (k1.p8 == k2.p8) &&
+ (k1.p9 == k2.p9) &&
+ (k1.p10 == k2.p10) &&
+ (k1.p11 == k2.p11) &&
+ (k1.p12 == k2.p12) &&
+ (k1.p13 == k2.p13) &&
+ (k1.p14 == k2.p14) )
+ return true;
+ else
+ return false;
+ case 15:
+ if( (k1.id == k2.id) &&
+ (k1.p1 == k2.p1) &&
+ (k1.p2 == k2.p2) &&
+ (k1.p3 == k2.p3) &&
+ (k1.p4 == k2.p4) &&
+ (k1.p5 == k2.p5) &&
+ (k1.p6 == k2.p6) &&
+ (k1.p7 == k2.p7) &&
+ (k1.p8 == k2.p8) &&
+ (k1.p9 == k2.p9) &&
+ (k1.p10 == k2.p10) &&
+ (k1.p11 == k2.p11) &&
+ (k1.p12 == k2.p12) &&
+ (k1.p13 == k2.p13) &&
+ (k1.p14 == k2.p14) &&
+ (k1.p15 == k2.p15) )
+ return true;
+ else
+ return false;
+ default:
return false;
- switch(k1.count){
- case -1:
- return true;
- case 0:
- if( k1.id == k2.id )
- return true;
- else
- return false;
- case 1:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) )
- return true;
- else
- return false;
- case 2:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) )
- return true;
- else
- return false;
- case 3:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) )
- return true;
- else
- return false;
- case 4:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) )
- return true;
- else
- return false;
- case 5:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) )
- return true;
- else
- return false;
- case 6:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) &&
- (k1.p6 == k2.p6) )
- return true;
- else
- return false;
- case 7:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) &&
- (k1.p6 == k2.p6) &&
- (k1.p7 == k2.p7) )
- return true;
- else
- return false;
- case 8:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) &&
- (k1.p6 == k2.p6) &&
- (k1.p7 == k2.p7) &&
- (k1.p8 == k2.p8) )
- return true;
- else
- return false;
- case 9:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) &&
- (k1.p6 == k2.p6) &&
- (k1.p7 == k2.p7) &&
- (k1.p8 == k2.p8) &&
- (k1.p9 == k2.p9) )
- return true;
- else
- return false;
- case 10:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) &&
- (k1.p6 == k2.p6) &&
- (k1.p7 == k2.p7) &&
- (k1.p8 == k2.p8) &&
- (k1.p9 == k2.p9) &&
- (k1.p10 == k2.p10) )
- return true;
- else
- return false;
- case 11:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) &&
- (k1.p6 == k2.p6) &&
- (k1.p7 == k2.p7) &&
- (k1.p8 == k2.p8) &&
- (k1.p9 == k2.p9) &&
- (k1.p10 == k2.p10) &&
- (k1.p11 == k2.p11) )
- return true;
- else
- return false;
- case 12:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) &&
- (k1.p6 == k2.p6) &&
- (k1.p7 == k2.p7) &&
- (k1.p8 == k2.p8) &&
- (k1.p9 == k2.p9) &&
- (k1.p10 == k2.p10) &&
- (k1.p11 == k2.p11) &&
- (k1.p12 == k2.p12) )
- return true;
- else
- return false;
- case 13:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) &&
- (k1.p6 == k2.p6) &&
- (k1.p7 == k2.p7) &&
- (k1.p8 == k2.p8) &&
- (k1.p9 == k2.p9) &&
- (k1.p10 == k2.p10) &&
- (k1.p11 == k2.p11) &&
- (k1.p12 == k2.p12) &&
- (k1.p13 == k2.p13) )
- return true;
- else
- return false;
- case 14:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) &&
- (k1.p6 == k2.p6) &&
- (k1.p7 == k2.p7) &&
- (k1.p8 == k2.p8) &&
- (k1.p9 == k2.p9) &&
- (k1.p10 == k2.p10) &&
- (k1.p11 == k2.p11) &&
- (k1.p12 == k2.p12) &&
- (k1.p13 == k2.p13) &&
- (k1.p14 == k2.p14) )
- return true;
- else
- return false;
- case 15:
- if( (k1.id == k2.id) &&
- (k1.p1 == k2.p1) &&
- (k1.p2 == k2.p2) &&
- (k1.p3 == k2.p3) &&
- (k1.p4 == k2.p4) &&
- (k1.p5 == k2.p5) &&
- (k1.p6 == k2.p6) &&
- (k1.p7 == k2.p7) &&
- (k1.p8 == k2.p8) &&
- (k1.p9 == k2.p9) &&
- (k1.p10 == k2.p10) &&
- (k1.p11 == k2.p11) &&
- (k1.p12 == k2.p12) &&
- (k1.p13 == k2.p13) &&
- (k1.p14 == k2.p14) &&
- (k1.p15 == k2.p15) )
- return true;
- else
- return false;
- default:
- return false;
- }
}
+}
- template<class F, typename I>
- bool operator<(const Key<F, I> &k1, const Key<F, I> &k2)
+template<class F, typename I>
+bool operator<(const Key<F, I> &k1, const Key<F, I> &k2)
+{
+ if( k1.count < k2.count )
+ return true;
+ switch(k1.count)
{
- if( k1.count < k2.count )
- return true;
- switch(k1.count){
- case -1:
- return false;
- case 0:
- if( k1.id < k2.id )
- return true;
- else
- return false;
- case 1:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) )
- return true;
- else
- return false;
- case 2:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) )
- return true;
- else
- return false;
- case 3:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) )
- return true;
- else
- return false;
- case 4:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) )
- return true;
- else
- return false;
- case 5:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) )
- return true;
- else
- return false;
- case 6:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) ||
- (k1.p6 < k2.p6) )
- return true;
- else
- return false;
- case 7:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) ||
- (k1.p6 < k2.p6) ||
- (k1.p7 < k2.p7) )
- return true;
- else
- return false;
- case 8:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) ||
- (k1.p6 < k2.p6) ||
- (k1.p7 < k2.p7) ||
- (k1.p8 < k2.p8) )
- return true;
- else
- return false;
- case 9:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) ||
- (k1.p6 < k2.p6) ||
- (k1.p7 < k2.p7) ||
- (k1.p8 < k2.p8) ||
- (k1.p9 < k2.p9) )
- return true;
- else
- return false;
- case 10:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) ||
- (k1.p6 < k2.p6) ||
- (k1.p7 < k2.p7) ||
- (k1.p8 < k2.p8) ||
- (k1.p9 < k2.p9) ||
- (k1.p10 < k2.p10) )
- return true;
- else
- return false;
- case 11:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) ||
- (k1.p6 < k2.p6) ||
- (k1.p7 < k2.p7) ||
- (k1.p8 < k2.p8) ||
- (k1.p9 < k2.p9) ||
- (k1.p10 < k2.p10) ||
- (k1.p11 < k2.p11) )
- return true;
- else
- return false;
- case 12:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) ||
- (k1.p6 < k2.p6) ||
- (k1.p7 < k2.p7) ||
- (k1.p8 < k2.p8) ||
- (k1.p9 < k2.p9) ||
- (k1.p10 < k2.p10) ||
- (k1.p11 < k2.p11) ||
- (k1.p12 < k2.p12) )
- return true;
- else
- return false;
- case 13:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) ||
- (k1.p6 < k2.p6) ||
- (k1.p7 < k2.p7) ||
- (k1.p8 < k2.p8) ||
- (k1.p9 < k2.p9) ||
- (k1.p10 < k2.p10) ||
- (k1.p11 < k2.p11) ||
- (k1.p12 < k2.p12) ||
- (k1.p13 < k2.p13) )
- return true;
- else
- return false;
- case 14:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) ||
- (k1.p6 < k2.p6) ||
- (k1.p7 < k2.p7) ||
- (k1.p8 < k2.p8) ||
- (k1.p9 < k2.p9) ||
- (k1.p10 < k2.p10) ||
- (k1.p11 < k2.p11) ||
- (k1.p12 < k2.p12) ||
- (k1.p13 < k2.p13) ||
- (k1.p14 < k2.p14) )
- return true;
- else
- return false;
- case 15:
- if( (k1.id < k2.id) ||
- (k1.p1 < k2.p1) ||
- (k1.p2 < k2.p2) ||
- (k1.p3 < k2.p3) ||
- (k1.p4 < k2.p4) ||
- (k1.p5 < k2.p5) ||
- (k1.p6 < k2.p6) ||
- (k1.p7 < k2.p7) ||
- (k1.p8 < k2.p8) ||
- (k1.p9 < k2.p9) ||
- (k1.p10 < k2.p10) ||
- (k1.p11 < k2.p11) ||
- (k1.p12 < k2.p12) ||
- (k1.p13 < k2.p13) ||
- (k1.p14 < k2.p14) ||
- (k1.p15 < k2.p15) )
- return true;
- else
- return false;
- default:
- return false;
- }
+ case -1:
+ return false;
+ case 0:
+ if( k1.id < k2.id )
+ return true;
+ else
+ return false;
+ case 1:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) )
+ return true;
+ else
+ return false;
+ case 2:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) )
+ return true;
+ else
+ return false;
+ case 3:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) )
+ return true;
+ else
+ return false;
+ case 4:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) )
+ return true;
+ else
+ return false;
+ case 5:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) )
+ return true;
+ else
+ return false;
+ case 6:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) ||
+ (k1.p6 < k2.p6) )
+ return true;
+ else
+ return false;
+ case 7:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) ||
+ (k1.p6 < k2.p6) ||
+ (k1.p7 < k2.p7) )
+ return true;
+ else
+ return false;
+ case 8:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) ||
+ (k1.p6 < k2.p6) ||
+ (k1.p7 < k2.p7) ||
+ (k1.p8 < k2.p8) )
+ return true;
+ else
+ return false;
+ case 9:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) ||
+ (k1.p6 < k2.p6) ||
+ (k1.p7 < k2.p7) ||
+ (k1.p8 < k2.p8) ||
+ (k1.p9 < k2.p9) )
+ return true;
+ else
+ return false;
+ case 10:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) ||
+ (k1.p6 < k2.p6) ||
+ (k1.p7 < k2.p7) ||
+ (k1.p8 < k2.p8) ||
+ (k1.p9 < k2.p9) ||
+ (k1.p10 < k2.p10) )
+ return true;
+ else
+ return false;
+ case 11:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) ||
+ (k1.p6 < k2.p6) ||
+ (k1.p7 < k2.p7) ||
+ (k1.p8 < k2.p8) ||
+ (k1.p9 < k2.p9) ||
+ (k1.p10 < k2.p10) ||
+ (k1.p11 < k2.p11) )
+ return true;
+ else
+ return false;
+ case 12:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) ||
+ (k1.p6 < k2.p6) ||
+ (k1.p7 < k2.p7) ||
+ (k1.p8 < k2.p8) ||
+ (k1.p9 < k2.p9) ||
+ (k1.p10 < k2.p10) ||
+ (k1.p11 < k2.p11) ||
+ (k1.p12 < k2.p12) )
+ return true;
+ else
+ return false;
+ case 13:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) ||
+ (k1.p6 < k2.p6) ||
+ (k1.p7 < k2.p7) ||
+ (k1.p8 < k2.p8) ||
+ (k1.p9 < k2.p9) ||
+ (k1.p10 < k2.p10) ||
+ (k1.p11 < k2.p11) ||
+ (k1.p12 < k2.p12) ||
+ (k1.p13 < k2.p13) )
+ return true;
+ else
+ return false;
+ case 14:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) ||
+ (k1.p6 < k2.p6) ||
+ (k1.p7 < k2.p7) ||
+ (k1.p8 < k2.p8) ||
+ (k1.p9 < k2.p9) ||
+ (k1.p10 < k2.p10) ||
+ (k1.p11 < k2.p11) ||
+ (k1.p12 < k2.p12) ||
+ (k1.p13 < k2.p13) ||
+ (k1.p14 < k2.p14) )
+ return true;
+ else
+ return false;
+ case 15:
+ if( (k1.id < k2.id) ||
+ (k1.p1 < k2.p1) ||
+ (k1.p2 < k2.p2) ||
+ (k1.p3 < k2.p3) ||
+ (k1.p4 < k2.p4) ||
+ (k1.p5 < k2.p5) ||
+ (k1.p6 < k2.p6) ||
+ (k1.p7 < k2.p7) ||
+ (k1.p8 < k2.p8) ||
+ (k1.p9 < k2.p9) ||
+ (k1.p10 < k2.p10) ||
+ (k1.p11 < k2.p11) ||
+ (k1.p12 < k2.p12) ||
+ (k1.p13 < k2.p13) ||
+ (k1.p14 < k2.p14) ||
+ (k1.p15 < k2.p15) )
+ return true;
+ else
+ return false;
+ default:
+ return false;
}
+}
+
-
} // namespace Loki
diff --git a/shared/loki/LevelMutex.h b/shared/loki/LevelMutex.h
index c048000f..eb01f44a 100644
--- a/shared/loki/LevelMutex.h
+++ b/shared/loki/LevelMutex.h
@@ -4,9 +4,9 @@
// Copyright (c) 2008 Richard Sposato
// The copyright on this file is protected under the terms of the MIT license.
//
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
//
// The author makes no representations about the suitability of this software
@@ -29,13 +29,13 @@
#include <time.h>
#if defined( _MSC_VER )
- #include <Windows.h>
+#include <Windows.h>
#else
- #include <pthread.h>
+#include <pthread.h>
#endif
#if !defined(_WIN32) && !defined(_WIN64)
- #include <unistd.h> // declares sleep under Linux
+#include <unistd.h> // declares sleep under Linux
#endif
/** @par thread_local Keyword
@@ -49,26 +49,26 @@
you can't use LevelMutex.
*/
#ifndef LOKI_THREAD_LOCAL
- #if defined( _MSC_VER )
- #if ( _MSC_VER >= 1300 )
- #define LOKI_THREAD_LOCAL __declspec( thread )
- #else
- #error "Only Visual Studio versions 7.0 and after supported."
- #endif
-
- #elif ( __GNUC__ )
- #define LOKI_THREAD_LOCAL __thread
-
- #else
- #warning "Check if your compiler provides thread local storage."
- #define LOKI_THREAD_LOCAL thread_local
- #endif
+#if defined( _MSC_VER )
+#if ( _MSC_VER >= 1300 )
+#define LOKI_THREAD_LOCAL __declspec( thread )
+#else
+#error "Only Visual Studio versions 7.0 and after supported."
+#endif
+
+#elif ( __GNUC__ )
+#define LOKI_THREAD_LOCAL __thread
+
+#else
+#warning "Check if your compiler provides thread local storage."
+#define LOKI_THREAD_LOCAL thread_local
+#endif
#endif
#if defined( DEBUG ) || defined( _DEBUG )
- #define LOKI_MUTEX_DEBUG_CODE( x ) x
+#define LOKI_MUTEX_DEBUG_CODE( x ) x
#else
- #define LOKI_MUTEX_DEBUG_CODE( x )
+#define LOKI_MUTEX_DEBUG_CODE( x )
#endif
@@ -154,7 +154,7 @@ public:
static const unsigned int UnlockedLevel = 0xFFFFFFFF;
/// Container for locking multiple mutexes at once.
- typedef ::std::vector< volatile LevelMutexInfo * > MutexContainer;
+ typedef ::std::vector< volatile LevelMutexInfo* > MutexContainer;
typedef MutexContainer::iterator LevelMutexContainerIter;
typedef MutexContainer::const_iterator LevelMutexContainerCIter;
typedef MutexContainer::reverse_iterator LevelMutexContainerRIter;
@@ -170,7 +170,7 @@ public:
by address order.
@return Enum value indicating success or error.
*/
- static MutexErrors::Type MultiLock( MutexContainer & mutexes );
+ static MutexErrors::Type MultiLock( MutexContainer& mutexes );
/** Locks several mutexes at once. Requires O(m + n*n + n*t) actions where m is
the number of mutexes currently locked by the thread, n is the number of mutexes
@@ -184,8 +184,8 @@ public:
@param milliSeconds Amount of time to wait for each mutex.
@return Enum value indicating success or error.
*/
- static MutexErrors::Type MultiLock( MutexContainer & mutexes,
- unsigned int milliSeconds );
+ static MutexErrors::Type MultiLock( MutexContainer& mutexes,
+ unsigned int milliSeconds );
/** Unlocks several mutexes at once. Requires O(m) actions where m is the number of
mutexes in the container. This provides strong exception safety. If an exception
@@ -195,14 +195,14 @@ public:
be locked by the current thread. This sorts the container dby address order.
@return Enum value indicating success or error.
*/
- static MutexErrors::Type MultiUnlock( MutexContainer & mutexes );
+ static MutexErrors::Type MultiUnlock( MutexContainer& mutexes );
/** Gives pointer to most recently locked mutex, or NULL if nothing locked.
The pointer is for a const mutex so the mutex can't be modified inappropriately.
The pointer is for a volatile mutex so callers can call volatile member
functions to get info about the mutex.
*/
- static const volatile LevelMutexInfo * GetCurrentMutex( void );
+ static const volatile LevelMutexInfo* GetCurrentMutex( void );
/// Returns the level of this mutex.
inline unsigned int GetLevel( void ) const volatile { return m_level; }
@@ -214,7 +214,7 @@ public:
inline unsigned int GetLockCount( void ) const volatile { return m_count; }
/// Returns pointer to mutex previously locked by the thread which locked this.
- inline const volatile LevelMutexInfo * GetPrevious( void ) const volatile
+ inline const volatile LevelMutexInfo* GetPrevious( void ) const volatile
{
return m_previous;
}
@@ -279,14 +279,14 @@ protected:
class Checker
{
public:
- inline explicit Checker( const volatile LevelMutexInfo * mutex ) :
+ inline explicit Checker( const volatile LevelMutexInfo* mutex ) :
m_mutex( mutex ) {}
inline ~Checker( void ) { m_mutex->IsValid(); }
private:
Checker( void );
- Checker( const Checker & );
- Checker & operator = ( const Checker & );
- const volatile LevelMutexInfo * m_mutex;
+ Checker( const Checker& );
+ Checker& operator = ( const Checker& );
+ const volatile LevelMutexInfo* m_mutex;
};
/** @class MutexUndoer
@@ -299,18 +299,18 @@ protected:
{
public:
- explicit MutexUndoer( MutexContainer & mutexes );
+ explicit MutexUndoer( MutexContainer& mutexes );
~MutexUndoer( void );
- void SetPlace( LevelMutexContainerIter & here );
+ void SetPlace( LevelMutexContainerIter& here );
void Cancel( void );
private:
MutexUndoer( void );
- MutexUndoer( const MutexUndoer & );
- MutexUndoer & operator = ( const MutexUndoer & );
+ MutexUndoer( const MutexUndoer& );
+ MutexUndoer& operator = ( const MutexUndoer& );
- MutexContainer & m_mutexes;
+ MutexContainer& m_mutexes;
LevelMutexContainerIter m_here;
};
@@ -354,9 +354,9 @@ protected:
private:
/// Copy constructor is not implemented.
- LevelMutexInfo( const LevelMutexInfo & );
+ LevelMutexInfo( const LevelMutexInfo& );
/// Copy-assignment operator is not implemented.
- LevelMutexInfo & operator = ( const LevelMutexInfo & );
+ LevelMutexInfo& operator = ( const LevelMutexInfo& );
/** Called only by MultiLock & MultiUnlock to pass a result through an
error checking policy.
@@ -373,11 +373,11 @@ private:
*/
virtual MutexErrors::Type LockThis( unsigned int milliSeconds ) volatile = 0;
- /// Called only by MultiUnlock to unlock each particular mutex within a container.
+ /// Called only by MultiUnlock to unlock each particular mutex within a container.
virtual MutexErrors::Type UnlockThis( void ) volatile = 0;
/// Pointer to singly-linked list of mutexes locked by the current thread.
- static LOKI_THREAD_LOCAL volatile LevelMutexInfo * s_currentMutex;
+ static LOKI_THREAD_LOCAL volatile LevelMutexInfo* s_currentMutex;
/// Level of this mutex.
const unsigned int m_level;
@@ -386,7 +386,7 @@ private:
unsigned int m_count;
/// Pointer to mutex locked before this one.
- volatile LevelMutexInfo * m_previous;
+ volatile LevelMutexInfo* m_previous;
};
@@ -401,7 +401,7 @@ class ThrowOnAnyMutexError
{
public:
static MutexErrors::Type CheckError( MutexErrors::Type error,
- unsigned int level );
+ unsigned int level );
};
// ----------------------------------------------------------------------------
@@ -415,7 +415,7 @@ class ThrowOnBadDesignMutexError
{
public:
static MutexErrors::Type CheckError( MutexErrors::Type error,
- unsigned int level );
+ unsigned int level );
};
// ----------------------------------------------------------------------------
@@ -429,11 +429,11 @@ class AssertAnyMutexError
{
public:
static inline MutexErrors::Type CheckError( MutexErrors::Type error,
- unsigned int level )
+ unsigned int level )
{
(void)level;
assert( ( error == MutexErrors::Success )
- || ( error == MutexErrors::NoProblem ) );
+ || ( error == MutexErrors::NoProblem ) );
return error;
}
};
@@ -449,11 +449,11 @@ class AssertBadDesignMutexError
{
public:
static inline MutexErrors::Type CheckError( MutexErrors::Type error,
- unsigned int level )
+ unsigned int level )
{
(void)level;
assert( ( error != MutexErrors::LevelTooHigh )
- && ( error != MutexErrors::LevelTooLow ) );
+ && ( error != MutexErrors::LevelTooLow ) );
return error;
}
};
@@ -469,7 +469,7 @@ class JustReturnMutexError
{
public:
static inline MutexErrors::Type CheckError( MutexErrors::Type error,
- unsigned int level )
+ unsigned int level )
{
(void)level;
return error;
@@ -533,24 +533,24 @@ public:
private:
/// Copy constructor is not implemented.
- SpinLevelMutex( const SpinLevelMutex & );
+ SpinLevelMutex( const SpinLevelMutex& );
/// Copy-assignment operator is not implemented.
- SpinLevelMutex & operator = ( const SpinLevelMutex & );
+ SpinLevelMutex& operator = ( const SpinLevelMutex& );
#if defined( _MSC_VER )
- #if ( _MSC_VER >= 1300 )
- /// The actual mutex.
- CRITICAL_SECTION m_mutex;
- #else
- #error "Only Visual Studio versions 7.0 and after supported."
- #endif
+#if ( _MSC_VER >= 1300 )
+ /// The actual mutex.
+ CRITICAL_SECTION m_mutex;
+#else
+#error "Only Visual Studio versions 7.0 and after supported."
+#endif
#elif ( __GNUC__ )
/// The actual mutex.
pthread_mutex_t m_mutex;
#else
- #error "Check if any mutex libraries are compatible with your compiler."
+#error "Check if any mutex libraries are compatible with your compiler."
#endif
/// Keep a copy of the mutex level around for error reporting.
@@ -564,7 +564,7 @@ private:
Implements a sleeping loop to wait for the mutex to unlock.
@par Purpose
- Since this class puts the thread to sleep for short intervals, you can use this
+ Since this class puts the thread to sleep for short intervals, you can use this
class for most of your mutexes. Especially for locking any high level resources
where any one operation on the resouce consumes many CPU cycles. The purpose of
this mutex is to reduce the number of CPU cycles spent in idle loops. All
@@ -613,17 +613,17 @@ private:
/// Default constructor is not implemented.
SleepLevelMutex( void );
/// Copy constructor is not implemented.
- SleepLevelMutex( const SleepLevelMutex & );
+ SleepLevelMutex( const SleepLevelMutex& );
/// Copy-assignment operator is not implemented.
- SleepLevelMutex & operator = ( const SleepLevelMutex & );
+ SleepLevelMutex& operator = ( const SleepLevelMutex& );
#if defined( _MSC_VER )
- #if ( _MSC_VER >= 1300 )
- /// True if operating system may wake thread to respond to events.
- bool m_wakable;
- #else
- #error "Only Visual Studio versions 7.0 and after supported."
- #endif
+#if ( _MSC_VER >= 1300 )
+ /// True if operating system may wake thread to respond to events.
+ bool m_wakable;
+#else
+#error "Only Visual Studio versions 7.0 and after supported."
+#endif
#endif
/// How many milli-seconds to sleep before trying to lock mutex again.
@@ -738,11 +738,11 @@ private:
template
<
- class MutexPolicy,
- unsigned int DefaultLevel,
- class ErrorPolicy = ::Loki::ThrowOnBadDesignMutexError,
- class WaitPolicy = ::Loki::NoMutexWait
->
+class MutexPolicy,
+ unsigned int DefaultLevel,
+ class ErrorPolicy = ::Loki::ThrowOnBadDesignMutexError,
+ class WaitPolicy = ::Loki::NoMutexWait
+ >
class LevelMutex : public LevelMutexInfo
{
public:
@@ -775,10 +775,10 @@ public:
const and volatile qualifiers so callers get a reference to a MutexPolicy
with the proper qualifiers.
*/
- inline const volatile MutexPolicy & GetMutexPolicy( void ) const volatile { return m_mutex; }
- inline volatile MutexPolicy & GetMutexPolicy( void ) volatile { return m_mutex; }
- inline const MutexPolicy & GetMutexPolicy( void ) const { return m_mutex; }
- inline MutexPolicy & GetMutexPolicy( void ) { return m_mutex; }
+ inline const volatile MutexPolicy& GetMutexPolicy( void ) const volatile { return m_mutex; }
+ inline volatile MutexPolicy& GetMutexPolicy( void ) volatile { return m_mutex; }
+ inline const MutexPolicy& GetMutexPolicy( void ) const { return m_mutex; }
+ inline MutexPolicy& GetMutexPolicy( void ) { return m_mutex; }
virtual MutexErrors::Type TryLock( void ) volatile
{
@@ -889,9 +889,9 @@ public:
private:
/// Copy constructor is not implemented since mutexes don't get copied.
- LevelMutex( const LevelMutex & );
+ LevelMutex( const LevelMutex& );
/// Copy-assignment operator is not implemented since mutexes don't get copied.
- LevelMutex & operator = ( const LevelMutex & );
+ LevelMutex& operator = ( const LevelMutex& );
virtual MutexErrors::Type DoErrorCheck( MutexErrors::Type result ) const volatile
{
@@ -1002,7 +1002,7 @@ unsigned int CountMutexesAtCurrentLevel( void );
/** Determines if container of mutexes matches the recently locked mutexes.
If they do match, it returns success, otherwise an error condition.
*/
-MutexErrors::Type DoMutexesMatchContainer( const LevelMutexInfo::MutexContainer & mutexes );
+MutexErrors::Type DoMutexesMatchContainer( const LevelMutexInfo::MutexContainer& mutexes );
// ----------------------------------------------------------------------------
@@ -1018,19 +1018,19 @@ public:
/** Constructs an exception which stores information about a mutex and the
reason an attempt to use a mutex failed.
*/
- MutexException( const char * message, unsigned int level, MutexErrors::Type reason );
+ MutexException( const char* message, unsigned int level, MutexErrors::Type reason );
/// Copy constructor performs a member-by-member copy of an exception.
- MutexException( const MutexException & that ) throw ();
+ MutexException( const MutexException& that ) throw ();
/// Copy-assignment operator performs a member-by-member copy of an exception.
- MutexException & operator = ( const MutexException & that ) throw ();
+ MutexException& operator = ( const MutexException& that ) throw ();
/// Destroys the exception.
virtual ~MutexException( void ) throw();
/// Returns a simple message about which operation failed.
- virtual const char * what( void ) const throw();
+ virtual const char* what( void ) const throw();
/// Returns level of mutex(es) used when problem occurred.
unsigned int GetLevel( void ) const { return m_level; }
@@ -1044,7 +1044,7 @@ private:
MutexException( void ) throw ();
/// Simple message about operation that failed.
- const char * m_message;
+ const char* m_message;
/// Level of mutex(es) used when problem occurred.
unsigned int m_level;
/// Error status for why operation failed.
@@ -1071,7 +1071,7 @@ public:
@param lock True if function wants to lock the mutex as this gets
constructed.
*/
- explicit MutexLocker( volatile LevelMutexInfo & mutex, bool lock = true );
+ explicit MutexLocker( volatile LevelMutexInfo& mutex, bool lock = true );
/** Creates an object to lock an unlock a mutex for a function. This waits
a specified amount of time for another thread to unlock the mutex if it is
@@ -1082,8 +1082,8 @@ public:
@param lock True if function wants to lock the mutex as this gets
constructed.
*/
- MutexLocker( volatile LevelMutexInfo & mutex, unsigned int milliSeconds,
- bool lock = true );
+ MutexLocker( volatile LevelMutexInfo& mutex, unsigned int milliSeconds,
+ bool lock = true );
/// Destructs the locker, and determines if it needs to unlock the mutex.
~MutexLocker( void );
@@ -1107,23 +1107,23 @@ public:
/// Returns true if the mutex is locked by this object.
inline bool IsLocked( void ) const { return m_locked; }
- /// Provides access to mutex controlled by this.
- const volatile LevelMutexInfo & GetMutex( void ) const { return m_mutex; }
+ /// Provides access to mutex controlled by this.
+ const volatile LevelMutexInfo& GetMutex( void ) const { return m_mutex; }
private:
/// Default constructor is not implemented.
MutexLocker( void );
/// Copy constructor is not implemented.
- MutexLocker( const MutexLocker & );
+ MutexLocker( const MutexLocker& );
/// Copy-assignment operator is not implemented.
- MutexLocker & operator = ( const MutexLocker & );
+ MutexLocker& operator = ( const MutexLocker& );
/// True if mutex got locked.
bool m_locked;
/// Reference to mutex.
- volatile LevelMutexInfo & m_mutex;
+ volatile LevelMutexInfo& m_mutex;
};
// ----------------------------------------------------------------------------
@@ -1147,8 +1147,8 @@ public:
@param lock True if function wants to lock the mutex as this gets
constructed.
*/
- explicit MultiMutexLocker( LevelMutexInfo::MutexContainer & mutexes,
- bool lock = true );
+ explicit MultiMutexLocker( LevelMutexInfo::MutexContainer& mutexes,
+ bool lock = true );
/** Creates an object to lock and unlock a collection of mutexes for a function.
This waits a specified amount of time for other threads to unlock each mutex
@@ -1160,8 +1160,8 @@ public:
@param lock True if function wants to lock the mutexes as this gets
constructed.
*/
- MultiMutexLocker( LevelMutexInfo::MutexContainer & mutexes,
- unsigned int milliSeconds, bool lock = true );
+ MultiMutexLocker( LevelMutexInfo::MutexContainer& mutexes,
+ unsigned int milliSeconds, bool lock = true );
/// Destructs the locker, and determines if it needs to unlock the mutexes.
~MultiMutexLocker( void );
@@ -1185,23 +1185,23 @@ public:
/// Returns true if the mutexes are locked by this object.
inline bool IsLocked( void ) const { return m_locked; }
- /// Provides access to the collection of mutexes controlled by this.
- const LevelMutexInfo::MutexContainer & GetMutexes( void ) const { return m_mutexes; }
+ /// Provides access to the collection of mutexes controlled by this.
+ const LevelMutexInfo::MutexContainer& GetMutexes( void ) const { return m_mutexes; }
private:
/// Default constructor is not implemented.
MultiMutexLocker( void );
/// Copy constructor is not implemented.
- MultiMutexLocker( const MultiMutexLocker & );
+ MultiMutexLocker( const MultiMutexLocker& );
/// Copy-assignment operator is not implemented.
- MultiMutexLocker & operator = ( const MultiMutexLocker & );
+ MultiMutexLocker& operator = ( const MultiMutexLocker& );
/// True if mutexes got locked.
bool m_locked;
/// Reference to external container of mutexes;
- LevelMutexInfo::MutexContainer & m_mutexes;
+ LevelMutexInfo::MutexContainer& m_mutexes;
};
// ----------------------------------------------------------------------------
diff --git a/shared/loki/LockingPtr.h b/shared/loki/LockingPtr.h
index a50f5d6d..5482f075 100644
--- a/shared/loki/LockingPtr.h
+++ b/shared/loki/LockingPtr.h
@@ -7,12 +7,12 @@
// for You" by Alexandrescu, Andrei.
// Published in the February 2001 issue of the C/C++ Users Journal.
// http://www.cuj.com/documents/s=7998/cujcexp1902alexandr/
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
// Prepared for Loki library by Richard Sposato
////////////////////////////////////////////////////////////////////////////////
@@ -28,81 +28,81 @@
namespace Loki
{
- /** @class LockingPtr
- Locks a volatile object and casts away volatility so that the object
- can be safely used in a single-threaded region of code.
- Original version of LockingPtr had only one template - for the shared
- object, but not the mutex type. This version allows users to specify a
- the mutex type as a LockingPolicy class. The only requirements for a
- LockingPolicy class are to provide Lock and Unlock methods.
+/** @class LockingPtr
+ Locks a volatile object and casts away volatility so that the object
+ can be safely used in a single-threaded region of code.
+ Original version of LockingPtr had only one template - for the shared
+ object, but not the mutex type. This version allows users to specify a
+ the mutex type as a LockingPolicy class. The only requirements for a
+ LockingPolicy class are to provide Lock and Unlock methods.
+ */
+template < typename SharedObject, typename LockingPolicy = LOKI_DEFAULT_MUTEX,
+ template<class> class ConstPolicy = LOKI_DEFAULT_CONSTNESS >
+class LockingPtr
+{
+public:
+
+ typedef typename ConstPolicy<SharedObject>::Type ConstOrNotType;
+
+ /** Constructor locks mutex associated with an object.
+ @param object Reference to object.
+ @param mutex Mutex used to control thread access to object.
+ */
+ LockingPtr( volatile ConstOrNotType& object, LockingPolicy& mutex )
+ : pObject_( const_cast< SharedObject* >( &object ) ),
+ pMutex_( &mutex )
+ {
+ mutex.Lock();
+ }
+
+ typedef typename std::pair<volatile ConstOrNotType*, LockingPolicy*> Pair;
+
+ /** Constructor locks mutex associated with an object.
+ @param lockpair a std::pair of pointers to the object and the mutex
*/
- template < typename SharedObject, typename LockingPolicy = LOKI_DEFAULT_MUTEX,
- template<class> class ConstPolicy = LOKI_DEFAULT_CONSTNESS >
- class LockingPtr
+ LockingPtr( Pair lockpair )
+ : pObject_( const_cast< SharedObject* >( lockpair.first ) ),
+ pMutex_( lockpair.second )
+ {
+ lockpair.second->Lock();
+ }
+
+ /// Destructor unlocks the mutex.
+ ~LockingPtr()
+ {
+ pMutex_->Unlock();
+ }
+
+ /// Star-operator dereferences pointer.
+ ConstOrNotType& operator * ()
+ {
+ return *pObject_;
+ }
+
+ /// Point-operator returns pointer to object.
+ ConstOrNotType* operator -> ()
{
- public:
-
- typedef typename ConstPolicy<SharedObject>::Type ConstOrNotType;
-
- /** Constructor locks mutex associated with an object.
- @param object Reference to object.
- @param mutex Mutex used to control thread access to object.
- */
- LockingPtr( volatile ConstOrNotType & object, LockingPolicy & mutex )
- : pObject_( const_cast< SharedObject * >( &object ) ),
- pMutex_( &mutex )
- {
- mutex.Lock();
- }
-
- typedef typename std::pair<volatile ConstOrNotType *, LockingPolicy *> Pair;
-
- /** Constructor locks mutex associated with an object.
- @param lockpair a std::pair of pointers to the object and the mutex
- */
- LockingPtr( Pair lockpair )
- : pObject_( const_cast< SharedObject * >( lockpair.first ) ),
- pMutex_( lockpair.second )
- {
- lockpair.second->Lock();
- }
-
- /// Destructor unlocks the mutex.
- ~LockingPtr()
- {
- pMutex_->Unlock();
- }
-
- /// Star-operator dereferences pointer.
- ConstOrNotType & operator * ()
- {
- return *pObject_;
- }
-
- /// Point-operator returns pointer to object.
- ConstOrNotType * operator -> ()
- {
- return pObject_;
- }
-
- private:
-
- /// Default constructor is not implemented.
- LockingPtr();
-
- /// Copy-constructor is not implemented.
- LockingPtr( const LockingPtr & );
-
- /// Copy-assignment-operator is not implemented.
- LockingPtr & operator = ( const LockingPtr & );
-
- /// Pointer to the shared object.
- ConstOrNotType * pObject_;
-
- /// Pointer to the mutex.
- LockingPolicy * pMutex_;
-
- }; // end class LockingPtr
+ return pObject_;
+ }
+
+private:
+
+ /// Default constructor is not implemented.
+ LockingPtr();
+
+ /// Copy-constructor is not implemented.
+ LockingPtr( const LockingPtr& );
+
+ /// Copy-assignment-operator is not implemented.
+ LockingPtr& operator = ( const LockingPtr& );
+
+ /// Pointer to the shared object.
+ ConstOrNotType* pObject_;
+
+ /// Pointer to the mutex.
+ LockingPolicy* pMutex_;
+
+}; // end class LockingPtr
} // namespace Loki
diff --git a/shared/loki/LokiExport.h b/shared/loki/LokiExport.h
index 625449f2..eb02516b 100644
--- a/shared/loki/LokiExport.h
+++ b/shared/loki/LokiExport.h
@@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
// The Loki Library
// Copyright (c) 2006 by Peter Kümmel
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_LOKIEXPORT_INC_
@@ -19,10 +19,10 @@
#ifdef _HAVE_GCC_VISIBILITY
#define LOKI_EXPORT_SPEC __attribute__ ((visibility("default")))
-#define LOKI_IMPORT_SPEC
+#define LOKI_IMPORT_SPEC
#else
#define LOKI_EXPORT_SPEC
-#define LOKI_IMPORT_SPEC
+#define LOKI_IMPORT_SPEC
#endif
#else
@@ -31,8 +31,8 @@
#define LOKI_EXPORT_SPEC __declspec(dllexport)
#define LOKI_IMPORT_SPEC __declspec(dllimport)
#else
-#define LOKI_EXPORT_SPEC
-#define LOKI_IMPORT_SPEC
+#define LOKI_EXPORT_SPEC
+#define LOKI_IMPORT_SPEC
#endif
#endif
diff --git a/shared/loki/LokiTypeInfo.h b/shared/loki/LokiTypeInfo.h
index 715dab1a..ecb657d4 100644
--- a/shared/loki/LokiTypeInfo.h
+++ b/shared/loki/LokiTypeInfo.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_LOKITYPEINFO_INC_
@@ -29,75 +29,75 @@ namespace Loki
// Purpose: offer a first-class, comparable wrapper over std::type_info
////////////////////////////////////////////////////////////////////////////////
- class TypeInfo
- {
- public:
- // Constructors
- TypeInfo(); // needed for containers
- TypeInfo(const std::type_info&); // non-explicit
-
- // Access for the wrapped std::type_info
- const std::type_info& Get() const;
- // Compatibility functions
- bool before(const TypeInfo& rhs) const;
- const char* name() const;
-
- private:
- const std::type_info* pInfo_;
- };
-
+class TypeInfo
+{
+public:
+ // Constructors
+ TypeInfo(); // needed for containers
+ TypeInfo(const std::type_info&); // non-explicit
+
+ // Access for the wrapped std::type_info
+ const std::type_info& Get() const;
+ // Compatibility functions
+ bool before(const TypeInfo& rhs) const;
+ const char* name() const;
+
+private:
+ const std::type_info* pInfo_;
+};
+
// Implementation
-
- inline TypeInfo::TypeInfo()
- {
- class Nil {};
- pInfo_ = &typeid(Nil);
- assert(pInfo_);
- }
-
- inline TypeInfo::TypeInfo(const std::type_info& ti)
+
+inline TypeInfo::TypeInfo()
+{
+ class Nil {};
+ pInfo_ = &typeid(Nil);
+ assert(pInfo_);
+}
+
+inline TypeInfo::TypeInfo(const std::type_info& ti)
: pInfo_(&ti)
- { assert(pInfo_); }
-
- inline bool TypeInfo::before(const TypeInfo& rhs) const
- {
- assert(pInfo_);
- // type_info::before return type is int in some VC libraries
- return pInfo_->before(*rhs.pInfo_) != 0;
- }
-
- inline const std::type_info& TypeInfo::Get() const
- {
- assert(pInfo_);
- return *pInfo_;
- }
-
- inline const char* TypeInfo::name() const
- {
- assert(pInfo_);
- return pInfo_->name();
- }
+{ assert(pInfo_); }
+
+inline bool TypeInfo::before(const TypeInfo& rhs) const
+{
+ assert(pInfo_);
+ // type_info::before return type is int in some VC libraries
+ return pInfo_->before(*rhs.pInfo_) != 0;
+}
+
+inline const std::type_info& TypeInfo::Get() const
+{
+ assert(pInfo_);
+ return *pInfo_;
+}
+
+inline const char* TypeInfo::name() const
+{
+ assert(pInfo_);
+ return pInfo_->name();
+}
// Comparison operators
-
- inline bool operator==(const TypeInfo& lhs, const TypeInfo& rhs)
- // type_info::operator== return type is int in some VC libraries
- { return (lhs.Get() == rhs.Get()) != 0; }
-
- inline bool operator<(const TypeInfo& lhs, const TypeInfo& rhs)
- { return lhs.before(rhs); }
-
- inline bool operator!=(const TypeInfo& lhs, const TypeInfo& rhs)
- { return !(lhs == rhs); }
-
- inline bool operator>(const TypeInfo& lhs, const TypeInfo& rhs)
- { return rhs < lhs; }
-
- inline bool operator<=(const TypeInfo& lhs, const TypeInfo& rhs)
- { return !(lhs > rhs); }
-
- inline bool operator>=(const TypeInfo& lhs, const TypeInfo& rhs)
- { return !(lhs < rhs); }
+
+inline bool operator==(const TypeInfo& lhs, const TypeInfo& rhs)
+// type_info::operator== return type is int in some VC libraries
+{ return (lhs.Get() == rhs.Get()) != 0; }
+
+inline bool operator<(const TypeInfo& lhs, const TypeInfo& rhs)
+{ return lhs.before(rhs); }
+
+inline bool operator!=(const TypeInfo& lhs, const TypeInfo& rhs)
+{ return !(lhs == rhs); }
+
+inline bool operator>(const TypeInfo& lhs, const TypeInfo& rhs)
+{ return rhs < lhs; }
+
+inline bool operator<=(const TypeInfo& lhs, const TypeInfo& rhs)
+{ return !(lhs > rhs); }
+
+inline bool operator>=(const TypeInfo& lhs, const TypeInfo& rhs)
+{ return !(lhs < rhs); }
}
#endif // end file guardian
diff --git a/shared/loki/MultiMethods.h b/shared/loki/MultiMethods.h
index d095cfae..ece4fb17 100644
--- a/shared/loki/MultiMethods.h
+++ b/shared/loki/MultiMethods.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_MULTIMETHODS_INC_
@@ -36,210 +36,210 @@ namespace Loki
// Helps implementing optional symmetry
////////////////////////////////////////////////////////////////////////////////
- namespace Private
+namespace Private
+{
+template <class SomeLhs, class SomeRhs,
+ class Executor, typename ResultType>
+struct InvocationTraits
+{
+ static ResultType
+ DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
+ Executor& exec, Int2Type<false>)
{
- template <class SomeLhs, class SomeRhs,
- class Executor, typename ResultType>
- struct InvocationTraits
- {
- static ResultType
- DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
- Executor& exec, Int2Type<false>)
- {
- return exec.Fire(lhs, rhs);
- }
- static ResultType
- DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
- Executor& exec, Int2Type<true>)
- {
- return exec.Fire(rhs, lhs);
- }
- };
+ return exec.Fire(lhs, rhs);
}
+ static ResultType
+ DoDispatch(SomeLhs& lhs, SomeRhs& rhs,
+ Executor& exec, Int2Type<true>)
+ {
+ return exec.Fire(rhs, lhs);
+ }
+};
+}
////////////////////////////////////////////////////////////////////////////////
// class template StaticDispatcher
// Implements an automatic static double dispatcher based on two typelists
////////////////////////////////////////////////////////////////////////////////
- template
- <
- class Executor,
- class BaseLhs,
- class TypesLhs,
- bool symmetric = true,
- class BaseRhs = BaseLhs,
- class TypesRhs = TypesLhs,
- typename ResultType = void
- >
- class StaticDispatcher
+template
+<
+class Executor,
+ class BaseLhs,
+ class TypesLhs,
+ bool symmetric = true,
+ class BaseRhs = BaseLhs,
+ class TypesRhs = TypesLhs,
+ typename ResultType = void
+ >
+class StaticDispatcher
+{
+ template <class SomeLhs>
+ static ResultType DispatchRhs(SomeLhs& lhs, BaseRhs& rhs,
+ Executor exec, NullType)
+ { return exec.OnError(lhs, rhs); }
+
+ template <class Head, class Tail, class SomeLhs>
+ static ResultType DispatchRhs(SomeLhs& lhs, BaseRhs& rhs,
+ Executor exec, Typelist<Head, Tail>)
{
- template <class SomeLhs>
- static ResultType DispatchRhs(SomeLhs& lhs, BaseRhs& rhs,
- Executor exec, NullType)
- { return exec.OnError(lhs, rhs); }
-
- template <class Head, class Tail, class SomeLhs>
- static ResultType DispatchRhs(SomeLhs& lhs, BaseRhs& rhs,
- Executor exec, Typelist<Head, Tail>)
- {
- if (Head* p2 = dynamic_cast<Head*>(&rhs))
- {
- Int2Type<(symmetric &&
- int(TL::IndexOf<TypesRhs, Head>::value) <
- int(TL::IndexOf<TypesLhs, SomeLhs>::value))> i2t;
-
- typedef Private::InvocationTraits<
- SomeLhs, Head, Executor, ResultType> CallTraits;
-
- return CallTraits::DoDispatch(lhs, *p2, exec, i2t);
- }
- return DispatchRhs(lhs, rhs, exec, Tail());
+ if (Head* p2 = dynamic_cast<Head*>(&rhs))
+ {
+ Int2Type<(symmetric &&
+ int(TL::IndexOf<TypesRhs, Head>::value) <
+ int(TL::IndexOf<TypesLhs, SomeLhs>::value))> i2t;
+
+ typedef Private::InvocationTraits<
+ SomeLhs, Head, Executor, ResultType> CallTraits;
+
+ return CallTraits::DoDispatch(lhs, *p2, exec, i2t);
}
-
- static ResultType DispatchLhs(BaseLhs& lhs, BaseRhs& rhs,
- Executor exec, NullType)
- { return exec.OnError(lhs, rhs); }
-
- template <class Head, class Tail>
- static ResultType DispatchLhs(BaseLhs& lhs, BaseRhs& rhs,
- Executor exec, Typelist<Head, Tail>)
- {
- if (Head* p1 = dynamic_cast<Head*>(&lhs))
- {
- return DispatchRhs(*p1, rhs, exec, TypesRhs());
- }
- return DispatchLhs(lhs, rhs, exec, Tail());
+ return DispatchRhs(lhs, rhs, exec, Tail());
+ }
+
+ static ResultType DispatchLhs(BaseLhs& lhs, BaseRhs& rhs,
+ Executor exec, NullType)
+ { return exec.OnError(lhs, rhs); }
+
+ template <class Head, class Tail>
+ static ResultType DispatchLhs(BaseLhs& lhs, BaseRhs& rhs,
+ Executor exec, Typelist<Head, Tail>)
+ {
+ if (Head* p1 = dynamic_cast<Head*>(&lhs))
+ {
+ return DispatchRhs(*p1, rhs, exec, TypesRhs());
}
+ return DispatchLhs(lhs, rhs, exec, Tail());
+ }
+
+public:
+ static ResultType Go(BaseLhs& lhs, BaseRhs& rhs,
+ Executor exec)
+ { return DispatchLhs(lhs, rhs, exec, TypesLhs()); }
+};
- public:
- static ResultType Go(BaseLhs& lhs, BaseRhs& rhs,
- Executor exec)
- { return DispatchLhs(lhs, rhs, exec, TypesLhs()); }
- };
-
////////////////////////////////////////////////////////////////////////////////
// class template BasicDispatcher
// Implements a logarithmic double dispatcher for functors (or functions)
// Doesn't offer automated casts or symmetry
////////////////////////////////////////////////////////////////////////////////
- template
- <
- class BaseLhs,
- class BaseRhs = BaseLhs,
- typename ResultType = void,
- typename CallbackType = ResultType (*)(BaseLhs&, BaseRhs&)
- >
- class BasicDispatcher
- {
- typedef std::pair<TypeInfo,TypeInfo> KeyType;
- typedef CallbackType MappedType;
- typedef AssocVector<KeyType, MappedType> MapType;
- MapType callbackMap_;
-
- void DoAdd(TypeInfo lhs, TypeInfo rhs, CallbackType fun);
- bool DoRemove(TypeInfo lhs, TypeInfo rhs);
-
- public:
- template <class SomeLhs, class SomeRhs>
- void Add(CallbackType fun)
- {
- DoAdd(typeid(SomeLhs), typeid(SomeRhs), fun);
- }
-
- template <class SomeLhs, class SomeRhs>
- bool Remove()
- {
- return DoRemove(typeid(SomeLhs), typeid(SomeRhs));
- }
-
- ResultType Go(BaseLhs& lhs, BaseRhs& rhs);
- };
-
- // Non-inline to reduce compile time overhead...
- template <class BaseLhs, class BaseRhs,
- typename ResultType, typename CallbackType>
- void BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
- ::DoAdd(TypeInfo lhs, TypeInfo rhs, CallbackType fun)
+template
+<
+class BaseLhs,
+ class BaseRhs = BaseLhs,
+ typename ResultType = void,
+ typename CallbackType = ResultType (*)(BaseLhs&, BaseRhs&)
+ >
+class BasicDispatcher
+{
+ typedef std::pair<TypeInfo,TypeInfo> KeyType;
+ typedef CallbackType MappedType;
+ typedef AssocVector<KeyType, MappedType> MapType;
+ MapType callbackMap_;
+
+ void DoAdd(TypeInfo lhs, TypeInfo rhs, CallbackType fun);
+ bool DoRemove(TypeInfo lhs, TypeInfo rhs);
+
+public:
+ template <class SomeLhs, class SomeRhs>
+ void Add(CallbackType fun)
{
- callbackMap_[KeyType(lhs, rhs)] = fun;
+ DoAdd(typeid(SomeLhs), typeid(SomeRhs), fun);
}
-
- template <class BaseLhs, class BaseRhs,
- typename ResultType, typename CallbackType>
- bool BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
- ::DoRemove(TypeInfo lhs, TypeInfo rhs)
+
+ template <class SomeLhs, class SomeRhs>
+ bool Remove()
{
- return callbackMap_.erase(KeyType(lhs, rhs)) == 1;
+ return DoRemove(typeid(SomeLhs), typeid(SomeRhs));
}
- template <class BaseLhs, class BaseRhs,
- typename ResultType, typename CallbackType>
- ResultType BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
- ::Go(BaseLhs& lhs, BaseRhs& rhs)
+ ResultType Go(BaseLhs& lhs, BaseRhs& rhs);
+};
+
+// Non-inline to reduce compile time overhead...
+template <class BaseLhs, class BaseRhs,
+ typename ResultType, typename CallbackType>
+void BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
+::DoAdd(TypeInfo lhs, TypeInfo rhs, CallbackType fun)
+{
+ callbackMap_[KeyType(lhs, rhs)] = fun;
+}
+
+template <class BaseLhs, class BaseRhs,
+ typename ResultType, typename CallbackType>
+bool BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
+::DoRemove(TypeInfo lhs, TypeInfo rhs)
+{
+ return callbackMap_.erase(KeyType(lhs, rhs)) == 1;
+}
+
+template <class BaseLhs, class BaseRhs,
+ typename ResultType, typename CallbackType>
+ResultType BasicDispatcher<BaseLhs,BaseRhs,ResultType,CallbackType>
+::Go(BaseLhs& lhs, BaseRhs& rhs)
+{
+ typename MapType::key_type k(typeid(lhs),typeid(rhs));
+ typename MapType::iterator i = callbackMap_.find(k);
+ if (i == callbackMap_.end())
{
- typename MapType::key_type k(typeid(lhs),typeid(rhs));
- typename MapType::iterator i = callbackMap_.find(k);
- if (i == callbackMap_.end())
- {
- throw std::runtime_error("Function not found");
- }
- return (i->second)(lhs, rhs);
+ throw std::runtime_error("Function not found");
}
+ return (i->second)(lhs, rhs);
+}
////////////////////////////////////////////////////////////////////////////////
// class template StaticCaster
// Implementation of the CastingPolicy used by FunctorDispatcher
////////////////////////////////////////////////////////////////////////////////
- template <class To, class From>
- struct StaticCaster
+template <class To, class From>
+struct StaticCaster
+{
+ static To& Cast(From& obj)
{
- static To& Cast(From& obj)
- {
- return static_cast<To&>(obj);
- }
- };
+ return static_cast<To&>(obj);
+ }
+};
////////////////////////////////////////////////////////////////////////////////
// class template DynamicCaster
// Implementation of the CastingPolicy used by FunctorDispatcher
////////////////////////////////////////////////////////////////////////////////
- template <class To, class From>
- struct DynamicCaster
+template <class To, class From>
+struct DynamicCaster
+{
+ static To& Cast(From& obj)
{
- static To& Cast(From& obj)
- {
- return dynamic_cast<To&>(obj);
- }
- };
+ return dynamic_cast<To&>(obj);
+ }
+};
////////////////////////////////////////////////////////////////////////////////
// class template Private::FnDispatcherHelper
// Implements trampolines and argument swapping used by FnDispatcher
////////////////////////////////////////////////////////////////////////////////
- namespace Private
+namespace Private
+{
+template <class BaseLhs, class BaseRhs,
+ class SomeLhs, class SomeRhs,
+ typename ResultType,
+ class CastLhs, class CastRhs,
+ ResultType (*Callback)(SomeLhs&, SomeRhs&)>
+struct FnDispatcherHelper
+{
+ static ResultType Trampoline(BaseLhs& lhs, BaseRhs& rhs)
{
- template <class BaseLhs, class BaseRhs,
- class SomeLhs, class SomeRhs,
- typename ResultType,
- class CastLhs, class CastRhs,
- ResultType (*Callback)(SomeLhs&, SomeRhs&)>
- struct FnDispatcherHelper
- {
- static ResultType Trampoline(BaseLhs& lhs, BaseRhs& rhs)
- {
- return Callback(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
- }
- static ResultType TrampolineR(BaseRhs& rhs, BaseLhs& lhs)
- {
- return Trampoline(lhs, rhs);
- }
- };
+ return Callback(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
+ }
+ static ResultType TrampolineR(BaseRhs& rhs, BaseLhs& lhs)
+ {
+ return Trampoline(lhs, rhs);
}
+};
+}
////////////////////////////////////////////////////////////////////////////////
// class template FnDispatcher
@@ -247,102 +247,102 @@ namespace Loki
// Features automated conversions
////////////////////////////////////////////////////////////////////////////////
- template <class BaseLhs, class BaseRhs = BaseLhs,
- typename ResultType = void,
- template <class, class> class CastingPolicy = DynamicCaster,
- template <class, class, class, class>
- class DispatcherBackend = BasicDispatcher>
- class FnDispatcher
+template <class BaseLhs, class BaseRhs = BaseLhs,
+ typename ResultType = void,
+ template <class, class> class CastingPolicy = DynamicCaster,
+ template <class, class, class, class>
+ class DispatcherBackend = BasicDispatcher>
+class FnDispatcher
+{
+ DispatcherBackend<BaseLhs, BaseRhs, ResultType,
+ ResultType (*)(BaseLhs&, BaseRhs&)> backEnd_;
+
+public:
+ template <class SomeLhs, class SomeRhs>
+ void Add(ResultType (*pFun)(BaseLhs&, BaseRhs&))
+ {
+ return backEnd_.template Add<SomeLhs, SomeRhs>(pFun);
+ }
+
+ template <class SomeLhs, class SomeRhs,
+ ResultType (*callback)(SomeLhs&, SomeRhs&)>
+ void Add()
{
- DispatcherBackend<BaseLhs, BaseRhs, ResultType,
- ResultType (*)(BaseLhs&, BaseRhs&)> backEnd_;
-
- public:
- template <class SomeLhs, class SomeRhs>
- void Add(ResultType (*pFun)(BaseLhs&, BaseRhs&))
- {
- return backEnd_.template Add<SomeLhs, SomeRhs>(pFun);
- }
-
- template <class SomeLhs, class SomeRhs,
- ResultType (*callback)(SomeLhs&, SomeRhs&)>
- void Add()
- {
typedef Private::FnDispatcherHelper<
- BaseLhs, BaseRhs,
- SomeLhs, SomeRhs,
- ResultType,
- CastingPolicy<SomeLhs,BaseLhs>,
- CastingPolicy<SomeRhs,BaseRhs>,
- callback> Local;
-
- Add<SomeLhs, SomeRhs>(&Local::Trampoline);
- }
-
- template <class SomeLhs, class SomeRhs,
- ResultType (*callback)(SomeLhs&, SomeRhs&),
- bool symmetric>
- void Add(bool = true) // [gcc] dummy bool
- {
+ BaseLhs, BaseRhs,
+ SomeLhs, SomeRhs,
+ ResultType,
+ CastingPolicy<SomeLhs,BaseLhs>,
+ CastingPolicy<SomeRhs,BaseRhs>,
+ callback> Local;
+
+ Add<SomeLhs, SomeRhs>(&Local::Trampoline);
+ }
+
+ template <class SomeLhs, class SomeRhs,
+ ResultType (*callback)(SomeLhs&, SomeRhs&),
+ bool symmetric>
+ void Add(bool = true) // [gcc] dummy bool
+ {
typedef Private::FnDispatcherHelper<
- BaseLhs, BaseRhs,
- SomeLhs, SomeRhs,
- ResultType,
- CastingPolicy<SomeLhs,BaseLhs>,
- CastingPolicy<SomeRhs,BaseRhs>,
- callback> Local;
-
- Add<SomeLhs, SomeRhs>(&Local::Trampoline);
- if (symmetric)
- {
- Add<SomeRhs, SomeLhs>(&Local::TrampolineR);
- }
- }
-
- template <class SomeLhs, class SomeRhs>
- void Remove()
+ BaseLhs, BaseRhs,
+ SomeLhs, SomeRhs,
+ ResultType,
+ CastingPolicy<SomeLhs,BaseLhs>,
+ CastingPolicy<SomeRhs,BaseRhs>,
+ callback> Local;
+
+ Add<SomeLhs, SomeRhs>(&Local::Trampoline);
+ if (symmetric)
{
- backEnd_.template Remove<SomeLhs, SomeRhs>();
+ Add<SomeRhs, SomeLhs>(&Local::TrampolineR);
}
+ }
- ResultType Go(BaseLhs& lhs, BaseRhs& rhs)
- {
- return backEnd_.Go(lhs, rhs);
- }
- };
+ template <class SomeLhs, class SomeRhs>
+ void Remove()
+ {
+ backEnd_.template Remove<SomeLhs, SomeRhs>();
+ }
+
+ ResultType Go(BaseLhs& lhs, BaseRhs& rhs)
+ {
+ return backEnd_.Go(lhs, rhs);
+ }
+};
////////////////////////////////////////////////////////////////////////////////
// class template FunctorDispatcherAdaptor
// permits use of FunctorDispatcher under gcc.2.95.2/3
///////////////////////////////////////////////////////////////////////////////
- namespace Private
+namespace Private
+{
+template <class BaseLhs, class BaseRhs,
+ class SomeLhs, class SomeRhs,
+ typename ResultType,
+ class CastLhs, class CastRhs,
+ class Fun, bool SwapArgs>
+class FunctorDispatcherHelper
+{
+ Fun fun_;
+ ResultType Fire(BaseLhs& lhs, BaseRhs& rhs,Int2Type<false>)
{
- template <class BaseLhs, class BaseRhs,
- class SomeLhs, class SomeRhs,
- typename ResultType,
- class CastLhs, class CastRhs,
- class Fun, bool SwapArgs>
- class FunctorDispatcherHelper
- {
- Fun fun_;
- ResultType Fire(BaseLhs& lhs, BaseRhs& rhs,Int2Type<false>)
- {
- return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
- }
- ResultType Fire(BaseLhs& rhs, BaseRhs& lhs,Int2Type<true>)
- {
- return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
- }
- public:
- FunctorDispatcherHelper(const Fun& fun) : fun_(fun) {}
-
- ResultType operator()(BaseLhs& lhs, BaseRhs& rhs)
- {
- return Fire(lhs,rhs,Int2Type<SwapArgs>());
- }
- };
+ return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
}
+ ResultType Fire(BaseLhs& rhs, BaseRhs& lhs,Int2Type<true>)
+ {
+ return fun_(CastLhs::Cast(lhs), CastRhs::Cast(rhs));
+ }
+public:
+ FunctorDispatcherHelper(const Fun& fun) : fun_(fun) {}
+
+ ResultType operator()(BaseLhs& lhs, BaseRhs& rhs)
+ {
+ return Fire(lhs,rhs,Int2Type<SwapArgs>());
+ }
+};
+}
////////////////////////////////////////////////////////////////////////////////
// class template FunctorDispatcher
@@ -350,63 +350,63 @@ namespace Loki
// Features automated casting
////////////////////////////////////////////////////////////////////////////////
- template <class BaseLhs, class BaseRhs = BaseLhs,
- typename ResultType = void,
- template <class, class> class CastingPolicy = DynamicCaster,
- template <class, class, class, class>
- class DispatcherBackend = BasicDispatcher>
- class FunctorDispatcher
- {
- typedef LOKI_TYPELIST_2(BaseLhs&, BaseRhs&) ArgsList;
- typedef Functor<ResultType, ArgsList, LOKI_DEFAULT_THREADING> FunctorType;
+template <class BaseLhs, class BaseRhs = BaseLhs,
+ typename ResultType = void,
+ template <class, class> class CastingPolicy = DynamicCaster,
+ template <class, class, class, class>
+ class DispatcherBackend = BasicDispatcher>
+class FunctorDispatcher
+{
+ typedef LOKI_TYPELIST_2(BaseLhs&, BaseRhs&) ArgsList;
+ typedef Functor<ResultType, ArgsList, LOKI_DEFAULT_THREADING> FunctorType;
- DispatcherBackend<BaseLhs, BaseRhs, ResultType, FunctorType> backEnd_;
+ DispatcherBackend<BaseLhs, BaseRhs, ResultType, FunctorType> backEnd_;
- public:
- template <class SomeLhs, class SomeRhs, class Fun>
- void Add(const Fun& fun)
- {
- typedef Private::FunctorDispatcherHelper<
- BaseLhs, BaseRhs,
- SomeLhs, SomeRhs,
- ResultType,
- CastingPolicy<SomeLhs, BaseLhs>,
- CastingPolicy<SomeRhs, BaseRhs>,
- Fun, false> Adapter;
-
- backEnd_.template Add<SomeLhs, SomeRhs>(FunctorType(Adapter(fun)));
+public:
+ template <class SomeLhs, class SomeRhs, class Fun>
+ void Add(const Fun& fun)
+ {
+ typedef Private::FunctorDispatcherHelper<
+ BaseLhs, BaseRhs,
+ SomeLhs, SomeRhs,
+ ResultType,
+ CastingPolicy<SomeLhs, BaseLhs>,
+ CastingPolicy<SomeRhs, BaseRhs>,
+ Fun, false> Adapter;
+
+ backEnd_.template Add<SomeLhs, SomeRhs>(FunctorType(Adapter(fun)));
}
- template <class SomeLhs, class SomeRhs, bool symmetric, class Fun>
- void Add(const Fun& fun)
- {
+ template <class SomeLhs, class SomeRhs, bool symmetric, class Fun>
+ void Add(const Fun& fun)
+ {
Add<SomeLhs,SomeRhs>(fun);
if (symmetric)
{
- // Note: symmetry only makes sense where BaseLhs==BaseRhs
- typedef Private::FunctorDispatcherHelper<
- BaseLhs, BaseLhs,
- SomeLhs, SomeRhs,
- ResultType,
- CastingPolicy<SomeLhs, BaseLhs>,
- CastingPolicy<SomeRhs, BaseLhs>,
- Fun, true> AdapterR;
-
- backEnd_.template Add<SomeRhs, SomeLhs>(FunctorType(AdapterR(fun)));
- }
- }
-
- template <class SomeLhs, class SomeRhs>
- void Remove()
- {
- backEnd_.template Remove<SomeLhs, SomeRhs>();
+ // Note: symmetry only makes sense where BaseLhs==BaseRhs
+ typedef Private::FunctorDispatcherHelper<
+ BaseLhs, BaseLhs,
+ SomeLhs, SomeRhs,
+ ResultType,
+ CastingPolicy<SomeLhs, BaseLhs>,
+ CastingPolicy<SomeRhs, BaseLhs>,
+ Fun, true> AdapterR;
+
+ backEnd_.template Add<SomeRhs, SomeLhs>(FunctorType(AdapterR(fun)));
}
+ }
- ResultType Go(BaseLhs& lhs, BaseRhs& rhs)
- {
- return backEnd_.Go(lhs, rhs);
- }
- };
+ template <class SomeLhs, class SomeRhs>
+ void Remove()
+ {
+ backEnd_.template Remove<SomeLhs, SomeRhs>();
+ }
+
+ ResultType Go(BaseLhs& lhs, BaseRhs& rhs)
+ {
+ return backEnd_.Go(lhs, rhs);
+ }
+};
} // namespace Loki
diff --git a/shared/loki/NullType.h b/shared/loki/NullType.h
index 9403901a..8a4bb008 100644
--- a/shared/loki/NullType.h
+++ b/shared/loki/NullType.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_NULLTYPE_INC_
@@ -23,11 +23,11 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
// class NullType
// Used as a placeholder for "no type here"
-// Useful as an end marker in typelists
+// Useful as an end marker in typelists
////////////////////////////////////////////////////////////////////////////////
- class NullType {};
-
+class NullType {};
+
} // namespace Loki
diff --git a/shared/loki/OrderedStatic.h b/shared/loki/OrderedStatic.h
index 6eaa20b9..0f26b6e0 100644
--- a/shared/loki/OrderedStatic.h
+++ b/shared/loki/OrderedStatic.h
@@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
// The Loki Library
// Copyright (c) 2005 Peter Kümmel
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_ORDEREDSTATIC_INC_
@@ -27,197 +27,197 @@
namespace Loki
{
- namespace Private
+namespace Private
+{
+////////////////////////////////////////////////////////////////////////////////
+// polymorph base class for OrderedStatic template,
+// necessary because of the creator
+////////////////////////////////////////////////////////////////////////////////
+class LOKI_EXPORT OrderedStaticCreatorFunc
+{
+public:
+ virtual void createObject() = 0;
+
+protected:
+ OrderedStaticCreatorFunc();
+ virtual ~OrderedStaticCreatorFunc();
+
+private:
+ OrderedStaticCreatorFunc(const OrderedStaticCreatorFunc&);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// template base clase for OrderedStatic template,
+// common for all specializations
+////////////////////////////////////////////////////////////////////////////////
+template<class T>
+class OrderedStaticBase : public OrderedStaticCreatorFunc
+{
+public:
+ T& operator*()
{
- ////////////////////////////////////////////////////////////////////////////////
- // polymorph base class for OrderedStatic template,
- // necessary because of the creator
- ////////////////////////////////////////////////////////////////////////////////
- class LOKI_EXPORT OrderedStaticCreatorFunc
- {
- public:
- virtual void createObject() = 0;
-
- protected:
- OrderedStaticCreatorFunc();
- virtual ~OrderedStaticCreatorFunc();
-
- private:
- OrderedStaticCreatorFunc(const OrderedStaticCreatorFunc&);
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // template base clase for OrderedStatic template,
- // common for all specializations
- ////////////////////////////////////////////////////////////////////////////////
- template<class T>
- class OrderedStaticBase : public OrderedStaticCreatorFunc
- {
- public:
- T& operator*()
- {
- return *val_;
- }
-
- T* operator->()
- {
- return val_;
- }
-
- protected:
-
- OrderedStaticBase(unsigned int longevity) : val_(0), longevity_(longevity)
- {
- }
-
- virtual ~OrderedStaticBase()
- {
- }
-
- void SetLongevity(T* ptr)
- {
- val_=ptr;
- Loki::SetLongevity(val_,longevity_);
- }
-
- private:
- OrderedStaticBase();
- OrderedStaticBase(const OrderedStaticBase&);
- OrderedStaticBase& operator=(const OrderedStaticBase&);
- T* val_;
- unsigned int longevity_;
-
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // OrderedStaticManagerClass implements details
- // OrderedStaticManager is then defined as a Singleton
- ////////////////////////////////////////////////////////////////////////////////
- class LOKI_EXPORT OrderedStaticManagerClass
- {
- public:
- OrderedStaticManagerClass();
- virtual ~OrderedStaticManagerClass();
-
- typedef void (OrderedStaticCreatorFunc::*Creator)();
-
- void createObjects();
- void registerObject(unsigned int longevity,OrderedStaticCreatorFunc*,Creator);
-
- private:
- OrderedStaticManagerClass(const OrderedStaticManagerClass&);
- OrderedStaticManagerClass& operator=(const OrderedStaticManagerClass&);
-
- struct Data
- {
- Data(unsigned int,OrderedStaticCreatorFunc*, Creator);
- unsigned int longevity;
- OrderedStaticCreatorFunc* object;
- Creator creator;
- };
-
- std::vector<Data> staticObjects_;
- unsigned int max_longevity_;
- unsigned int min_longevity_;
- };
-
- }// namespace Private
-
- ////////////////////////////////////////////////////////////////////////////////
- // OrderedStaticManager is only a Singleton typedef
- ////////////////////////////////////////////////////////////////////////////////
-
- typedef Loki::SingletonHolder
- <
- Loki::Private::OrderedStaticManagerClass,
- Loki::CreateUsingNew,
- Loki::NoDestroy,
- Loki::SingleThreaded
- >
- OrderedStaticManager;
-
- ////////////////////////////////////////////////////////////////////////////////
- // template OrderedStatic template:
- // L : longevity
- // T : object type
- // TList : creator parameters
- ////////////////////////////////////////////////////////////////////////////////
-
- template<unsigned int L, class T, class TList = Loki::NullType>
- class OrderedStatic;
-
-
- ////////////////////////////////////////////////////////////////////////////////
- // OrderedStatic specializations
- ////////////////////////////////////////////////////////////////////////////////
-
- template<unsigned int L, class T>
- class OrderedStatic<L, T, Loki::NullType> : public Private::OrderedStaticBase<T>
+ return *val_;
+ }
+
+ T* operator->()
{
- public:
- OrderedStatic() : Private::OrderedStaticBase<T>(L)
- {
- OrderedStaticManager::Instance().registerObject
- (L,this,&Private::OrderedStaticCreatorFunc::createObject);
- }
-
- void createObject()
- {
- Private::OrderedStaticBase<T>::SetLongevity(new T);
- }
-
- private:
- OrderedStatic(const OrderedStatic&);
- OrderedStatic& operator=(const OrderedStatic&);
- };
+ return val_;
+ }
- template<unsigned int L, class T, typename P1>
- class OrderedStatic<L, T, Loki::Seq<P1> > : public Private::OrderedStaticBase<T>
+protected:
+
+ OrderedStaticBase(unsigned int longevity) : val_(0), longevity_(longevity)
{
- public:
- OrderedStatic(P1 p) : Private::OrderedStaticBase<T>(L), para_(p)
- {
- OrderedStaticManager::Instance().registerObject
- (L,this,&Private::OrderedStaticCreatorFunc::createObject);
- }
-
- void createObject()
- {
- Private::OrderedStaticBase<T>::SetLongevity(new T(para_));
- }
-
- private:
- OrderedStatic();
- OrderedStatic(const OrderedStatic&);
- OrderedStatic& operator=(const OrderedStatic&);
- P1 para_;
- };
+ }
- template<unsigned int L, class T, typename P1>
- class OrderedStatic<L, T, P1(*)() > : public Private::OrderedStaticBase<T>
+ virtual ~OrderedStaticBase()
{
- public:
-
- typedef P1(*Func)();
-
- OrderedStatic(Func p) : Private::OrderedStaticBase<T>(L), para_(p)
- {
- OrderedStaticManager::Instance().registerObject
- (L,this,&Private::OrderedStaticCreatorFunc::createObject);
- }
-
- void createObject()
- {
- Private::OrderedStaticBase<T>::SetLongevity(new T(para_()));
- }
-
- private:
- OrderedStatic();
- OrderedStatic(const OrderedStatic&);
- OrderedStatic& operator=(const OrderedStatic&);
- Func para_;
+ }
+
+ void SetLongevity(T* ptr)
+ {
+ val_=ptr;
+ Loki::SetLongevity(val_,longevity_);
+ }
+
+private:
+ OrderedStaticBase();
+ OrderedStaticBase(const OrderedStaticBase&);
+ OrderedStaticBase& operator=(const OrderedStaticBase&);
+ T* val_;
+ unsigned int longevity_;
+
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// OrderedStaticManagerClass implements details
+// OrderedStaticManager is then defined as a Singleton
+////////////////////////////////////////////////////////////////////////////////
+class LOKI_EXPORT OrderedStaticManagerClass
+{
+public:
+ OrderedStaticManagerClass();
+ virtual ~OrderedStaticManagerClass();
+
+ typedef void (OrderedStaticCreatorFunc::*Creator)();
+
+ void createObjects();
+ void registerObject(unsigned int longevity,OrderedStaticCreatorFunc*,Creator);
+
+private:
+ OrderedStaticManagerClass(const OrderedStaticManagerClass&);
+ OrderedStaticManagerClass& operator=(const OrderedStaticManagerClass&);
+
+ struct Data
+ {
+ Data(unsigned int,OrderedStaticCreatorFunc*, Creator);
+ unsigned int longevity;
+ OrderedStaticCreatorFunc* object;
+ Creator creator;
};
+ std::vector<Data> staticObjects_;
+ unsigned int max_longevity_;
+ unsigned int min_longevity_;
+};
+
+}// namespace Private
+
+////////////////////////////////////////////////////////////////////////////////
+// OrderedStaticManager is only a Singleton typedef
+////////////////////////////////////////////////////////////////////////////////
+
+typedef Loki::SingletonHolder
+<
+Loki::Private::OrderedStaticManagerClass,
+ Loki::CreateUsingNew,
+ Loki::NoDestroy,
+ Loki::SingleThreaded
+ >
+ OrderedStaticManager;
+
+////////////////////////////////////////////////////////////////////////////////
+// template OrderedStatic template:
+// L : longevity
+// T : object type
+// TList : creator parameters
+////////////////////////////////////////////////////////////////////////////////
+
+template<unsigned int L, class T, class TList = Loki::NullType>
+class OrderedStatic;
+
+
+////////////////////////////////////////////////////////////////////////////////
+// OrderedStatic specializations
+////////////////////////////////////////////////////////////////////////////////
+
+template<unsigned int L, class T>
+class OrderedStatic<L, T, Loki::NullType> : public Private::OrderedStaticBase<T>
+{
+public:
+ OrderedStatic() : Private::OrderedStaticBase<T>(L)
+ {
+ OrderedStaticManager::Instance().registerObject
+ (L,this,&Private::OrderedStaticCreatorFunc::createObject);
+ }
+
+ void createObject()
+ {
+ Private::OrderedStaticBase<T>::SetLongevity(new T);
+ }
+
+private:
+ OrderedStatic(const OrderedStatic&);
+ OrderedStatic& operator=(const OrderedStatic&);
+};
+
+template<unsigned int L, class T, typename P1>
+class OrderedStatic<L, T, Loki::Seq<P1> > : public Private::OrderedStaticBase<T>
+{
+public:
+ OrderedStatic(P1 p) : Private::OrderedStaticBase<T>(L), para_(p)
+ {
+ OrderedStaticManager::Instance().registerObject
+ (L,this,&Private::OrderedStaticCreatorFunc::createObject);
+ }
+
+ void createObject()
+ {
+ Private::OrderedStaticBase<T>::SetLongevity(new T(para_));
+ }
+
+private:
+ OrderedStatic();
+ OrderedStatic(const OrderedStatic&);
+ OrderedStatic& operator=(const OrderedStatic&);
+ P1 para_;
+};
+
+template<unsigned int L, class T, typename P1>
+class OrderedStatic<L, T, P1(*)() > : public Private::OrderedStaticBase<T>
+{
+public:
+
+ typedef P1(*Func)();
+
+ OrderedStatic(Func p) : Private::OrderedStaticBase<T>(L), para_(p)
+ {
+ OrderedStaticManager::Instance().registerObject
+ (L,this,&Private::OrderedStaticCreatorFunc::createObject);
+ }
+
+ void createObject()
+ {
+ Private::OrderedStaticBase<T>::SetLongevity(new T(para_()));
+ }
+
+private:
+ OrderedStatic();
+ OrderedStatic(const OrderedStatic&);
+ OrderedStatic& operator=(const OrderedStatic&);
+ Func para_;
+};
+
}// namespace Loki
diff --git a/shared/loki/Pimpl.h b/shared/loki/Pimpl.h
index ed0d1c7b..788f76d8 100644
--- a/shared/loki/Pimpl.h
+++ b/shared/loki/Pimpl.h
@@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
// The Loki Library
// Copyright (c) 2006 Peter Kümmel
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_PIMPL_INC_
@@ -15,7 +15,7 @@
// $Id: Pimpl.h 751 2006-10-17 19:50:37Z syntheticpp $
-/// \defgroup PimplGroup Pimpl
+/// \defgroup PimplGroup Pimpl
#ifndef LOKI_INHERITED_PIMPL_NAME
#define LOKI_INHERITED_PIMPL_NAME d
@@ -28,170 +28,170 @@
namespace Loki
{
- //////////////////////////////////////////
- /// \class ConstPropPtr
- ///
- /// \ingroup PimplGroup
- /// Simple const propagating smart pointer
- /// Is the default smart pointer of Pimpl.
- //////////////////////////////////////////
+//////////////////////////////////////////
+/// \class ConstPropPtr
+///
+/// \ingroup PimplGroup
+/// Simple const propagating smart pointer
+/// Is the default smart pointer of Pimpl.
+//////////////////////////////////////////
- template<class T>
- struct ConstPropPtr
+template<class T>
+struct ConstPropPtr
+{
+ explicit ConstPropPtr(T* p) : ptr_(p) {}
+ ~ConstPropPtr() { delete ptr_; ptr_ = 0; }
+ T* operator->() { return ptr_; }
+ T& operator*() { return *ptr_; }
+ const T* operator->() const { return ptr_; }
+ const T& operator*() const { return *ptr_; }
+
+private:
+ ConstPropPtr();
+ ConstPropPtr(const ConstPropPtr&);
+ ConstPropPtr& operator=(const ConstPropPtr&);
+ T* ptr_;
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+/// \class Pimpl
+///
+/// \ingroup PimplGroup
+///
+/// Implements the Pimpl idiom. It's a wrapper for a smart pointer which
+/// automatically creates and deletes the implementation object and adds
+/// const propagation to the smart pointer.
+///
+/// \par Usage
+/// see test/Pimpl
+////////////////////////////////////////////////////////////////////////////////
+
+template
+<
+class T,
+ typename Pointer = ConstPropPtr<T>
+ >
+class Pimpl
+{
+public:
+
+ typedef T Impl;
+
+ Pimpl() : ptr_(new T)
+ {}
+
+ ~Pimpl()
{
- explicit ConstPropPtr(T* p) : ptr_(p) {}
- ~ConstPropPtr() { delete ptr_; ptr_ = 0; }
- T* operator->() { return ptr_; }
- T& operator*() { return *ptr_; }
- const T* operator->() const { return ptr_; }
- const T& operator*() const { return *ptr_; }
-
- private:
- ConstPropPtr();
- ConstPropPtr(const ConstPropPtr&);
- ConstPropPtr& operator=(const ConstPropPtr&);
- T* ptr_;
- };
+ // Don't compile with incomplete type
+ //
+ // If compilation breaks here make sure
+ // the compiler does not auto-generate the
+ // destructor of the class hosting the pimpl:
+ // - implement the destructor of the class
+ // - don't inline the destructor
+ typedef char T_must_be_defined[sizeof(T) ? 1 : -1 ];
+ }
+
+
+ T* operator->()
+ {
+ return ptr_.operator->();
+ }
+ T& operator*()
+ {
+ return ptr_.operator*();
+ }
- ////////////////////////////////////////////////////////////////////////////////
- /// \class Pimpl
- ///
- /// \ingroup PimplGroup
- ///
- /// Implements the Pimpl idiom. It's a wrapper for a smart pointer which
- /// automatically creates and deletes the implementation object and adds
- /// const propagation to the smart pointer.
- ///
- /// \par Usage
- /// see test/Pimpl
- ////////////////////////////////////////////////////////////////////////////////
-
- template
- <
- class T,
- typename Pointer = ConstPropPtr<T>
- >
- class Pimpl
+ const T* operator->() const
{
- public:
+ return ptr_.operator->();
+ }
- typedef T Impl;
+ const T& operator*() const
+ {
+ return ptr_.operator*();
+ }
- Pimpl() : ptr_(new T)
- {}
+ Pointer& wrapped()
+ {
+ return ptr_;
+ }
- ~Pimpl()
- {
- // Don't compile with incomplete type
- //
- // If compilation breaks here make sure
- // the compiler does not auto-generate the
- // destructor of the class hosting the pimpl:
- // - implement the destructor of the class
- // - don't inline the destructor
- typedef char T_must_be_defined[sizeof(T) ? 1 : -1 ];
- }
-
-
- T* operator->()
- {
- return ptr_.operator->();
- }
-
- T& operator*()
- {
- return ptr_.operator*();
- }
-
- const T* operator->() const
- {
- return ptr_.operator->();
- }
-
- const T& operator*() const
- {
- return ptr_.operator*();
- }
-
- Pointer& wrapped()
- {
- return ptr_;
- }
-
- const Pointer& wrapped() const
- {
- return ptr_;
- }
-
-
- private:
- Pimpl(const Pimpl&);
- Pimpl& operator=(const Pimpl&);
-
- Pointer ptr_;
- };
+ const Pointer& wrapped() const
+ {
+ return ptr_;
+ }
- template<class T, typename Pointer = ConstPropPtr<T> >
- struct PimplOwner
- {
- Pimpl<T,Pointer> LOKI_INHERITED_PIMPL_NAME;
- };
+private:
+ Pimpl(const Pimpl&);
+ Pimpl& operator=(const Pimpl&);
+ Pointer ptr_;
+};
- //////////////////////////////////////////
- /// \class ImplOf
- ///
- /// \ingroup PimplGroup
- /// Convenience template for the
- /// implementations which Pimpl points to.
- //////////////////////////////////////////
- template<class T>
- struct ImplOf;
+template<class T, typename Pointer = ConstPropPtr<T> >
+struct PimplOwner
+{
+ Pimpl<T,Pointer> LOKI_INHERITED_PIMPL_NAME;
+};
- //////////////////////////////////////////
- /// \class PImplOf
- ///
- /// \ingroup PimplGroup
- /// Convenience template which uses ImplOf
- /// as implementation structure
- //////////////////////////////////////////
+//////////////////////////////////////////
+/// \class ImplOf
+///
+/// \ingroup PimplGroup
+/// Convenience template for the
+/// implementations which Pimpl points to.
+//////////////////////////////////////////
+template<class T>
+struct ImplOf;
- template<class T, template<class> class Ptr = ConstPropPtr>
- struct PimplOf
- {
- typedef T Impl;
- // declare pimpl
- typedef Pimpl<ImplOf<T>, Ptr<ImplOf<T> > > Type;
+//////////////////////////////////////////
+/// \class PImplOf
+///
+/// \ingroup PimplGroup
+/// Convenience template which uses ImplOf
+/// as implementation structure
+//////////////////////////////////////////
- // inherit pimpl
- typedef PimplOwner<ImplOf<T>, Ptr<ImplOf<T> > > Owner;
- };
+template<class T, template<class> class Ptr = ConstPropPtr>
+struct PimplOf
+{
+ typedef T Impl;
- template<class T, class UsedPimpl = typename PimplOf<T>::Type >
- struct RimplOf
- {
- typedef typename UsedPimpl::Impl & Type;
+ // declare pimpl
+ typedef Pimpl<ImplOf<T>, Ptr<ImplOf<T> > > Type;
- class Owner
- {
- UsedPimpl pimpl;
+ // inherit pimpl
+ typedef PimplOwner<ImplOf<T>, Ptr<ImplOf<T> > > Owner;
+};
- public:
- Owner() : LOKI_INHERITED_RIMPL_NAME(*pimpl)
- {}
- Type LOKI_INHERITED_RIMPL_NAME;
- };
+template<class T, class UsedPimpl = typename PimplOf<T>::Type >
+struct RimplOf
+{
+ typedef typename UsedPimpl::Impl& Type;
+
+ class Owner
+ {
+ UsedPimpl pimpl;
+
+ public:
+ Owner() : LOKI_INHERITED_RIMPL_NAME(*pimpl)
+ {}
+ Type LOKI_INHERITED_RIMPL_NAME;
};
-
+
+};
+
}
#endif // end file guardian
diff --git a/shared/loki/RefToValue.h b/shared/loki/RefToValue.h
index 248de792..3f7ecfef 100644
--- a/shared/loki/RefToValue.h
+++ b/shared/loki/RefToValue.h
@@ -2,12 +2,12 @@
// The Loki Library
// Copyright (c) 2006 Richard Sposato
// Copyright (c) 2006 Peter Kümmel
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The authors make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The authors make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_REFTOVALUE_INC_
@@ -19,50 +19,50 @@
namespace Loki
{
- ////////////////////////////////////////////////////////////////////////////////
- /// \class RefToValue
- ///
- /// \ingroup SmartPointerGroup
- /// Transports a reference as a value
- /// Serves to implement the Colvin/Gibbons trick for SmartPtr/ScopeGuard
- ////////////////////////////////////////////////////////////////////////////////
-
- template <class T>
- class RefToValue
- {
- public:
-
- RefToValue(T& ref) : ref_(ref)
- {}
-
- RefToValue(const RefToValue& rhs) : ref_(rhs.ref_)
- {}
-
- operator T& () const
- {
- return ref_;
- }
-
- private:
- // Disable - not implemented
- RefToValue();
- RefToValue& operator=(const RefToValue&);
-
- T& ref_;
- };
-
-
- ////////////////////////////////////////////////////////////////////////////////
- /// \ingroup ExceptionGroup
- /// RefToValue creator.
- ////////////////////////////////////////////////////////////////////////////////
-
- template <class T>
- inline RefToValue<T> ByRef(T& t)
+////////////////////////////////////////////////////////////////////////////////
+/// \class RefToValue
+///
+/// \ingroup SmartPointerGroup
+/// Transports a reference as a value
+/// Serves to implement the Colvin/Gibbons trick for SmartPtr/ScopeGuard
+////////////////////////////////////////////////////////////////////////////////
+
+template <class T>
+class RefToValue
+{
+public:
+
+ RefToValue(T& ref) : ref_(ref)
+ {}
+
+ RefToValue(const RefToValue& rhs) : ref_(rhs.ref_)
+ {}
+
+ operator T& () const
{
- return RefToValue<T>(t);
- }
-
+ return ref_;
+ }
+
+private:
+ // Disable - not implemented
+ RefToValue();
+ RefToValue& operator=(const RefToValue&);
+
+ T& ref_;
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup ExceptionGroup
+/// RefToValue creator.
+////////////////////////////////////////////////////////////////////////////////
+
+template <class T>
+inline RefToValue<T> ByRef(T& t)
+{
+ return RefToValue<T>(t);
+}
+
}
diff --git a/shared/loki/Register.h b/shared/loki/Register.h
index 0ad014ab..0edf4a37 100644
--- a/shared/loki/Register.h
+++ b/shared/loki/Register.h
@@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
// The Loki Library
// Copyright (c) 2006 Peter Kümmel
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_REGISTER_INC_
@@ -18,98 +18,98 @@
#include "TypeManip.h"
#include "HierarchyGenerators.h"
-/// \defgroup RegisterGroup Register
+/// \defgroup RegisterGroup Register
namespace Loki
{
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Helper classes/functions for RegisterByCreateSet
- //
- ////////////////////////////////////////////////////////////////////////////////
-
- ////////////////////////////////////////////////////////////////////////////////
- /// \ingroup RegisterGroup
- /// Must be specialized be the user
- ////////////////////////////////////////////////////////////////////////////////
- template<class t> bool RegisterFunction();
-
- ////////////////////////////////////////////////////////////////////////////////
- /// \ingroup RegisterGroup
- /// Must be specialized be the user
- ////////////////////////////////////////////////////////////////////////////////
- template<class t> bool UnRegisterFunction();
-
- namespace Private
- {
- template<class T>
- struct RegisterOnCreate
- {
- RegisterOnCreate() { RegisterFunction<T>(); }
- };
-
- template<class T>
- struct UnRegisterOnDelete
- {
- ~UnRegisterOnDelete() { UnRegisterFunction<T>(); }
- };
-
- template<class T>
- struct RegisterOnCreateElement
- {
- RegisterOnCreate<T> registerObj;
- };
-
- template<class T>
- struct UnRegisterOnDeleteElement
- {
- UnRegisterOnDelete<T> unregisterObj;
- };
- }
-
- ////////////////////////////////////////////////////////////////////////////////
- /// \class RegisterOnCreateSet
- ///
- /// \ingroup RegisterGroup
- /// Implements a generic register class which registers classes of a typelist
- ///
- /// \par Usage
- /// see test/Register
- ////////////////////////////////////////////////////////////////////////////////
-
- template<typename ElementList>
- struct RegisterOnCreateSet
+////////////////////////////////////////////////////////////////////////////////
+//
+// Helper classes/functions for RegisterByCreateSet
+//
+////////////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup RegisterGroup
+/// Must be specialized be the user
+////////////////////////////////////////////////////////////////////////////////
+template<class t> bool RegisterFunction();
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup RegisterGroup
+/// Must be specialized be the user
+////////////////////////////////////////////////////////////////////////////////
+template<class t> bool UnRegisterFunction();
+
+namespace Private
+{
+template<class T>
+struct RegisterOnCreate
+{
+ RegisterOnCreate() { RegisterFunction<T>(); }
+};
+
+template<class T>
+struct UnRegisterOnDelete
+{
+ ~UnRegisterOnDelete() { UnRegisterFunction<T>(); }
+};
+
+template<class T>
+struct RegisterOnCreateElement
+{
+ RegisterOnCreate<T> registerObj;
+};
+
+template<class T>
+struct UnRegisterOnDeleteElement
+{
+ UnRegisterOnDelete<T> unregisterObj;
+};
+}
+
+////////////////////////////////////////////////////////////////////////////////
+/// \class RegisterOnCreateSet
+///
+/// \ingroup RegisterGroup
+/// Implements a generic register class which registers classes of a typelist
+///
+/// \par Usage
+/// see test/Register
+////////////////////////////////////////////////////////////////////////////////
+
+template<typename ElementList>
+struct RegisterOnCreateSet
: GenScatterHierarchy<ElementList, Private::RegisterOnCreateElement>
{};
- ////////////////////////////////////////////////////////////////////////////////
- /// \class UnRegisterOnDeleteSet
- ///
- /// \ingroup RegisterGroup
- /// Implements a generic register class which unregisters classes of a typelist
- ///
- /// \par Usage
- /// see test/Register
- ////////////////////////////////////////////////////////////////////////////////
- template<typename ElementList>
- struct UnRegisterOnDeleteSet
+////////////////////////////////////////////////////////////////////////////////
+/// \class UnRegisterOnDeleteSet
+///
+/// \ingroup RegisterGroup
+/// Implements a generic register class which unregisters classes of a typelist
+///
+/// \par Usage
+/// see test/Register
+////////////////////////////////////////////////////////////////////////////////
+template<typename ElementList>
+struct UnRegisterOnDeleteSet
: GenScatterHierarchy<ElementList, Private::UnRegisterOnDeleteElement>
{};
- ////////////////////////////////////////////////////////////////////////////////
- /// \def LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST )
- ///
- /// \ingroup RegisterGroup
- /// Check if CLASS is in the typelist LIST.
- ///
- /// \par Usage
- /// see test/Register
- ////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+/// \def LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST )
+///
+/// \ingroup RegisterGroup
+/// Check if CLASS is in the typelist LIST.
+///
+/// \par Usage
+/// see test/Register
+////////////////////////////////////////////////////////////////////////////////
+
-
-#define LOKI_CONCATE(a,b,c,d) a ## b ## c ## d
+#define LOKI_CONCATE(a,b,c,d) a ## b ## c ## d
#define LOKI_CONCAT(a,b,c,d) LOKI_CONCATE(a,b,c,d)
#define LOKI_CHECK_CLASS_IN_LIST( CLASS , LIST ) \
diff --git a/shared/loki/SPCachedFactory.h b/shared/loki/SPCachedFactory.h
index 71c72644..aab37127 100644
--- a/shared/loki/SPCachedFactory.h
+++ b/shared/loki/SPCachedFactory.h
@@ -4,16 +4,16 @@
//
// Code covered by the MIT License
//
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
//
// The authors make no representations about the suitability of this software
// for any purpose. It is provided "as is" without express or implied warranty.
//
// This code DOES NOT accompany the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
//
////////////////////////////////////////////////////////////////////////////////
@@ -29,8 +29,8 @@
* It as been defined in a separate file because of the many introduced
* dependencies (SmartPtr.h would depend on Functor.h and CachedFactory.h
* would depend on SmartPtr.h). By defining another header you pay for those
- * extra dependencies only if you need it.
- *
+ * extra dependencies only if you need it.
+ *
* This file defines FunctionStorage a new SmartPointer storage policy and
* SmartPointer a new CachedFactory encapsulation policy.
*/
@@ -45,7 +45,7 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
/// \class FunctionStorage
///
-/// \ingroup SmartPointerStorageGroup
+/// \ingroup SmartPointerStorageGroup
/// \brief Implementation of the StoragePolicy used by SmartPtr.
///
/// This storage policy is used by SmartPointer CachedFactory's encapsulation
@@ -58,146 +58,146 @@ namespace Loki
/// the FunctionStorage template to know the full definition of the SmartPtr.
////////////////////////////////////////////////////////////////////////////////
- template <class T>
- class FunctionStorage
+template <class T>
+class FunctionStorage
+{
+public:
+ /// the type of the pointee_ object
+ typedef T* StoredType;
+ /// type used to declare OwnershipPolicy type.
+ typedef T* InitPointerType;
+ /// type returned by operator->
+ typedef T* PointerType;
+ /// type returned by operator*
+ typedef T& ReferenceType;
+ /// type of the Functor to set
+ typedef Functor< void , Seq< void* > > FunctorType;
+
+ FunctionStorage() : pointee_(Default()), functor_()
+ {}
+
+ // The storage policy doesn't initialize the stored pointer
+ // which will be initialized by the OwnershipPolicy's Clone fn
+ FunctionStorage(const FunctionStorage& rsh) : pointee_(0), functor_(rsh.functor_)
+ {}
+
+ template <class U>
+ FunctionStorage(const FunctionStorage<U>& rsh) : pointee_(0), functor_(rsh.functor_)
+ {}
+
+ FunctionStorage(const StoredType& p) : pointee_(p), functor_() {}
+
+ PointerType operator->() const { return pointee_; }
+
+ ReferenceType operator*() const { return *pointee_; }
+
+ void Swap(FunctionStorage& rhs)
+ {
+ std::swap(pointee_, rhs.pointee_);
+ std::swap(functor_, rhs.functor_);
+ }
+
+ /// Sets the callback function to call. You have to specify it or
+ /// the smartPtr will throw a bad_function_call exception.
+ void SetCallBackFunction(const FunctorType& functor)
+ {
+ functor_ = functor;
+ }
+
+ // Accessors
+ template <class F>
+ friend typename FunctionStorage<F>::PointerType GetImpl(const FunctionStorage<F>& sp);
+
+ template <class F>
+ friend const typename FunctionStorage<F>::StoredType& GetImplRef(const FunctionStorage<F>& sp);
+
+ template <class F>
+ friend typename FunctionStorage<F>::StoredType& GetImplRef(FunctionStorage<F>& sp);
+
+protected:
+ // Destroys the data stored
+ // (Destruction might be taken over by the OwnershipPolicy)
+ void Destroy()
+ {
+ functor_(this);
+ }
+
+ // Default value to initialize the pointer
+ static StoredType Default()
+ { return 0; }
+
+private:
+ // Data
+ StoredType pointee_;
+ FunctorType functor_;
+};
+
+template <class T>
+inline typename FunctionStorage<T>::PointerType GetImpl(const FunctionStorage<T>& sp)
+{ return sp.pointee_; }
+
+template <class T>
+inline const typename FunctionStorage<T>::StoredType& GetImplRef(const FunctionStorage<T>& sp)
+{ return sp.pointee_; }
+
+template <class T>
+inline typename FunctionStorage<T>::StoredType& GetImplRef(FunctionStorage<T>& sp)
+{ return sp.pointee_; }
+
+/**
+ * \class SmartPointer
+ * \ingroup EncapsulationPolicyCachedFactoryGroup
+ * \brief Encapsulate the object in a SmartPtr with FunctionStorage policy.
+ *
+ * The object will come back to the Cache as soon as no more SmartPtr are
+ * referencing this object. You can customize the SmartPointer with the standard
+ * SmartPtr policies (OwnershipPolicy, ConversionPolicy, CheckingPolicy,
+ * ConstnessPolicy) but StoragePolicy is forced to FunctionStorage.
+ */
+template
+<
+class AbstractProduct,
+ template <class> class OwnershipPolicy = RefCounted,
+ class ConversionPolicy = DisallowConversion,
+ template <class> class CheckingPolicy = AssertCheck,
+ template<class> class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
+ >
+class SmartPointer
+{
+private:
+ typedef SmartPtr< AbstractProduct,OwnershipPolicy,
+ ConversionPolicy, CheckingPolicy,
+ FunctionStorage, ConstnessPolicy > CallBackSP;
+protected:
+ typedef CallBackSP ProductReturn;
+ SmartPointer() : fun(this, &SmartPointer::smartPointerCallbackFunction) {}
+ virtual ~SmartPointer() {}
+
+ ProductReturn encapsulate(AbstractProduct* pProduct)
+ {
+ CallBackSP SP(pProduct);
+ SP.SetCallBackFunction(fun);
+ return SP;
+ }
+
+ AbstractProduct* release(ProductReturn& pProduct)
+ {
+ return GetImpl(pProduct);
+ }
+
+ const char* name() {return "smart pointer";}
+
+private:
+ SmartPointer& operator=(const SmartPointer&);
+ SmartPointer(const SmartPointer&);
+ void smartPointerCallbackFunction(void* pSP)
{
- public:
- /// the type of the pointee_ object
- typedef T* StoredType;
- /// type used to declare OwnershipPolicy type.
- typedef T* InitPointerType;
- /// type returned by operator->
- typedef T* PointerType;
- /// type returned by operator*
- typedef T& ReferenceType;
- /// type of the Functor to set
- typedef Functor< void , Seq< void* > > FunctorType;
-
- FunctionStorage() : pointee_(Default()), functor_()
- {}
-
- // The storage policy doesn't initialize the stored pointer
- // which will be initialized by the OwnershipPolicy's Clone fn
- FunctionStorage(const FunctionStorage& rsh) : pointee_(0), functor_(rsh.functor_)
- {}
-
- template <class U>
- FunctionStorage(const FunctionStorage<U>& rsh) : pointee_(0), functor_(rsh.functor_)
- {}
-
- FunctionStorage(const StoredType& p) : pointee_(p), functor_() {}
-
- PointerType operator->() const { return pointee_; }
-
- ReferenceType operator*() const { return *pointee_; }
-
- void Swap(FunctionStorage& rhs)
- {
- std::swap(pointee_, rhs.pointee_);
- std::swap(functor_, rhs.functor_);
- }
-
- /// Sets the callback function to call. You have to specify it or
- /// the smartPtr will throw a bad_function_call exception.
- void SetCallBackFunction(const FunctorType &functor)
- {
- functor_ = functor;
- }
-
- // Accessors
- template <class F>
- friend typename FunctionStorage<F>::PointerType GetImpl(const FunctionStorage<F>& sp);
-
- template <class F>
- friend const typename FunctionStorage<F>::StoredType& GetImplRef(const FunctionStorage<F>& sp);
-
- template <class F>
- friend typename FunctionStorage<F>::StoredType& GetImplRef(FunctionStorage<F>& sp);
-
- protected:
- // Destroys the data stored
- // (Destruction might be taken over by the OwnershipPolicy)
- void Destroy()
- {
- functor_(this);
- }
-
- // Default value to initialize the pointer
- static StoredType Default()
- { return 0; }
-
- private:
- // Data
- StoredType pointee_;
- FunctorType functor_;
- };
-
- template <class T>
- inline typename FunctionStorage<T>::PointerType GetImpl(const FunctionStorage<T>& sp)
- { return sp.pointee_; }
-
- template <class T>
- inline const typename FunctionStorage<T>::StoredType& GetImplRef(const FunctionStorage<T>& sp)
- { return sp.pointee_; }
-
- template <class T>
- inline typename FunctionStorage<T>::StoredType& GetImplRef(FunctionStorage<T>& sp)
- { return sp.pointee_; }
-
- /**
- * \class SmartPointer
- * \ingroup EncapsulationPolicyCachedFactoryGroup
- * \brief Encapsulate the object in a SmartPtr with FunctionStorage policy.
- *
- * The object will come back to the Cache as soon as no more SmartPtr are
- * referencing this object. You can customize the SmartPointer with the standard
- * SmartPtr policies (OwnershipPolicy, ConversionPolicy, CheckingPolicy,
- * ConstnessPolicy) but StoragePolicy is forced to FunctionStorage.
- */
- template
- <
- class AbstractProduct,
- template <class> class OwnershipPolicy = RefCounted,
- class ConversionPolicy = DisallowConversion,
- template <class> class CheckingPolicy = AssertCheck,
- template<class> class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
- >
- class SmartPointer
- {
- private:
- typedef SmartPtr< AbstractProduct,OwnershipPolicy,
- ConversionPolicy, CheckingPolicy,
- FunctionStorage, ConstnessPolicy > CallBackSP;
- protected:
- typedef CallBackSP ProductReturn;
- SmartPointer() : fun(this, &SmartPointer::smartPointerCallbackFunction) {}
- virtual ~SmartPointer(){}
-
- ProductReturn encapsulate(AbstractProduct* pProduct)
- {
- CallBackSP SP(pProduct);
- SP.SetCallBackFunction(fun);
- return SP;
- }
-
- AbstractProduct* release(ProductReturn &pProduct)
- {
- return GetImpl(pProduct);
- }
-
- const char* name(){return "smart pointer";}
-
- private:
- SmartPointer& operator=(const SmartPointer&);
- SmartPointer(const SmartPointer&);
- void smartPointerCallbackFunction(void* pSP)
- {
- CallBackSP &SP(*reinterpret_cast<CallBackSP*>(pSP));
- ReleaseObject(SP);
- }
- virtual void ReleaseObject(ProductReturn &object)=0;
- const typename CallBackSP::FunctorType fun;
- };
+ CallBackSP& SP(*reinterpret_cast<CallBackSP*>(pSP));
+ ReleaseObject(SP);
+ }
+ virtual void ReleaseObject(ProductReturn& object)=0;
+ const typename CallBackSP::FunctorType fun;
+};
} // namespace Loki
diff --git a/shared/loki/SafeBits.h b/shared/loki/SafeBits.h
index f45065ed..4105f375 100644
--- a/shared/loki/SafeBits.h
+++ b/shared/loki/SafeBits.h
@@ -102,7 +102,7 @@ namespace Loki
/// the template one. The only downside is that instead of compile-time checking
/// of the index argument, it does runtime checking.
#if defined(__SUNPRO_CC) || ( defined(__GNUC__) && (__GNUC__ < 3) )
- #define LOKI_BIT_FIELD_NONTEMPLATE_INIT
+#define LOKI_BIT_FIELD_NONTEMPLATE_INIT
#endif
/// @par Forbidding Conversions.
@@ -118,9 +118,9 @@ template < typename > struct Forbidden_conversion; // This struct must not be d
/// Forward declaration of the field type.
template <
- unsigned int unique_index,
- typename word_t = unsigned long
-> class SafeBitField;
+unsigned int unique_index,
+ typename word_t = unsigned long
+ > class SafeBitField;
////////////////////////////////////////////////////////////////////////////////
/// \class SafeBitConst Bit constants.
@@ -141,9 +141,9 @@ template <
template
<
- unsigned int unique_index,
- typename word_t = unsigned long
->
+unsigned int unique_index,
+ typename word_t = unsigned long
+ >
class SafeBitConst
{
public:
@@ -193,32 +193,32 @@ public:
SafeBitConst( const SafeBitConst& rhs ) : word( rhs.word ) {}
/// Comparison operators which take a constant bit value.
- bool operator == ( const SafeBitConst & rhs ) const { return word == rhs.word; }
- bool operator != ( const SafeBitConst & rhs ) const { return word != rhs.word; }
- bool operator < ( const SafeBitConst & rhs ) const { return word < rhs.word; }
- bool operator > ( const SafeBitConst & rhs ) const { return word > rhs.word; }
- bool operator <= ( const SafeBitConst & rhs ) const { return word <= rhs.word; }
- bool operator >= ( const SafeBitConst & rhs ) const { return word >= rhs.word; }
+ bool operator == ( const SafeBitConst& rhs ) const { return word == rhs.word; }
+ bool operator != ( const SafeBitConst& rhs ) const { return word != rhs.word; }
+ bool operator < ( const SafeBitConst& rhs ) const { return word < rhs.word; }
+ bool operator > ( const SafeBitConst& rhs ) const { return word > rhs.word; }
+ bool operator <= ( const SafeBitConst& rhs ) const { return word <= rhs.word; }
+ bool operator >= ( const SafeBitConst& rhs ) const { return word >= rhs.word; }
/// Comparision operators for mutable bit fields.
- bool operator == ( const field_t & rhs ) const { return word == rhs.word; }
- bool operator != ( const field_t & rhs ) const { return word != rhs.word; }
- bool operator < ( const field_t & rhs ) const { return word < rhs.word; }
- bool operator > ( const field_t & rhs ) const { return word > rhs.word; }
- bool operator <= ( const field_t & rhs ) const { return word <= rhs.word; }
- bool operator >= ( const field_t & rhs ) const { return word >= rhs.word; }
+ bool operator == ( const field_t& rhs ) const { return word == rhs.word; }
+ bool operator != ( const field_t& rhs ) const { return word != rhs.word; }
+ bool operator < ( const field_t& rhs ) const { return word < rhs.word; }
+ bool operator > ( const field_t& rhs ) const { return word > rhs.word; }
+ bool operator <= ( const field_t& rhs ) const { return word <= rhs.word; }
+ bool operator >= ( const field_t& rhs ) const { return word >= rhs.word; }
/// Bitwise operations. Operation-assignment operators are not needed,
/// since bit constants cannot be changed after they are initialized.
- const SafeBitConst operator | ( const SafeBitConst & rhs ) const { return SafeBitConst( word | rhs.word ); }
- const SafeBitConst operator & ( const SafeBitConst & rhs ) const { return SafeBitConst( word & rhs.word ); }
- const SafeBitConst operator ^ ( const SafeBitConst & rhs ) const { return SafeBitConst( word ^ rhs.word ); }
+ const SafeBitConst operator | ( const SafeBitConst& rhs ) const { return SafeBitConst( word | rhs.word ); }
+ const SafeBitConst operator & ( const SafeBitConst& rhs ) const { return SafeBitConst( word & rhs.word ); }
+ const SafeBitConst operator ^ ( const SafeBitConst& rhs ) const { return SafeBitConst( word ^ rhs.word ); }
const SafeBitConst operator ~ ( void ) const { return SafeBitConst( ~word ); }
/// These bitwise operators return a bit-field instead of a bit-const.
- field_t operator | ( const field_t & rhs ) const { return field_t( word | rhs.word ); }
- field_t operator & ( const field_t & rhs ) const { return field_t( word & rhs.word ); }
- field_t operator ^ ( const field_t & rhs ) const { return field_t( word ^ rhs.word ); }
+ field_t operator | ( const field_t& rhs ) const { return field_t( word | rhs.word ); }
+ field_t operator & ( const field_t& rhs ) const { return field_t( word & rhs.word ); }
+ field_t operator ^ ( const field_t& rhs ) const { return field_t( word ^ rhs.word ); }
/// The shift operators move bits inside the bit field. These are useful in
/// loops which act over bit fields and increment them.
@@ -232,7 +232,7 @@ private:
/// Copy-assignment operator is not implemented since it does not make sense
/// for a constant object.
- SafeBitConst operator = ( const SafeBitConst & rhs );
+ SafeBitConst operator = ( const SafeBitConst& rhs );
// Private constructor from an integer type.
explicit SafeBitConst( word_t init ) : word( init ) {}
@@ -287,9 +287,9 @@ private:
template
<
- unsigned int unique_index,
- typename word_t
->
+unsigned int unique_index,
+ typename word_t
+ >
class SafeBitField
{
public:
@@ -305,37 +305,37 @@ public:
SafeBitField() : word( 0 ) {}
/// Copy constructor and assignment operators.
- SafeBitField( const SafeBitField & rhs ) : word( rhs.word ) {}
- SafeBitField & operator = ( const SafeBitField & rhs ) { word = rhs.word; return *this; }
+ SafeBitField( const SafeBitField& rhs ) : word( rhs.word ) {}
+ SafeBitField& operator = ( const SafeBitField& rhs ) { word = rhs.word; return *this; }
/// Copy constructor and assignment operators from constant bit fields.
- SafeBitField( const const_t & rhs ) : word( rhs.word ) {}
- SafeBitField & operator = ( const const_t & rhs ) { word = rhs.word; return *this; }
+ SafeBitField( const const_t& rhs ) : word( rhs.word ) {}
+ SafeBitField& operator = ( const const_t& rhs ) { word = rhs.word; return *this; }
/// These comparison operators act on bit-fields of the same type.
- bool operator == ( const SafeBitField & rhs ) const { return word == rhs.word; }
- bool operator != ( const SafeBitField & rhs ) const { return word != rhs.word; }
- bool operator < ( const SafeBitField & rhs ) const { return word < rhs.word; }
- bool operator > ( const SafeBitField & rhs ) const { return word > rhs.word; }
- bool operator <= ( const SafeBitField & rhs ) const { return word <= rhs.word; }
- bool operator >= ( const SafeBitField & rhs ) const { return word >= rhs.word; }
+ bool operator == ( const SafeBitField& rhs ) const { return word == rhs.word; }
+ bool operator != ( const SafeBitField& rhs ) const { return word != rhs.word; }
+ bool operator < ( const SafeBitField& rhs ) const { return word < rhs.word; }
+ bool operator > ( const SafeBitField& rhs ) const { return word > rhs.word; }
+ bool operator <= ( const SafeBitField& rhs ) const { return word <= rhs.word; }
+ bool operator >= ( const SafeBitField& rhs ) const { return word >= rhs.word; }
/// These comparison operators act on bit-constants of a similar type.
- bool operator == ( const const_t & rhs ) const { return word == rhs.word; }
- bool operator != ( const const_t & rhs ) const { return word != rhs.word; }
- bool operator < ( const const_t & rhs ) const { return word < rhs.word; }
- bool operator > ( const const_t & rhs ) const { return word > rhs.word; }
- bool operator <= ( const const_t & rhs ) const { return word <= rhs.word; }
- bool operator >= ( const const_t & rhs ) const { return word >= rhs.word; }
+ bool operator == ( const const_t& rhs ) const { return word == rhs.word; }
+ bool operator != ( const const_t& rhs ) const { return word != rhs.word; }
+ bool operator < ( const const_t& rhs ) const { return word < rhs.word; }
+ bool operator > ( const const_t& rhs ) const { return word > rhs.word; }
+ bool operator <= ( const const_t& rhs ) const { return word <= rhs.word; }
+ bool operator >= ( const const_t& rhs ) const { return word >= rhs.word; }
/// Bitwise operations that use bit-fields.
- SafeBitField operator | ( const SafeBitField & rhs ) const { return SafeBitField( word | rhs.word ); }
- SafeBitField operator & ( const SafeBitField & rhs ) const { return SafeBitField( word & rhs.word ); }
- SafeBitField operator ^ ( const SafeBitField & rhs ) const { return SafeBitField( word ^ rhs.word ); }
+ SafeBitField operator | ( const SafeBitField& rhs ) const { return SafeBitField( word | rhs.word ); }
+ SafeBitField operator & ( const SafeBitField& rhs ) const { return SafeBitField( word & rhs.word ); }
+ SafeBitField operator ^ ( const SafeBitField& rhs ) const { return SafeBitField( word ^ rhs.word ); }
SafeBitField operator ~ ( void ) const { return SafeBitField( ~word ); }
- SafeBitField operator |= ( const SafeBitField & rhs ) { word |= rhs.word; return SafeBitField( *this ); }
- SafeBitField operator &= ( const SafeBitField & rhs ) { word &= rhs.word; return SafeBitField( *this ); }
- SafeBitField operator ^= ( const SafeBitField & rhs ) { word ^= rhs.word; return SafeBitField( *this ); }
+ SafeBitField operator |= ( const SafeBitField& rhs ) { word |= rhs.word; return SafeBitField( *this ); }
+ SafeBitField operator &= ( const SafeBitField& rhs ) { word &= rhs.word; return SafeBitField( *this ); }
+ SafeBitField operator ^= ( const SafeBitField& rhs ) { word ^= rhs.word; return SafeBitField( *this ); }
/// Bitwise operators that use bit-constants.
SafeBitField operator | ( const_t rhs ) const { return SafeBitField( word | rhs.word ); }
@@ -471,42 +471,42 @@ inline SafeBitField< unique_index, word_t > operator != ( bool, SafeBitField< un
// This creates a typedef field_t for SafeBitField<unique_index, ulong> where index is the current line number. Since line numbers __LINE__ are counted
// separately for all header files, this ends up being the same type in all files using the header which defines field_t.
#ifdef LOKI_SAFE_BIT_FIELD
- #define LOKI_BIT_FIELD( word_t ) typedef SafeBitField<__LINE__, word_t>
+#define LOKI_BIT_FIELD( word_t ) typedef SafeBitField<__LINE__, word_t>
#else
- #define LOKI_BIT_FIELD( word_t ) typedef word_t
+#define LOKI_BIT_FIELD( word_t ) typedef word_t
#endif // LOKI_SAFE_BIT_FIELD
// The second macro helps to declare static bit constants:
// LOKI_BIT_CONST( field_t, Label_1, 1 );
// creates new bit field object named Label_1 of type field_t which represents the field with the 1st (junior) bit set.
#ifdef LOKI_SAFE_BIT_FIELD
- #ifndef LOKI_BIT_FIELD_NONTEMPLATE_INIT
- #define LOKI_BIT_CONST( field_t, label, bit_index ) \
+#ifndef LOKI_BIT_FIELD_NONTEMPLATE_INIT
+#define LOKI_BIT_CONST( field_t, label, bit_index ) \
static const field_t::const_t label = field_t::const_t::make_bit_const<bit_index>()
- #else
- #define LOKI_BIT_CONST( field_t, label, bit_index ) \
+#else
+#define LOKI_BIT_CONST( field_t, label, bit_index ) \
static const field_t::const_t label = field_t::const_t::make_bit_const( bit_index )
- #endif // LOKI_BIT_FIELD_NONTEMPLATE_INIT
+#endif // LOKI_BIT_FIELD_NONTEMPLATE_INIT
#else
- inline size_t make_bit_const( size_t i ) { return ( i > 0 ) ? ( size_t(1) << ( ( i > 0 ) ? ( i - 1 ) : 0 ) ) : 0; }
- #define LOKI_BIT_CONST( field_t, label, bit_index ) static const field_t label = make_bit_const( bit_index )
+inline size_t make_bit_const( size_t i ) { return ( i > 0 ) ? ( size_t(1) << ( ( i > 0 ) ? ( i - 1 ) : 0 ) ) : 0; }
+#define LOKI_BIT_CONST( field_t, label, bit_index ) static const field_t label = make_bit_const( bit_index )
#endif // LOKI_SAFE_BIT_FIELD
// The third macro helps to declare complex bit constants which are combination of several bits:
// LOKI_BIT_CONSTS( field_t, Label12 ) = Label_1 | Label_2;
#ifdef LOKI_SAFE_BIT_FIELD
- #define LOKI_BIT_CONSTS( field_t, label ) static const field_t::const_t label
+#define LOKI_BIT_CONSTS( field_t, label ) static const field_t::const_t label
#else
- #define LOKI_BIT_CONSTS( field_t, label ) static const field_t label
+#define LOKI_BIT_CONSTS( field_t, label ) static const field_t label
#endif // LOKI_SAFE_BIT_FIELD
// The fourth macro helps to declare the maximum number of bit constants for a given type:
// static const size_t count = LOKI_BIT_FIELD_COUNT( field_t );
// declared a variable "count" initialized to field_t::size()
#ifdef LOKI_SAFE_BIT_FIELD
- #define LOKI_BIT_FIELD_COUNT( field_t ) field_t::size()
+#define LOKI_BIT_FIELD_COUNT( field_t ) field_t::size()
#else
- #define LOKI_BIT_FIELD_COUNT( field_t ) ( 8 * sizeof(field_t) )
+#define LOKI_BIT_FIELD_COUNT( field_t ) ( 8 * sizeof(field_t) )
#endif // LOKI_SAFE_BIT_FIELD
} // namespace Loki
diff --git a/shared/loki/SafeFormat.h b/shared/loki/SafeFormat.h
index 9d948581..2734e972 100644
--- a/shared/loki/SafeFormat.h
+++ b/shared/loki/SafeFormat.h
@@ -5,8 +5,8 @@
// purpose is hereby granted without fee, provided that the above copyright
// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the suitability of this software
-// for any purpose. It is provided "as is" without express or implied
+// The author makes no representations about the suitability of this software
+// for any purpose. It is provided "as is" without express or implied
// warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_SAFEFORMAT_INC_
@@ -16,8 +16,8 @@
////////////////////////////////////////////////////////////////////////////////
-// This file contains definitions for SafePrintf. SafeScanf coming soon (the
-// design is similar).
+// This file contains definitions for SafePrintf. SafeScanf coming soon (the
+// design is similar).
// See Alexandrescu, Andrei: Type-safe Formatting, C/C++ Users Journal, Aug 2005
////////////////////////////////////////////////////////////////////////////////
@@ -45,328 +45,375 @@
#endif
// Windows headers could have min/max defined
-#ifdef max
-# undef max
-#endif
-#ifdef min
-# undef min
-#endif
+#ifdef max
+# undef max
+#endif
+#ifdef min
+# undef min
+#endif
namespace Loki
{
- // Crude writing method: writes straight to the file, unbuffered
- // Must be combined with a buffer to work properly (and efficiently)
- LOKI_EXPORT
- void write(std::FILE* f, const char* from, const char* to);
-
- // Write to an ostream
- LOKI_EXPORT
- void write(std::ostream& f, const char* from, const char* to);
-
- // Write to a string
- LOKI_EXPORT
- void write(std::string& s, const char* from, const char* to);
-
- // Write to a fixed-size buffer
- template <class Char>
- void write(std::pair<Char*, std::size_t>& s, const Char* from, const Char* to) {
- assert(from <= to);
- if(from + s.second < to)
- throw std::overflow_error("");
- // s.first: position one past the final copied element
- s.first = std::copy(from, to, s.first);
- // remaining buffer size
- s.second -= to - from;
+// Crude writing method: writes straight to the file, unbuffered
+// Must be combined with a buffer to work properly (and efficiently)
+LOKI_EXPORT
+void write(std::FILE* f, const char* from, const char* to);
+
+// Write to an ostream
+LOKI_EXPORT
+void write(std::ostream& f, const char* from, const char* to);
+
+// Write to a string
+LOKI_EXPORT
+void write(std::string& s, const char* from, const char* to);
+
+// Write to a fixed-size buffer
+template <class Char>
+void write(std::pair<Char*, std::size_t>& s, const Char* from, const Char* to)
+{
+ assert(from <= to);
+ if(from + s.second < to)
+ throw std::overflow_error("");
+ // s.first: position one past the final copied element
+ s.first = std::copy(from, to, s.first);
+ // remaining buffer size
+ s.second -= to - from;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// PrintfState class template
+// Holds the formatting state, and implements operator() to format stuff
+// Todo: make sure errors are handled properly
+////////////////////////////////////////////////////////////////////////////////
+
+template <class Device, class Char>
+struct PrintfState
+{
+ PrintfState(Device dev, const Char* format)
+ : device_(dev)
+ , format_(format)
+ , width_(0)
+ , prec_(0)
+ , flags_(0)
+ , result_(0)
+ {
+ Advance();
}
- ////////////////////////////////////////////////////////////////////////////////
- // PrintfState class template
- // Holds the formatting state, and implements operator() to format stuff
- // Todo: make sure errors are handled properly
- ////////////////////////////////////////////////////////////////////////////////
-
- template <class Device, class Char>
- struct PrintfState {
- PrintfState(Device dev, const Char * format)
- : device_(dev)
- , format_(format)
- , width_(0)
- , prec_(0)
- , flags_(0)
- , result_(0) {
- Advance();
- }
-
- ~PrintfState() {
- }
+ ~PrintfState()
+ {
+ }
- #define LOKI_PRINTF_STATE_FORWARD(type) \
+#define LOKI_PRINTF_STATE_FORWARD(type) \
PrintfState& operator()(type par) {\
return (*this)(static_cast< LOKI_SAFEFORMAT_UNSIGNED_LONG >(par)); \
}
- LOKI_PRINTF_STATE_FORWARD(bool)
- LOKI_PRINTF_STATE_FORWARD(char)
- LOKI_PRINTF_STATE_FORWARD(signed char)
- LOKI_PRINTF_STATE_FORWARD(unsigned char)
- LOKI_PRINTF_STATE_FORWARD(signed short)
- LOKI_PRINTF_STATE_FORWARD(unsigned short)
- LOKI_PRINTF_STATE_FORWARD(signed int)
- LOKI_PRINTF_STATE_FORWARD(signed long)
+ LOKI_PRINTF_STATE_FORWARD(bool)
+ LOKI_PRINTF_STATE_FORWARD(char)
+ LOKI_PRINTF_STATE_FORWARD(signed char)
+ LOKI_PRINTF_STATE_FORWARD(unsigned char)
+ LOKI_PRINTF_STATE_FORWARD(signed short)
+ LOKI_PRINTF_STATE_FORWARD(unsigned short)
+ LOKI_PRINTF_STATE_FORWARD(signed int)
+ LOKI_PRINTF_STATE_FORWARD(signed long)
#if (defined(_WIN32) || defined(_WIN64))
- LOKI_PRINTF_STATE_FORWARD(unsigned long)
+ LOKI_PRINTF_STATE_FORWARD(unsigned long)
#else
- // on Windows already defined by uintptr_t
- LOKI_PRINTF_STATE_FORWARD(unsigned int)
+ // on Windows already defined by uintptr_t
+ LOKI_PRINTF_STATE_FORWARD(unsigned int)
#endif
- // Print (or gobble in case of the "*" specifier) an int
- PrintfState& operator()(LOKI_SAFEFORMAT_UNSIGNED_LONG i) {
- if (result_ == -1) return *this; // don't even bother
- // % [flags] [width] [.prec] [modifier] type_char
- // Fetch the flags
- ReadFlags();
- if (*format_ == '*') {
- // read the width and get out
- SetWidth(static_cast<size_t>(i));
- ++format_;
+ // Print (or gobble in case of the "*" specifier) an int
+ PrintfState& operator()(LOKI_SAFEFORMAT_UNSIGNED_LONG i)
+ {
+ if (result_ == -1) return *this; // don't even bother
+ // % [flags] [width] [.prec] [modifier] type_char
+ // Fetch the flags
+ ReadFlags();
+ if (*format_ == '*')
+ {
+ // read the width and get out
+ SetWidth(static_cast<size_t>(i));
+ ++format_;
+ return *this;
+ }
+ ReadWidth();
+ // precision
+ if (*format_ == '.')
+ {
+ // deal with precision
+ if (format_[1] == '*')
+ {
+ // read the precision and get out
+ SetPrec(static_cast<size_t>(i));
+ format_ += 2;
return *this;
}
- ReadWidth();
- // precision
- if (*format_ == '.') {
- // deal with precision
- if (format_[1] == '*') {
- // read the precision and get out
- SetPrec(static_cast<size_t>(i));
- format_ += 2;
- return *this;
- }
- ReadPrecision();
- }
- ReadModifiers();
- // input size modifier
- if (ForceShort()) {
- // short int
- const Char c = *format_;
- if (c == 'x' || c == 'X' || c == 'u' || c == 'o') {
- i = static_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(static_cast<unsigned short>(i));
- }
+ ReadPrecision();
+ }
+ ReadModifiers();
+ // input size modifier
+ if (ForceShort())
+ {
+ // short int
+ const Char c = *format_;
+ if (c == 'x' || c == 'X' || c == 'u' || c == 'o')
+ {
+ i = static_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(static_cast<unsigned short>(i));
}
- FormatWithCurrentFlags(i);
- return *this;
}
+ FormatWithCurrentFlags(i);
+ return *this;
+ }
- PrintfState& operator()(void* n) {
- if (result_ == -1) return *this; // don't even bother
- PrintUsing_snprintf(n,"p");
- return *this;
- }
-
- PrintfState& operator()(double n) {
- if (result_ == -1) return *this; // don't even bother
- PrintUsing_snprintf(n,"eEfgG");
- return *this;
- }
+ PrintfState& operator()(void* n)
+ {
+ if (result_ == -1) return *this; // don't even bother
+ PrintUsing_snprintf(n,"p");
+ return *this;
+ }
- PrintfState& operator()(long double n) {
- if (result_ == -1) return *this; // don't even bother
- PrintUsing_snprintf(n,"eEfgG");
- return *this;
- }
+ PrintfState& operator()(double n)
+ {
+ if (result_ == -1) return *this; // don't even bother
+ PrintUsing_snprintf(n,"eEfgG");
+ return *this;
+ }
- // Store the number of characters printed so far
- PrintfState& operator()(int * pi) {
- return StoreCountHelper(pi);
- }
-
- // Store the number of characters printed so far
- PrintfState& operator()(short * pi) {
- return StoreCountHelper(pi);
- }
-
- // Store the number of characters printed so far
- PrintfState& operator()(long * pi) {
- return StoreCountHelper(pi);
+ PrintfState& operator()(long double n)
+ {
+ if (result_ == -1) return *this; // don't even bother
+ PrintUsing_snprintf(n,"eEfgG");
+ return *this;
+ }
+
+ // Store the number of characters printed so far
+ PrintfState& operator()(int* pi)
+ {
+ return StoreCountHelper(pi);
+ }
+
+ // Store the number of characters printed so far
+ PrintfState& operator()(short* pi)
+ {
+ return StoreCountHelper(pi);
+ }
+
+ // Store the number of characters printed so far
+ PrintfState& operator()(long* pi)
+ {
+ return StoreCountHelper(pi);
+ }
+
+ PrintfState& operator()(const std::string& stdstr)
+ {
+ return operator()(stdstr.c_str());
+ }
+
+ PrintfState& operator()(const char* const s)
+ {
+ if (result_ == -1) return *this;
+ ReadLeaders();
+ const char fmt = *format_;
+ if (fmt == 'p')
+ {
+ FormatWithCurrentFlags(reinterpret_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(s));
+ return *this;
}
-
- PrintfState& operator()(const std::string& stdstr) {
- return operator()(stdstr.c_str());
+ if (fmt != 's')
+ {
+ result_ = -1;
+ return *this;
}
-
- PrintfState& operator()(const char *const s) {
- if (result_ == -1) return *this;
- ReadLeaders();
- const char fmt = *format_;
- if (fmt == 'p') {
- FormatWithCurrentFlags(reinterpret_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(s));
- return *this;
- }
- if (fmt != 's') {
- result_ = -1;
- return *this;
+ const size_t len = std::min(std::strlen(s), prec_);
+ if (width_ > len)
+ {
+ if (LeftJustify())
+ {
+ Write(s, s + len);
+ Fill(' ', width_ - len);
}
- const size_t len = std::min(std::strlen(s), prec_);
- if (width_ > len) {
- if (LeftJustify()) {
- Write(s, s + len);
- Fill(' ', width_ - len);
- } else {
- Fill(' ', width_ - len);
- Write(s, s + len);
- }
- } else {
+ else
+ {
+ Fill(' ', width_ - len);
Write(s, s + len);
}
- Next();
- return *this;
}
-
- PrintfState& operator()(const void *const p) {
- return (*this)(reinterpret_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(p));
+ else
+ {
+ Write(s, s + len);
}
-
- // read the result
- operator int() const {
- return static_cast<int>(result_);
+ Next();
+ return *this;
+ }
+
+ PrintfState& operator()(const void* const p)
+ {
+ return (*this)(reinterpret_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(p));
+ }
+
+ // read the result
+ operator int() const
+ {
+ return static_cast<int>(result_);
+ }
+
+private:
+ PrintfState& operator=(const PrintfState&);
+ template <typename T>
+ PrintfState& StoreCountHelper(T* const pi)
+ {
+ if (result_ == -1) return *this; // don't even bother
+ ReadLeaders();
+ const char fmt = *format_;
+ if (fmt == 'p') // pointer
+ {
+ FormatWithCurrentFlags(reinterpret_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(pi));
+ return *this;
}
-
- private:
- PrintfState& operator=(const PrintfState&);
- template <typename T>
- PrintfState& StoreCountHelper(T *const pi) {
- if (result_ == -1) return *this; // don't even bother
- ReadLeaders();
- const char fmt = *format_;
- if (fmt == 'p') { // pointer
- FormatWithCurrentFlags(reinterpret_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(pi));
- return *this;
- }
- if (fmt != 'n') {
- result_ = -1;
- return *this;
- }
- assert(pi != 0);
- *pi = result_;
- Next();
+ if (fmt != 'n')
+ {
+ result_ = -1;
return *this;
}
+ assert(pi != 0);
+ *pi = result_;
+ Next();
+ return *this;
+ }
- void FormatWithCurrentFlags(const LOKI_SAFEFORMAT_UNSIGNED_LONG i) {
- // look at the format character
- Char formatChar = *format_;
- bool isSigned = formatChar == 'd' || formatChar == 'i';
- if (formatChar == 'p') {
- formatChar = 'x'; // pointers go to hex
- SetAlternateForm(); // printed with '0x' in front
- isSigned = true; // that's what gcc does
- }
- if (!strchr("cdiuoxX", formatChar)) {
- result_ = -1;
- return;
- }
- Char buf[
- sizeof(LOKI_SAFEFORMAT_UNSIGNED_LONG) * 3 // digits
- + 1 // sign or ' '
- + 2 // 0x or 0X
- + 1]; // terminating zero
- const Char *const bufEnd = buf + (sizeof(buf) / sizeof(Char));
- Char * bufLast = buf + (sizeof(buf) / sizeof(Char) - 1);
- Char signChar = 0;
- unsigned int base = 10;
-
- if (formatChar == 'c') {
- // Format only one character
- // The 'fill with zeros' flag is ignored
- ResetFillZeros();
- *bufLast = static_cast<char>(i);
- } else {
- // TODO: inefficient code, refactor
- const bool negative = isSigned && static_cast<LOKI_SAFEFORMAT_SIGNED_LONG>(i) < 0;
- if (formatChar == 'o') base = 8;
- else if (formatChar == 'x' || formatChar == 'X') base = 16;
- bufLast = isSigned
- ? RenderWithoutSign(static_cast<LOKI_SAFEFORMAT_SIGNED_LONG>(i), bufLast, base,
- formatChar == 'X')
- : RenderWithoutSign(i, bufLast, base,
- formatChar == 'X');
- // Add the sign
- if (isSigned) {
- negative ? signChar = '-'
- : ShowSignAlways() ? signChar = '+'
- : Blank() ? signChar = ' '
- : 0;
- }
- }
- // precision
- size_t
- countDigits = bufEnd - bufLast,
- countZeros = prec_ != size_t(-1) && countDigits < prec_ &&
- formatChar != 'c'
- ? prec_ - countDigits
- : 0,
- countBase = base != 10 && AlternateForm() && i != 0
- ? (base == 16 ? 2 : countZeros > 0 ? 0 : 1)
- : 0,
- countSign = (signChar != 0),
- totalPrintable = countDigits + countZeros + countBase + countSign;
- size_t countPadLeft = 0, countPadRight = 0;
- if (width_ > totalPrintable) {
- if (LeftJustify()) {
- countPadRight = width_ - totalPrintable;
- countPadLeft = 0;
- } else {
- countPadLeft = width_ - totalPrintable;
- countPadRight = 0;
- }
+ void FormatWithCurrentFlags(const LOKI_SAFEFORMAT_UNSIGNED_LONG i)
+ {
+ // look at the format character
+ Char formatChar = *format_;
+ bool isSigned = formatChar == 'd' || formatChar == 'i';
+ if (formatChar == 'p')
+ {
+ formatChar = 'x'; // pointers go to hex
+ SetAlternateForm(); // printed with '0x' in front
+ isSigned = true; // that's what gcc does
+ }
+ if (!strchr("cdiuoxX", formatChar))
+ {
+ result_ = -1;
+ return;
+ }
+ Char buf[
+ sizeof(LOKI_SAFEFORMAT_UNSIGNED_LONG) * 3 // digits
+ + 1 // sign or ' '
+ + 2 // 0x or 0X
+ + 1]; // terminating zero
+ const Char* const bufEnd = buf + (sizeof(buf) / sizeof(Char));
+ Char* bufLast = buf + (sizeof(buf) / sizeof(Char) - 1);
+ Char signChar = 0;
+ unsigned int base = 10;
+
+ if (formatChar == 'c')
+ {
+ // Format only one character
+ // The 'fill with zeros' flag is ignored
+ ResetFillZeros();
+ *bufLast = static_cast<char>(i);
+ }
+ else
+ {
+ // TODO: inefficient code, refactor
+ const bool negative = isSigned && static_cast<LOKI_SAFEFORMAT_SIGNED_LONG>(i) < 0;
+ if (formatChar == 'o') base = 8;
+ else if (formatChar == 'x' || formatChar == 'X') base = 16;
+ bufLast = isSigned
+ ? RenderWithoutSign(static_cast<LOKI_SAFEFORMAT_SIGNED_LONG>(i), bufLast, base,
+ formatChar == 'X')
+ : RenderWithoutSign(i, bufLast, base,
+ formatChar == 'X');
+ // Add the sign
+ if (isSigned)
+ {
+ negative ? signChar = '-'
+ : ShowSignAlways() ? signChar = '+'
+ : Blank() ? signChar = ' '
+ : 0;
}
- if (FillZeros() && prec_ == size_t(-1)) {
- // pad with zeros and no precision - transfer padding to precision
- countZeros = countPadLeft;
+ }
+ // precision
+ size_t
+ countDigits = bufEnd - bufLast,
+ countZeros = prec_ != size_t(-1) && countDigits < prec_ &&
+ formatChar != 'c'
+ ? prec_ - countDigits
+ : 0,
+ countBase = base != 10 && AlternateForm() && i != 0
+ ? (base == 16 ? 2 : countZeros > 0 ? 0 : 1)
+ : 0,
+ countSign = (signChar != 0),
+ totalPrintable = countDigits + countZeros + countBase + countSign;
+ size_t countPadLeft = 0, countPadRight = 0;
+ if (width_ > totalPrintable)
+ {
+ if (LeftJustify())
+ {
+ countPadRight = width_ - totalPrintable;
countPadLeft = 0;
}
- // ok, all computed, ready to print to device
- Fill(' ', countPadLeft);
- if (signChar != 0) Write(&signChar, &signChar + 1);
- if (countBase > 0) Fill('0', 1);
- if (countBase == 2) Fill(formatChar, 1);
- Fill('0', countZeros);
- Write(bufLast, bufEnd);
- Fill(' ', countPadRight);
- // done, advance
- Next();
+ else
+ {
+ countPadLeft = width_ - totalPrintable;
+ countPadRight = 0;
+ }
}
-
- void Write(const Char* b, const Char* e) {
- if (result_ < 0) return;
- const LOKI_SAFEFORMAT_SIGNED_LONG x = e - b;
- write(device_, b, e);
- result_ += x;
+ if (FillZeros() && prec_ == size_t(-1))
+ {
+ // pad with zeros and no precision - transfer padding to precision
+ countZeros = countPadLeft;
+ countPadLeft = 0;
}
+ // ok, all computed, ready to print to device
+ Fill(' ', countPadLeft);
+ if (signChar != 0) Write(&signChar, &signChar + 1);
+ if (countBase > 0) Fill('0', 1);
+ if (countBase == 2) Fill(formatChar, 1);
+ Fill('0', countZeros);
+ Write(bufLast, bufEnd);
+ Fill(' ', countPadRight);
+ // done, advance
+ Next();
+ }
- template <class Value>
- void PrintUsing_snprintf(Value n, const char* check_fmt_char) {
- const Char *const fmt = format_ - 1;
- assert(*fmt == '%');
- // enforce format string validity
- ReadLeaders();
- // enforce format spec
- if (!strchr(check_fmt_char, *format_)) {
- result_ = -1;
- return;
- }
- // format char validated, copy it to a temp and use legacy sprintf
- ++format_;
- Char fmtBuf[128], resultBuf[1024];
- if (format_ >= fmt + sizeof(fmtBuf) / sizeof(Char)) {
- result_ = -1;
- return;
- }
- memcpy(fmtBuf, fmt, (format_ - fmt) * sizeof(Char));
- fmtBuf[format_ - fmt] = 0;
+ void Write(const Char* b, const Char* e)
+ {
+ if (result_ < 0) return;
+ const LOKI_SAFEFORMAT_SIGNED_LONG x = e - b;
+ write(device_, b, e);
+ result_ += x;
+ }
- const int stored =
+ template <class Value>
+ void PrintUsing_snprintf(Value n, const char* check_fmt_char)
+ {
+ const Char* const fmt = format_ - 1;
+ assert(*fmt == '%');
+ // enforce format string validity
+ ReadLeaders();
+ // enforce format spec
+ if (!strchr(check_fmt_char, *format_))
+ {
+ result_ = -1;
+ return;
+ }
+ // format char validated, copy it to a temp and use legacy sprintf
+ ++format_;
+ Char fmtBuf[128], resultBuf[1024];
+ if (format_ >= fmt + sizeof(fmtBuf) / sizeof(Char))
+ {
+ result_ = -1;
+ return;
+ }
+ memcpy(fmtBuf, fmt, (format_ - fmt) * sizeof(Char));
+ fmtBuf[format_ - fmt] = 0;
+
+ const int stored =
#ifdef _MSC_VER
#if _MSC_VER < 1400
_snprintf
@@ -374,214 +421,259 @@ namespace Loki
_snprintf_s
#endif
#else
- snprintf
-#endif
- (resultBuf, sizeof(resultBuf) / sizeof(Char), fmtBuf, n);
-
- if (stored < 0) {
- result_ = -1;
- return;
- }
- Write(resultBuf, resultBuf + strlen(resultBuf));
- Advance(); // output stuff to the next format directive
- }
+ snprintf
+#endif
+ (resultBuf, sizeof(resultBuf) / sizeof(Char), fmtBuf, n);
- void Fill(const Char c, size_t n) {
- for (; n > 0; --n) {
- Write(&c, &c + 1);
- }
+ if (stored < 0)
+ {
+ result_ = -1;
+ return;
}
-
- Char* RenderWithoutSign(LOKI_SAFEFORMAT_UNSIGNED_LONG n, char* bufLast,
- unsigned int base, bool uppercase) {
- const Char hex1st = uppercase ? 'A' : 'a';
- for (;;) {
- const LOKI_SAFEFORMAT_UNSIGNED_LONG next = n / base;
- Char c = static_cast<Char>(n - next * base);
- c = static_cast<Char>(c + (c <= 9 ? '0' : static_cast<Char>(hex1st - 10)));
- *bufLast = c;
- n = next;
- if (n == 0) break;
- --bufLast;
- }
- return bufLast;
+ Write(resultBuf, resultBuf + strlen(resultBuf));
+ Advance(); // output stuff to the next format directive
+ }
+
+ void Fill(const Char c, size_t n)
+ {
+ for (; n > 0; --n)
+ {
+ Write(&c, &c + 1);
}
+ }
- char* RenderWithoutSign(LOKI_SAFEFORMAT_SIGNED_LONG n, char* bufLast, unsigned int base,
- bool uppercase) {
- if (n != LONG_MIN) {
- return RenderWithoutSign(static_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(n < 0 ? -n : n),
- bufLast, base, uppercase);
- }
- // annoying corner case
- char* save = bufLast;
- ++n;
- bufLast = RenderWithoutSign(static_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(n),
- bufLast, base, uppercase);
- --(*save);
- return bufLast;
+ Char* RenderWithoutSign(LOKI_SAFEFORMAT_UNSIGNED_LONG n, char* bufLast,
+ unsigned int base, bool uppercase)
+ {
+ const Char hex1st = uppercase ? 'A' : 'a';
+ for (;;)
+ {
+ const LOKI_SAFEFORMAT_UNSIGNED_LONG next = n / base;
+ Char c = static_cast<Char>(n - next * base);
+ c = static_cast<Char>(c + (c <= 9 ? '0' : static_cast<Char>(hex1st - 10)));
+ *bufLast = c;
+ n = next;
+ if (n == 0) break;
+ --bufLast;
}
-
- void Next() {
- ++format_;
- Advance();
+ return bufLast;
+ }
+
+ char* RenderWithoutSign(LOKI_SAFEFORMAT_SIGNED_LONG n, char* bufLast, unsigned int base,
+ bool uppercase)
+ {
+ if (n != LONG_MIN)
+ {
+ return RenderWithoutSign(static_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(n < 0 ? -n : n),
+ bufLast, base, uppercase);
}
-
- void Advance() {
- ResetAll();
- const Char* begin = format_;
- for (;;) {
- if (*format_ == '%') {
- if (format_[1] != '%') { // It's a format specifier
- Write(begin, format_);
- ++format_;
- break;
- }
- // It's a "%%"
- Write(begin, ++format_);
- begin = ++format_;
- continue;
- }
- if (*format_ == 0) {
+ // annoying corner case
+ char* save = bufLast;
+ ++n;
+ bufLast = RenderWithoutSign(static_cast<LOKI_SAFEFORMAT_UNSIGNED_LONG>(n),
+ bufLast, base, uppercase);
+ --(*save);
+ return bufLast;
+ }
+
+ void Next()
+ {
+ ++format_;
+ Advance();
+ }
+
+ void Advance()
+ {
+ ResetAll();
+ const Char* begin = format_;
+ for (;;)
+ {
+ if (*format_ == '%')
+ {
+ if (format_[1] != '%') // It's a format specifier
+ {
Write(begin, format_);
+ ++format_;
break;
}
- ++format_;
+ // It's a "%%"
+ Write(begin, ++format_);
+ begin = ++format_;
+ continue;
}
- }
-
- void ReadFlags() {
- for (;; ++format_) {
- switch (*format_) {
- case '-': SetLeftJustify(); break;
- case '+': SetShowSignAlways(); break;
- case ' ': SetBlank(); break;
- case '#': SetAlternateForm(); break;
- case '0': SetFillZeros(); break;
- default: return;
- }
+ if (*format_ == 0)
+ {
+ Write(begin, format_);
+ break;
}
- }
-
- void ParseDecimalSizeT(size_t& dest) {
- if (!std::isdigit(*format_, std::locale())) return;
- size_t r = 0;
- do {
- // TODO: inefficient - rewrite
- r *= 10;
- r += *format_ - '0';
- ++format_;
- } while (std::isdigit(*format_, std::locale()));
- dest = r;
- }
-
- void ReadWidth() {
- ParseDecimalSizeT(width_);
- }
-
- void ReadPrecision() {
- assert(*format_ == '.');
++format_;
- ParseDecimalSizeT(prec_);
- }
-
- void ReadModifiers() {
- switch (*format_) {
- case 'h': SetForceShort(); ++format_; break;
- case 'l': ++format_; break;
- // more (C99 and platform-specific modifiers) to come
+ }
+ }
+
+ void ReadFlags()
+ {
+ for (;; ++format_)
+ {
+ switch (*format_)
+ {
+ case '-':
+ SetLeftJustify();
+ break;
+ case '+':
+ SetShowSignAlways();
+ break;
+ case ' ':
+ SetBlank();
+ break;
+ case '#':
+ SetAlternateForm();
+ break;
+ case '0':
+ SetFillZeros();
+ break;
+ default:
+ return;
}
}
-
- void ReadLeaders() {
- ReadFlags();
- ReadWidth();
- if (*format_ == '.') ReadPrecision();
- ReadModifiers();
+ }
+
+ void ParseDecimalSizeT(size_t& dest)
+ {
+ if (!std::isdigit(*format_, std::locale())) return;
+ size_t r = 0;
+ do
+ {
+ // TODO: inefficient - rewrite
+ r *= 10;
+ r += *format_ - '0';
+ ++format_;
}
-
- enum {
- leftJustify = 1,
- showSignAlways = 2,
- blank = 4,
- alternateForm = 8,
- fillZeros = 16,
- forceShort = 32
- };
-
- bool LeftJustify() const { return (flags_ & leftJustify) != 0; }
- bool ShowSignAlways() const { return (flags_ & showSignAlways) != 0; }
- void SetWidth(size_t w) { width_ = w; }
- void SetLeftJustify() { flags_ |= leftJustify; }
- void SetShowSignAlways() { flags_ |= showSignAlways; }
- bool Blank() const { return (flags_ & blank) != 0; }
- bool AlternateForm() const { return (flags_ & alternateForm) != 0; }
- bool FillZeros() const { return (flags_ & fillZeros) != 0; }
- bool ForceShort() const { return (flags_ & forceShort) != 0; }
-
- void SetPrec(size_t p) { prec_ = p; }
- void SetBlank() { flags_ |= blank; }
- void SetAlternateForm() { flags_ |= alternateForm; }
- void SetFillZeros() { flags_ |= fillZeros; }
- void ResetFillZeros() { flags_ &= ~fillZeros; }
- void SetForceShort() { flags_ |= forceShort; }
-
- void ResetAll() {
- assert(result_ != EOF);
- width_ = 0;
- prec_ = size_t(-1);
- flags_ = 0;
+ while (std::isdigit(*format_, std::locale()));
+ dest = r;
+ }
+
+ void ReadWidth()
+ {
+ ParseDecimalSizeT(width_);
+ }
+
+ void ReadPrecision()
+ {
+ assert(*format_ == '.');
+ ++format_;
+ ParseDecimalSizeT(prec_);
+ }
+
+ void ReadModifiers()
+ {
+ switch (*format_)
+ {
+ case 'h':
+ SetForceShort();
+ ++format_;
+ break;
+ case 'l':
+ ++format_;
+ break;
+ // more (C99 and platform-specific modifiers) to come
}
+ }
+
+ void ReadLeaders()
+ {
+ ReadFlags();
+ ReadWidth();
+ if (*format_ == '.') ReadPrecision();
+ ReadModifiers();
+ }
- // state
- Device device_;
- const Char* format_;
- size_t width_;
- size_t prec_;
- unsigned int flags_;
- LOKI_SAFEFORMAT_SIGNED_LONG result_;
+ enum
+ {
+ leftJustify = 1,
+ showSignAlways = 2,
+ blank = 4,
+ alternateForm = 8,
+ fillZeros = 16,
+ forceShort = 32
};
- LOKI_EXPORT
- PrintfState<std::FILE*, char> Printf(const char* format);
+ bool LeftJustify() const { return (flags_ & leftJustify) != 0; }
+ bool ShowSignAlways() const { return (flags_ & showSignAlways) != 0; }
+ void SetWidth(size_t w) { width_ = w; }
+ void SetLeftJustify() { flags_ |= leftJustify; }
+ void SetShowSignAlways() { flags_ |= showSignAlways; }
+ bool Blank() const { return (flags_ & blank) != 0; }
+ bool AlternateForm() const { return (flags_ & alternateForm) != 0; }
+ bool FillZeros() const { return (flags_ & fillZeros) != 0; }
+ bool ForceShort() const { return (flags_ & forceShort) != 0; }
+
+ void SetPrec(size_t p) { prec_ = p; }
+ void SetBlank() { flags_ |= blank; }
+ void SetAlternateForm() { flags_ |= alternateForm; }
+ void SetFillZeros() { flags_ |= fillZeros; }
+ void ResetFillZeros() { flags_ &= ~fillZeros; }
+ void SetForceShort() { flags_ |= forceShort; }
+
+ void ResetAll()
+ {
+ assert(result_ != EOF);
+ width_ = 0;
+ prec_ = size_t(-1);
+ flags_ = 0;
+ }
- LOKI_EXPORT
- PrintfState<std::FILE*, char> Printf(const std::string& format);
+ // state
+ Device device_;
+ const Char* format_;
+ size_t width_;
+ size_t prec_;
+ unsigned int flags_;
+ LOKI_SAFEFORMAT_SIGNED_LONG result_;
+};
- LOKI_EXPORT
- PrintfState<std::FILE*, char> FPrintf(std::FILE* f, const char* format);
+LOKI_EXPORT
+PrintfState<std::FILE*, char> Printf(const char* format);
- LOKI_EXPORT
- PrintfState<std::FILE*, char> FPrintf(std::FILE* f, const std::string& format);
+LOKI_EXPORT
+PrintfState<std::FILE*, char> Printf(const std::string& format);
- LOKI_EXPORT
- PrintfState<std::ostream&, char> FPrintf(std::ostream& f, const char* format);
+LOKI_EXPORT
+PrintfState<std::FILE*, char> FPrintf(std::FILE* f, const char* format);
- LOKI_EXPORT
- PrintfState<std::ostream&, char> FPrintf(std::ostream& f, const std::string& format);
+LOKI_EXPORT
+PrintfState<std::FILE*, char> FPrintf(std::FILE* f, const std::string& format);
- LOKI_EXPORT
- PrintfState<std::string&, char> SPrintf(std::string& s, const char* format);
+LOKI_EXPORT
+PrintfState<std::ostream&, char> FPrintf(std::ostream& f, const char* format);
- LOKI_EXPORT
- PrintfState<std::string&, char> SPrintf(std::string& s, const std::string& format);
+LOKI_EXPORT
+PrintfState<std::ostream&, char> FPrintf(std::ostream& f, const std::string& format);
- template <class T, class Char>
- PrintfState<T&, Char> XPrintf(T& device, const Char* format) {
- return PrintfState<T&, Char>(device, format);
- }
+LOKI_EXPORT
+PrintfState<std::string&, char> SPrintf(std::string& s, const char* format);
- template <class T>
- PrintfState<T&, char> XPrintf(T& device, const std::string& format) {
- return PrintfState<T&, char>(device, format.c_str());
- }
+LOKI_EXPORT
+PrintfState<std::string&, char> SPrintf(std::string& s, const std::string& format);
- template <class Char, std::size_t N>
- PrintfState<std::pair<Char*, std::size_t>, Char>
- BufPrintf(Char (&buf)[N], const Char* format) {
- std::pair<Char*, std::size_t> temp(buf, N);
- return PrintfState<std::pair<Char*, std::size_t>, Char>(temp, format);
- }
+template <class T, class Char>
+PrintfState<T&, Char> XPrintf(T& device, const Char* format)
+{
+ return PrintfState<T&, Char>(device, format);
+}
+
+template <class T>
+PrintfState<T&, char> XPrintf(T& device, const std::string& format)
+{
+ return PrintfState<T&, char>(device, format.c_str());
+}
+
+template <class Char, std::size_t N>
+PrintfState<std::pair<Char*, std::size_t>, Char>
+BufPrintf(Char (&buf)[N], const Char* format)
+{
+ std::pair<Char*, std::size_t> temp(buf, N);
+ return PrintfState<std::pair<Char*, std::size_t>, Char>(temp, format);
+}
}// namespace Loki
diff --git a/shared/loki/ScopeGuard.h b/shared/loki/ScopeGuard.h
index b530068d..0b5445f5 100644
--- a/shared/loki/ScopeGuard.h
+++ b/shared/loki/ScopeGuard.h
@@ -4,12 +4,12 @@
// Copyright (c) 2000 Petru Marginean
// Copyright (c) 2005 Joshua Lehrer
//
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_SCOPEGUARD_INC_
@@ -25,634 +25,634 @@
namespace Loki
{
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ScopeGuardImplBase
- /// \ingroup ExceptionGroup
- ///
- /// Base class used by all ScopeGuard implementations. All commonly used
- /// functions are in this class (e.g. - Dismiss and SafeExecute).
- ///
- /// See Andrei's and Petru Marginean's CUJ article
- /// http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm
- ///
- /// Changes to the original code by Joshua Lehrer:
- /// http://www.lehrerfamily.com/scopeguard.html
- ////////////////////////////////////////////////////////////////
-
- class ScopeGuardImplBase
- {
- /// Copy-assignment operator is not implemented and private.
- ScopeGuardImplBase& operator =(const ScopeGuardImplBase&);
-
- protected:
-
- ~ScopeGuardImplBase()
- {}
-
- /// Copy-constructor takes over responsibility from other ScopeGuard.
- ScopeGuardImplBase(const ScopeGuardImplBase& other) throw()
- : dismissed_(other.dismissed_)
- {
- other.Dismiss();
- }
-
- template <typename J>
- static void SafeExecute(J& j) throw()
- {
- if (!j.dismissed_)
- try
- {
- j.Execute();
- }
- catch(...)
+////////////////////////////////////////////////////////////////
+///
+/// \class ScopeGuardImplBase
+/// \ingroup ExceptionGroup
+///
+/// Base class used by all ScopeGuard implementations. All commonly used
+/// functions are in this class (e.g. - Dismiss and SafeExecute).
+///
+/// See Andrei's and Petru Marginean's CUJ article
+/// http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm
+///
+/// Changes to the original code by Joshua Lehrer:
+/// http://www.lehrerfamily.com/scopeguard.html
+////////////////////////////////////////////////////////////////
+
+class ScopeGuardImplBase
+{
+ /// Copy-assignment operator is not implemented and private.
+ ScopeGuardImplBase& operator =(const ScopeGuardImplBase&);
+
+protected:
+
+ ~ScopeGuardImplBase()
+ {}
+
+ /// Copy-constructor takes over responsibility from other ScopeGuard.
+ ScopeGuardImplBase(const ScopeGuardImplBase& other) throw()
+ : dismissed_(other.dismissed_)
+ {
+ other.Dismiss();
+ }
+
+ template <typename J>
+ static void SafeExecute(J& j) throw()
+ {
+ if (!j.dismissed_)
+ try
+ {
+ j.Execute();
+ }
+ catch(...)
{}
- }
-
- mutable bool dismissed_;
-
- public:
- ScopeGuardImplBase() throw() : dismissed_(false)
- {}
-
- void Dismiss() const throw()
- {
- dismissed_ = true;
- }
- };
-
- ////////////////////////////////////////////////////////////////
- ///
- /// \typedef typedef const ScopeGuardImplBase& ScopeGuard
- /// \ingroup ExceptionGroup
- ///
- ////////////////////////////////////////////////////////////////
-
- typedef const ScopeGuardImplBase& ScopeGuard;
-
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ScopeGuardImpl0
- /// \ingroup ExceptionGroup
- ///
- /// Implementation class for a standalone function or class static function
- /// with no parameters. ScopeGuard ignores any value returned from the
- /// call within the Execute function.
- ///
- /// This class has a single standalone helper function, MakeGuard which
- /// creates and returns a ScopeGuard.
- ///
- ////////////////////////////////////////////////////////////////
-
- template <typename F>
- class ScopeGuardImpl0 : public ScopeGuardImplBase
- {
- public:
- static ScopeGuardImpl0<F> MakeGuard(F fun)
- {
- return ScopeGuardImpl0<F>(fun);
- }
-
- ~ScopeGuardImpl0() throw()
- {
- SafeExecute(*this);
- }
-
- void Execute()
- {
- fun_();
- }
-
- protected:
- ScopeGuardImpl0(F fun) : fun_(fun)
- {}
-
- F fun_;
- };
-
- template <typename F>
- inline ScopeGuardImpl0<F> MakeGuard(F fun)
- {
- return ScopeGuardImpl0<F>::MakeGuard(fun);
- }
-
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ScopeGuardImpl1
- /// \ingroup ExceptionGroup
- ///
- /// Implementation class for a standalone function or class static function
- /// with one parameter. Each parameter is copied by value - use
- /// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
- /// any value returned from the call within the Execute function.
- ///
- /// This class has a single standalone helper function, MakeGuard which
- /// creates and returns a ScopeGuard.
- ///
- ////////////////////////////////////////////////////////////////
-
- template <typename F, typename P1>
- class ScopeGuardImpl1 : public ScopeGuardImplBase
- {
- public:
- static ScopeGuardImpl1<F, P1> MakeGuard(F fun, P1 p1)
- {
- return ScopeGuardImpl1<F, P1>(fun, p1);
- }
-
- ~ScopeGuardImpl1() throw()
- {
- SafeExecute(*this);
- }
-
- void Execute()
- {
- fun_(p1_);
- }
-
- protected:
- ScopeGuardImpl1(F fun, P1 p1) : fun_(fun), p1_(p1)
- {}
-
- F fun_;
- const P1 p1_;
- };
-
- template <typename F, typename P1>
- inline ScopeGuardImpl1<F, P1> MakeGuard(F fun, P1 p1)
- {
- return ScopeGuardImpl1<F, P1>::MakeGuard(fun, p1);
- }
-
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ScopeGuardImpl2
- /// \ingroup ExceptionGroup
- ///
- /// Implementation class for a standalone function or class static function
- /// with two parameters. Each parameter is copied by value - use
- /// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
- /// any value returned from the call within the Execute function.
- ///
- /// This class has a single standalone helper function, MakeGuard which
- /// creates and returns a ScopeGuard.
- ///
- ////////////////////////////////////////////////////////////////
-
- template <typename F, typename P1, typename P2>
- class ScopeGuardImpl2: public ScopeGuardImplBase
- {
- public:
- static ScopeGuardImpl2<F, P1, P2> MakeGuard(F fun, P1 p1, P2 p2)
- {
- return ScopeGuardImpl2<F, P1, P2>(fun, p1, p2);
- }
-
- ~ScopeGuardImpl2() throw()
- {
- SafeExecute(*this);
- }
-
- void Execute()
- {
- fun_(p1_, p2_);
- }
-
- protected:
- ScopeGuardImpl2(F fun, P1 p1, P2 p2) : fun_(fun), p1_(p1), p2_(p2)
- {}
-
- F fun_;
- const P1 p1_;
- const P2 p2_;
- };
-
- template <typename F, typename P1, typename P2>
- inline ScopeGuardImpl2<F, P1, P2> MakeGuard(F fun, P1 p1, P2 p2)
- {
- return ScopeGuardImpl2<F, P1, P2>::MakeGuard(fun, p1, p2);
- }
-
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ScopeGuardImpl3
- /// \ingroup ExceptionGroup
- ///
- /// Implementation class for a standalone function or class static function
- /// with three parameters. Each parameter is copied by value - use
- /// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
- /// any value returned from the call within the Execute function.
- ///
- /// This class has a single standalone helper function, MakeGuard which
- /// creates and returns a ScopeGuard.
- ///
- ////////////////////////////////////////////////////////////////
-
- template <typename F, typename P1, typename P2, typename P3>
- class ScopeGuardImpl3 : public ScopeGuardImplBase
- {
- public:
- static ScopeGuardImpl3<F, P1, P2, P3> MakeGuard(F fun, P1 p1, P2 p2, P3 p3)
- {
- return ScopeGuardImpl3<F, P1, P2, P3>(fun, p1, p2, p3);
- }
-
- ~ScopeGuardImpl3() throw()
- {
- SafeExecute(*this);
- }
-
- void Execute()
- {
- fun_(p1_, p2_, p3_);
- }
-
- protected:
- ScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) : fun_(fun), p1_(p1), p2_(p2), p3_(p3)
- {}
-
- F fun_;
- const P1 p1_;
- const P2 p2_;
- const P3 p3_;
- };
-
- template <typename F, typename P1, typename P2, typename P3>
- inline ScopeGuardImpl3<F, P1, P2, P3> MakeGuard(F fun, P1 p1, P2 p2, P3 p3)
- {
- return ScopeGuardImpl3<F, P1, P2, P3>::MakeGuard(fun, p1, p2, p3);
- }
-
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ScopeGuardImpl4
- /// \ingroup ExceptionGroup
- ///
- /// Implementation class for a standalone function or class static function
- /// with four parameters. Each parameter is copied by value - use
- /// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
- /// any value returned from the call within the Execute function.
- ///
- /// This class has a single standalone helper function, MakeGuard which
- /// creates and returns a ScopeGuard.
- ///
- ////////////////////////////////////////////////////////////////
-
- template < typename F, typename P1, typename P2, typename P3, typename P4 >
- class ScopeGuardImpl4 : public ScopeGuardImplBase
- {
- public:
- static ScopeGuardImpl4< F, P1, P2, P3, P4 > MakeGuard(
- F fun, P1 p1, P2 p2, P3 p3, P4 p4 )
- {
- return ScopeGuardImpl4< F, P1, P2, P3, P4 >( fun, p1, p2, p3, p4 );
- }
-
- ~ScopeGuardImpl4() throw()
- {
- SafeExecute( *this );
- }
-
- void Execute()
- {
- fun_( p1_, p2_, p3_, p4_ );
- }
-
- protected:
- ScopeGuardImpl4( F fun, P1 p1, P2 p2, P3 p3, P4 p4 ) :
- fun_( fun ), p1_( p1 ), p2_( p2 ), p3_( p3 ), p4_( p4 )
- {}
-
- F fun_;
- const P1 p1_;
- const P2 p2_;
- const P3 p3_;
- const P4 p4_;
- };
-
- template < typename F, typename P1, typename P2, typename P3, typename P4 >
- inline ScopeGuardImpl4< F, P1, P2, P3, P4 > MakeGuard( F fun, P1 p1, P2 p2, P3 p3, P4 p4 )
- {
- return ScopeGuardImpl4< F, P1, P2, P3, P4 >::MakeGuard( fun, p1, p2, p3, p4 );
- }
-
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ScopeGuardImpl5
- /// \ingroup ExceptionGroup
- ///
- /// Implementation class for a standalone function or class static function
- /// with five parameters. Each parameter is copied by value - use
- /// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
- /// any value returned from the call within the Execute function.
- ///
- /// This class has a single standalone helper function, MakeGuard which
- /// creates and returns a ScopeGuard.
- ///
- ////////////////////////////////////////////////////////////////
-
- template < typename F, typename P1, typename P2, typename P3, typename P4, typename P5 >
- class ScopeGuardImpl5 : public ScopeGuardImplBase
- {
- public:
- static ScopeGuardImpl5< F, P1, P2, P3, P4, P5 > MakeGuard(
- F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 )
- {
- return ScopeGuardImpl5< F, P1, P2, P3, P4, P5 >( fun, p1, p2, p3, p4, p5 );
- }
-
- ~ScopeGuardImpl5() throw()
- {
- SafeExecute( *this );
- }
-
- void Execute()
- {
- fun_( p1_, p2_, p3_, p4_, p5_ );
- }
-
- protected:
- ScopeGuardImpl5( F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 ) :
- fun_( fun ), p1_( p1 ), p2_( p2 ), p3_( p3 ), p4_( p4 ), p5_( p5 )
- {}
-
- F fun_;
- const P1 p1_;
- const P2 p2_;
- const P3 p3_;
- const P4 p4_;
- const P5 p5_;
- };
-
- template < typename F, typename P1, typename P2, typename P3, typename P4, typename P5 >
- inline ScopeGuardImpl5< F, P1, P2, P3, P4, P5 > MakeGuard( F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 )
- {
- return ScopeGuardImpl5< F, P1, P2, P3, P4, P5 >::MakeGuard( fun, p1, p2, p3, p4, p5 );
- }
-
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ObjScopeGuardImpl0
- /// \ingroup ExceptionGroup
- ///
- /// Implementation class for a class per-instance member function with no
- /// parameters. ScopeGuard ignores any value returned from the call within
- /// the Execute function.
- ///
- /// This class has 3 standalone helper functions which create a ScopeGuard.
- /// One is MakeObjGuard, which is deprecated but provided for older code.
- /// The other two are MakeGuard overloads, one which takes a pointer to an
- /// object, and the other which takes a reference.
- ///
- ////////////////////////////////////////////////////////////////
-
- template <class Obj, typename MemFun>
- class ObjScopeGuardImpl0 : public ScopeGuardImplBase
- {
- public:
- static ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun)
- {
- return ObjScopeGuardImpl0<Obj, MemFun>(obj, memFun);
- }
-
- ~ObjScopeGuardImpl0() throw()
- {
- SafeExecute(*this);
- }
-
- void Execute()
- {
- (obj_.*memFun_)();
- }
-
- protected:
- ObjScopeGuardImpl0(Obj& obj, MemFun memFun) : obj_(obj), memFun_(memFun)
- {}
-
- Obj& obj_;
- MemFun memFun_;
- };
-
- template <class Obj, typename MemFun>
- inline ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun)
- {
- return ObjScopeGuardImpl0<Obj, MemFun>::MakeObjGuard(obj, memFun);
- }
-
- template <typename Ret, class Obj1, class Obj2>
- inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1 &obj)
- {
- return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(obj,memFun);
- }
-
- template <typename Ret, class Obj1, class Obj2>
- inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1 *obj)
- {
- return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(*obj,memFun);
- }
-
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ObjScopeGuardImpl1
- /// \ingroup ExceptionGroup
- ///
- /// Implementation class for a class per-instance member function with one
- /// parameter. The parameter is copied by value - use ::Loki::ByRef if you
- /// must use a reference instead. ScopeGuard ignores any value returned
- /// from the call within the Execute function.
- ///
- /// This class has 3 standalone helper functions which create a ScopeGuard.
- /// One is MakeObjGuard, which is deprecated but provided for older code.
- /// The other two are MakeGuard overloads, one which takes a pointer to an
- /// object, and the other which takes a reference.
- ///
- ////////////////////////////////////////////////////////////////
-
- template <class Obj, typename MemFun, typename P1>
- class ObjScopeGuardImpl1 : public ScopeGuardImplBase
- {
- public:
- static ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1)
- {
- return ObjScopeGuardImpl1<Obj, MemFun, P1>(obj, memFun, p1);
- }
+ }
+
+ mutable bool dismissed_;
+
+public:
+ ScopeGuardImplBase() throw() : dismissed_(false)
+ {}
+
+ void Dismiss() const throw()
+ {
+ dismissed_ = true;
+ }
+};
+
+////////////////////////////////////////////////////////////////
+///
+/// \typedef typedef const ScopeGuardImplBase& ScopeGuard
+/// \ingroup ExceptionGroup
+///
+////////////////////////////////////////////////////////////////
+
+typedef const ScopeGuardImplBase& ScopeGuard;
+
+////////////////////////////////////////////////////////////////
+///
+/// \class ScopeGuardImpl0
+/// \ingroup ExceptionGroup
+///
+/// Implementation class for a standalone function or class static function
+/// with no parameters. ScopeGuard ignores any value returned from the
+/// call within the Execute function.
+///
+/// This class has a single standalone helper function, MakeGuard which
+/// creates and returns a ScopeGuard.
+///
+////////////////////////////////////////////////////////////////
+
+template <typename F>
+class ScopeGuardImpl0 : public ScopeGuardImplBase
+{
+public:
+ static ScopeGuardImpl0<F> MakeGuard(F fun)
+ {
+ return ScopeGuardImpl0<F>(fun);
+ }
- ~ObjScopeGuardImpl1() throw()
- {
- SafeExecute(*this);
- }
+ ~ScopeGuardImpl0() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ fun_();
+ }
- void Execute()
- {
- (obj_.*memFun_)(p1_);
- }
+protected:
+ ScopeGuardImpl0(F fun) : fun_(fun)
+ {}
- protected:
- ObjScopeGuardImpl1(Obj& obj, MemFun memFun, P1 p1) : obj_(obj), memFun_(memFun), p1_(p1)
- {}
-
- Obj& obj_;
- MemFun memFun_;
- const P1 p1_;
- };
-
- template <class Obj, typename MemFun, typename P1>
- inline ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1)
- {
- return ObjScopeGuardImpl1<Obj, MemFun, P1>::MakeObjGuard(obj, memFun, p1);
- }
-
- template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b>
- inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1 &obj, P1b p1)
+ F fun_;
+};
+
+template <typename F>
+inline ScopeGuardImpl0<F> MakeGuard(F fun)
+{
+ return ScopeGuardImpl0<F>::MakeGuard(fun);
+}
+
+////////////////////////////////////////////////////////////////
+///
+/// \class ScopeGuardImpl1
+/// \ingroup ExceptionGroup
+///
+/// Implementation class for a standalone function or class static function
+/// with one parameter. Each parameter is copied by value - use
+/// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
+/// any value returned from the call within the Execute function.
+///
+/// This class has a single standalone helper function, MakeGuard which
+/// creates and returns a ScopeGuard.
+///
+////////////////////////////////////////////////////////////////
+
+template <typename F, typename P1>
+class ScopeGuardImpl1 : public ScopeGuardImplBase
+{
+public:
+ static ScopeGuardImpl1<F, P1> MakeGuard(F fun, P1 p1)
{
- return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(obj,memFun,p1);
- }
-
- template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b>
- inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1 *obj, P1b p1)
- {
- return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(*obj,memFun,p1);
- }
-
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ObjScopeGuardImpl2
- /// \ingroup ExceptionGroup
- ///
- /// Implementation class for a class per-instance member function with two
- /// parameters. Each parameter is copied by value - use ::Loki::ByRef if you
- /// must use a reference instead. ScopeGuard ignores any value returned
- /// from the call within the Execute function.
- ///
- /// This class has 3 standalone helper functions which create a ScopeGuard.
- /// One is MakeObjGuard, which is deprecated but provided for older code.
- /// The other two are MakeGuard overloads, one which takes a pointer to an
- /// object, and the other which takes a reference.
- ///
- ////////////////////////////////////////////////////////////////
-
- template <class Obj, typename MemFun, typename P1, typename P2>
- class ObjScopeGuardImpl2 : public ScopeGuardImplBase
- {
- public:
- static ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2)
- {
- return ObjScopeGuardImpl2<Obj, MemFun, P1, P2>(obj, memFun, p1, p2);
- }
-
- ~ObjScopeGuardImpl2() throw()
- {
- SafeExecute(*this);
- }
-
- void Execute()
- {
- (obj_.*memFun_)(p1_, p2_);
- }
-
- protected:
- ObjScopeGuardImpl2(Obj& obj, MemFun memFun, P1 p1, P2 p2) : obj_(obj), memFun_(memFun), p1_(p1), p2_(p2)
- {}
-
- Obj& obj_;
- MemFun memFun_;
- const P1 p1_;
- const P2 p2_;
- };
-
- template <class Obj, typename MemFun, typename P1, typename P2>
- inline ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2)
- {
- return ObjScopeGuardImpl2<Obj, MemFun, P1, P2>::MakeObjGuard(obj, memFun, p1, p2);
- }
+ return ScopeGuardImpl1<F, P1>(fun, p1);
+ }
- template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b, typename P2a, typename P2b>
- inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1 &obj, P1b p1, P2b p2)
- {
- return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(obj,memFun,p1,p2);
+ ~ScopeGuardImpl1() throw()
+ {
+ SafeExecute(*this);
}
-
- template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b, typename P2a, typename P2b>
- inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1 *obj, P1b p1, P2b p2)
+
+ void Execute()
{
- return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(*obj,memFun,p1,p2);
+ fun_(p1_);
}
- ////////////////////////////////////////////////////////////////
- ///
- /// \class ObjScopeGuardImpl3
- /// \ingroup ExceptionGroup
- ///
- /// Implementation class for a class per-instance member function with three
- /// parameters. Each parameter is copied by value - use ::Loki::ByRef if you
- /// must use a reference instead. ScopeGuard ignores any value returned
- /// from the call within the Execute function.
- ///
- /// This class has 3 standalone helper functions which create a ScopeGuard.
- /// One is MakeObjGuard, which is deprecated but provided for older code.
- /// The other two are MakeGuard overloads, one which takes a pointer to an
- /// object, and the other which takes a reference.
- ///
- ////////////////////////////////////////////////////////////////
+protected:
+ ScopeGuardImpl1(F fun, P1 p1) : fun_(fun), p1_(p1)
+ {}
- template < class Obj, typename MemFun, typename P1, typename P2, typename P3 >
- class ObjScopeGuardImpl3 : public ScopeGuardImplBase
+ F fun_;
+ const P1 p1_;
+};
+
+template <typename F, typename P1>
+inline ScopeGuardImpl1<F, P1> MakeGuard(F fun, P1 p1)
+{
+ return ScopeGuardImpl1<F, P1>::MakeGuard(fun, p1);
+}
+
+////////////////////////////////////////////////////////////////
+///
+/// \class ScopeGuardImpl2
+/// \ingroup ExceptionGroup
+///
+/// Implementation class for a standalone function or class static function
+/// with two parameters. Each parameter is copied by value - use
+/// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
+/// any value returned from the call within the Execute function.
+///
+/// This class has a single standalone helper function, MakeGuard which
+/// creates and returns a ScopeGuard.
+///
+////////////////////////////////////////////////////////////////
+
+template <typename F, typename P1, typename P2>
+class ScopeGuardImpl2: public ScopeGuardImplBase
+{
+public:
+ static ScopeGuardImpl2<F, P1, P2> MakeGuard(F fun, P1 p1, P2 p2)
{
- public:
- static ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 > MakeObjGuard(
- Obj & obj, MemFun memFun, P1 p1, P2 p2, P3 p3 )
- {
- return ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 >( obj, memFun, p1, p2, p3 );
- }
+ return ScopeGuardImpl2<F, P1, P2>(fun, p1, p2);
+ }
- ~ObjScopeGuardImpl3() throw()
- {
- SafeExecute( *this );
- }
-
- void Execute()
- {
- ( obj_.*memFun_ )( p1_, p2_, p3_ );
- }
-
- protected:
- ObjScopeGuardImpl3( Obj & obj, MemFun memFun, P1 p1, P2 p2, P3 p3 ) :
- obj_( obj ), memFun_( memFun ), p1_( p1 ), p2_( p2 ), p3_( p3 )
- {}
-
- Obj& obj_;
- MemFun memFun_;
- const P1 p1_;
- const P2 p2_;
- const P3 p3_;
- };
+ ~ScopeGuardImpl2() throw()
+ {
+ SafeExecute(*this);
+ }
- template < class Obj, typename MemFun, typename P1, typename P2, typename P3 >
- inline ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 > MakeObjGuard(
- Obj & obj, MemFun memFun, P1 p1, P2 p2, P3 p3 )
+ void Execute()
+ {
+ fun_(p1_, p2_);
+ }
+
+protected:
+ ScopeGuardImpl2(F fun, P1 p1, P2 p2) : fun_(fun), p1_(p1), p2_(p2)
+ {}
+
+ F fun_;
+ const P1 p1_;
+ const P2 p2_;
+};
+
+template <typename F, typename P1, typename P2>
+inline ScopeGuardImpl2<F, P1, P2> MakeGuard(F fun, P1 p1, P2 p2)
+{
+ return ScopeGuardImpl2<F, P1, P2>::MakeGuard(fun, p1, p2);
+}
+
+////////////////////////////////////////////////////////////////
+///
+/// \class ScopeGuardImpl3
+/// \ingroup ExceptionGroup
+///
+/// Implementation class for a standalone function or class static function
+/// with three parameters. Each parameter is copied by value - use
+/// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
+/// any value returned from the call within the Execute function.
+///
+/// This class has a single standalone helper function, MakeGuard which
+/// creates and returns a ScopeGuard.
+///
+////////////////////////////////////////////////////////////////
+
+template <typename F, typename P1, typename P2, typename P3>
+class ScopeGuardImpl3 : public ScopeGuardImplBase
+{
+public:
+ static ScopeGuardImpl3<F, P1, P2, P3> MakeGuard(F fun, P1 p1, P2 p2, P3 p3)
+ {
+ return ScopeGuardImpl3<F, P1, P2, P3>(fun, p1, p2, p3);
+ }
+
+ ~ScopeGuardImpl3() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ fun_(p1_, p2_, p3_);
+ }
+
+protected:
+ ScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) : fun_(fun), p1_(p1), p2_(p2), p3_(p3)
+ {}
+
+ F fun_;
+ const P1 p1_;
+ const P2 p2_;
+ const P3 p3_;
+};
+
+template <typename F, typename P1, typename P2, typename P3>
+inline ScopeGuardImpl3<F, P1, P2, P3> MakeGuard(F fun, P1 p1, P2 p2, P3 p3)
+{
+ return ScopeGuardImpl3<F, P1, P2, P3>::MakeGuard(fun, p1, p2, p3);
+}
+
+////////////////////////////////////////////////////////////////
+///
+/// \class ScopeGuardImpl4
+/// \ingroup ExceptionGroup
+///
+/// Implementation class for a standalone function or class static function
+/// with four parameters. Each parameter is copied by value - use
+/// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
+/// any value returned from the call within the Execute function.
+///
+/// This class has a single standalone helper function, MakeGuard which
+/// creates and returns a ScopeGuard.
+///
+////////////////////////////////////////////////////////////////
+
+template < typename F, typename P1, typename P2, typename P3, typename P4 >
+class ScopeGuardImpl4 : public ScopeGuardImplBase
+{
+public:
+ static ScopeGuardImpl4< F, P1, P2, P3, P4 > MakeGuard(
+ F fun, P1 p1, P2 p2, P3 p3, P4 p4 )
+ {
+ return ScopeGuardImpl4< F, P1, P2, P3, P4 >( fun, p1, p2, p3, p4 );
+ }
+
+ ~ScopeGuardImpl4() throw()
+ {
+ SafeExecute( *this );
+ }
+
+ void Execute()
+ {
+ fun_( p1_, p2_, p3_, p4_ );
+ }
+
+protected:
+ ScopeGuardImpl4( F fun, P1 p1, P2 p2, P3 p3, P4 p4 ) :
+ fun_( fun ), p1_( p1 ), p2_( p2 ), p3_( p3 ), p4_( p4 )
+ {}
+
+ F fun_;
+ const P1 p1_;
+ const P2 p2_;
+ const P3 p3_;
+ const P4 p4_;
+};
+
+template < typename F, typename P1, typename P2, typename P3, typename P4 >
+inline ScopeGuardImpl4< F, P1, P2, P3, P4 > MakeGuard( F fun, P1 p1, P2 p2, P3 p3, P4 p4 )
+{
+ return ScopeGuardImpl4< F, P1, P2, P3, P4 >::MakeGuard( fun, p1, p2, p3, p4 );
+}
+
+////////////////////////////////////////////////////////////////
+///
+/// \class ScopeGuardImpl5
+/// \ingroup ExceptionGroup
+///
+/// Implementation class for a standalone function or class static function
+/// with five parameters. Each parameter is copied by value - use
+/// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
+/// any value returned from the call within the Execute function.
+///
+/// This class has a single standalone helper function, MakeGuard which
+/// creates and returns a ScopeGuard.
+///
+////////////////////////////////////////////////////////////////
+
+template < typename F, typename P1, typename P2, typename P3, typename P4, typename P5 >
+class ScopeGuardImpl5 : public ScopeGuardImplBase
+{
+public:
+ static ScopeGuardImpl5< F, P1, P2, P3, P4, P5 > MakeGuard(
+ F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 )
{
- return ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 >::MakeObjGuard(
- obj, memFun, p1, p2, p3 );
+ return ScopeGuardImpl5< F, P1, P2, P3, P4, P5 >( fun, p1, p2, p3, p4, p5 );
}
- template < typename Ret, class Obj1, class Obj2, typename P1a, typename P1b,
- typename P2a, typename P2b, typename P3a, typename P3b >
- inline ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
- MakeGuard( Ret( Obj2::*memFun )( P1a, P2a, P3a ), Obj1 & obj, P1b p1, P2b p2, P3b p3 )
+ ~ScopeGuardImpl5() throw()
{
- return ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
- ::MakeObjGuard( obj, memFun, p1, p2, p3 );
+ SafeExecute( *this );
}
- template < typename Ret, class Obj1, class Obj2, typename P1a, typename P1b,
- typename P2a, typename P2b, typename P3a, typename P3b >
- inline ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
- MakeGuard( Ret( Obj2::*memFun )( P1a, P2a, P3a ), Obj1 * obj, P1b p1, P2b p2, P3b p3 )
+ void Execute()
{
- return ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
- ::MakeObjGuard( *obj, memFun, p1, p2, p3 );
+ fun_( p1_, p2_, p3_, p4_, p5_ );
}
+protected:
+ ScopeGuardImpl5( F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 ) :
+ fun_( fun ), p1_( p1 ), p2_( p2 ), p3_( p3 ), p4_( p4 ), p5_( p5 )
+ {}
+
+ F fun_;
+ const P1 p1_;
+ const P2 p2_;
+ const P3 p3_;
+ const P4 p4_;
+ const P5 p5_;
+};
+
+template < typename F, typename P1, typename P2, typename P3, typename P4, typename P5 >
+inline ScopeGuardImpl5< F, P1, P2, P3, P4, P5 > MakeGuard( F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 )
+{
+ return ScopeGuardImpl5< F, P1, P2, P3, P4, P5 >::MakeGuard( fun, p1, p2, p3, p4, p5 );
+}
+
+////////////////////////////////////////////////////////////////
+///
+/// \class ObjScopeGuardImpl0
+/// \ingroup ExceptionGroup
+///
+/// Implementation class for a class per-instance member function with no
+/// parameters. ScopeGuard ignores any value returned from the call within
+/// the Execute function.
+///
+/// This class has 3 standalone helper functions which create a ScopeGuard.
+/// One is MakeObjGuard, which is deprecated but provided for older code.
+/// The other two are MakeGuard overloads, one which takes a pointer to an
+/// object, and the other which takes a reference.
+///
+////////////////////////////////////////////////////////////////
+
+template <class Obj, typename MemFun>
+class ObjScopeGuardImpl0 : public ScopeGuardImplBase
+{
+public:
+ static ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun)
+ {
+ return ObjScopeGuardImpl0<Obj, MemFun>(obj, memFun);
+ }
+
+ ~ObjScopeGuardImpl0() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ (obj_.*memFun_)();
+ }
+
+protected:
+ ObjScopeGuardImpl0(Obj& obj, MemFun memFun) : obj_(obj), memFun_(memFun)
+ {}
+
+ Obj& obj_;
+ MemFun memFun_;
+};
+
+template <class Obj, typename MemFun>
+inline ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun)
+{
+ return ObjScopeGuardImpl0<Obj, MemFun>::MakeObjGuard(obj, memFun);
+}
+
+template <typename Ret, class Obj1, class Obj2>
+inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1& obj)
+{
+ return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(obj,memFun);
+}
+
+template <typename Ret, class Obj1, class Obj2>
+inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1* obj)
+{
+ return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(*obj,memFun);
+}
+
+////////////////////////////////////////////////////////////////
+///
+/// \class ObjScopeGuardImpl1
+/// \ingroup ExceptionGroup
+///
+/// Implementation class for a class per-instance member function with one
+/// parameter. The parameter is copied by value - use ::Loki::ByRef if you
+/// must use a reference instead. ScopeGuard ignores any value returned
+/// from the call within the Execute function.
+///
+/// This class has 3 standalone helper functions which create a ScopeGuard.
+/// One is MakeObjGuard, which is deprecated but provided for older code.
+/// The other two are MakeGuard overloads, one which takes a pointer to an
+/// object, and the other which takes a reference.
+///
+////////////////////////////////////////////////////////////////
+
+template <class Obj, typename MemFun, typename P1>
+class ObjScopeGuardImpl1 : public ScopeGuardImplBase
+{
+public:
+ static ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1)
+ {
+ return ObjScopeGuardImpl1<Obj, MemFun, P1>(obj, memFun, p1);
+ }
+
+ ~ObjScopeGuardImpl1() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ (obj_.*memFun_)(p1_);
+ }
+
+protected:
+ ObjScopeGuardImpl1(Obj& obj, MemFun memFun, P1 p1) : obj_(obj), memFun_(memFun), p1_(p1)
+ {}
+
+ Obj& obj_;
+ MemFun memFun_;
+ const P1 p1_;
+};
+
+template <class Obj, typename MemFun, typename P1>
+inline ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1)
+{
+ return ObjScopeGuardImpl1<Obj, MemFun, P1>::MakeObjGuard(obj, memFun, p1);
+}
+
+template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b>
+inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1& obj, P1b p1)
+{
+ return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(obj,memFun,p1);
+}
+
+template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b>
+inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1* obj, P1b p1)
+{
+ return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(*obj,memFun,p1);
+}
+
+////////////////////////////////////////////////////////////////
+///
+/// \class ObjScopeGuardImpl2
+/// \ingroup ExceptionGroup
+///
+/// Implementation class for a class per-instance member function with two
+/// parameters. Each parameter is copied by value - use ::Loki::ByRef if you
+/// must use a reference instead. ScopeGuard ignores any value returned
+/// from the call within the Execute function.
+///
+/// This class has 3 standalone helper functions which create a ScopeGuard.
+/// One is MakeObjGuard, which is deprecated but provided for older code.
+/// The other two are MakeGuard overloads, one which takes a pointer to an
+/// object, and the other which takes a reference.
+///
+////////////////////////////////////////////////////////////////
+
+template <class Obj, typename MemFun, typename P1, typename P2>
+class ObjScopeGuardImpl2 : public ScopeGuardImplBase
+{
+public:
+ static ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2)
+ {
+ return ObjScopeGuardImpl2<Obj, MemFun, P1, P2>(obj, memFun, p1, p2);
+ }
+
+ ~ObjScopeGuardImpl2() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ (obj_.*memFun_)(p1_, p2_);
+ }
+
+protected:
+ ObjScopeGuardImpl2(Obj& obj, MemFun memFun, P1 p1, P2 p2) : obj_(obj), memFun_(memFun), p1_(p1), p2_(p2)
+ {}
+
+ Obj& obj_;
+ MemFun memFun_;
+ const P1 p1_;
+ const P2 p2_;
+};
+
+template <class Obj, typename MemFun, typename P1, typename P2>
+inline ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2)
+{
+ return ObjScopeGuardImpl2<Obj, MemFun, P1, P2>::MakeObjGuard(obj, memFun, p1, p2);
+}
+
+template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b, typename P2a, typename P2b>
+inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1& obj, P1b p1, P2b p2)
+{
+ return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(obj,memFun,p1,p2);
+}
+
+template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b, typename P2a, typename P2b>
+inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1* obj, P1b p1, P2b p2)
+{
+ return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(*obj,memFun,p1,p2);
+}
+
+////////////////////////////////////////////////////////////////
+///
+/// \class ObjScopeGuardImpl3
+/// \ingroup ExceptionGroup
+///
+/// Implementation class for a class per-instance member function with three
+/// parameters. Each parameter is copied by value - use ::Loki::ByRef if you
+/// must use a reference instead. ScopeGuard ignores any value returned
+/// from the call within the Execute function.
+///
+/// This class has 3 standalone helper functions which create a ScopeGuard.
+/// One is MakeObjGuard, which is deprecated but provided for older code.
+/// The other two are MakeGuard overloads, one which takes a pointer to an
+/// object, and the other which takes a reference.
+///
+////////////////////////////////////////////////////////////////
+
+template < class Obj, typename MemFun, typename P1, typename P2, typename P3 >
+class ObjScopeGuardImpl3 : public ScopeGuardImplBase
+{
+public:
+ static ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 > MakeObjGuard(
+ Obj& obj, MemFun memFun, P1 p1, P2 p2, P3 p3 )
+ {
+ return ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 >( obj, memFun, p1, p2, p3 );
+ }
+
+ ~ObjScopeGuardImpl3() throw()
+ {
+ SafeExecute( *this );
+ }
+
+ void Execute()
+ {
+ ( obj_.*memFun_ )( p1_, p2_, p3_ );
+ }
+
+protected:
+ ObjScopeGuardImpl3( Obj& obj, MemFun memFun, P1 p1, P2 p2, P3 p3 ) :
+ obj_( obj ), memFun_( memFun ), p1_( p1 ), p2_( p2 ), p3_( p3 )
+ {}
+
+ Obj& obj_;
+ MemFun memFun_;
+ const P1 p1_;
+ const P2 p2_;
+ const P3 p3_;
+};
+
+template < class Obj, typename MemFun, typename P1, typename P2, typename P3 >
+inline ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 > MakeObjGuard(
+ Obj& obj, MemFun memFun, P1 p1, P2 p2, P3 p3 )
+{
+ return ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 >::MakeObjGuard(
+ obj, memFun, p1, p2, p3 );
+}
+
+template < typename Ret, class Obj1, class Obj2, typename P1a, typename P1b,
+ typename P2a, typename P2b, typename P3a, typename P3b >
+inline ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
+MakeGuard( Ret( Obj2::*memFun )( P1a, P2a, P3a ), Obj1& obj, P1b p1, P2b p2, P3b p3 )
+{
+ return ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
+ ::MakeObjGuard( obj, memFun, p1, p2, p3 );
+}
+
+template < typename Ret, class Obj1, class Obj2, typename P1a, typename P1b,
+ typename P2a, typename P2b, typename P3a, typename P3b >
+inline ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
+MakeGuard( Ret( Obj2::*memFun )( P1a, P2a, P3a ), Obj1* obj, P1b p1, P2b p2, P3b p3 )
+{
+ return ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
+ ::MakeObjGuard( *obj, memFun, p1, p2, p3 );
+}
+
} // namespace Loki
#define LOKI_CONCATENATE_DIRECT(s1, s2) s1##s2
diff --git a/shared/loki/Sequence.h b/shared/loki/Sequence.h
index 4e5bd235..e8c8bd35 100644
--- a/shared/loki/Sequence.h
+++ b/shared/loki/Sequence.h
@@ -1,12 +1,12 @@
////////////////////////////////////////////////////////////////////////////////
// The Loki Library
// Copyright (c) 2005 by Peter Kümmel
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author makes no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_SEQUENCE_INC_
@@ -20,28 +20,28 @@
namespace Loki
{
- template
- <
- class T01=NullType,class T02=NullType,class T03=NullType,class T04=NullType,class T05=NullType,
- class T06=NullType,class T07=NullType,class T08=NullType,class T09=NullType,class T10=NullType,
- class T11=NullType,class T12=NullType,class T13=NullType,class T14=NullType,class T15=NullType,
- class T16=NullType,class T17=NullType,class T18=NullType,class T19=NullType,class T20=NullType
- >
- struct Seq
- {
- private:
- typedef typename Seq< T02, T03, T04, T05, T06, T07, T08, T09, T10,
- T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>::Type
- TailResult;
- public:
- typedef Typelist<T01, TailResult> Type;
- };
-
- template<>
- struct Seq<>
- {
- typedef NullType Type;
- };
+template
+<
+class T01=NullType,class T02=NullType,class T03=NullType,class T04=NullType,class T05=NullType,
+ class T06=NullType,class T07=NullType,class T08=NullType,class T09=NullType,class T10=NullType,
+ class T11=NullType,class T12=NullType,class T13=NullType,class T14=NullType,class T15=NullType,
+ class T16=NullType,class T17=NullType,class T18=NullType,class T19=NullType,class T20=NullType
+ >
+struct Seq
+{
+private:
+ typedef typename Seq< T02, T03, T04, T05, T06, T07, T08, T09, T10,
+ T11, T12, T13, T14, T15, T16, T17, T18, T19, T20>::Type
+ TailResult;
+public:
+ typedef Typelist<T01, TailResult> Type;
+};
+
+template<>
+struct Seq<>
+{
+ typedef NullType Type;
+};
} // namespace Loki
diff --git a/shared/loki/Singleton.h b/shared/loki/Singleton.h
index 42d6eb0d..40cc7550 100644
--- a/shared/loki/Singleton.h
+++ b/shared/loki/Singleton.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_SINGLETON_INC_
@@ -30,9 +30,9 @@
#include <memory>
#ifdef _MSC_VER
-#define LOKI_C_CALLING_CONVENTION_QUALIFIER __cdecl
+#define LOKI_C_CALLING_CONVENTION_QUALIFIER __cdecl
#else
-#define LOKI_C_CALLING_CONVENTION_QUALIFIER
+#define LOKI_C_CALLING_CONVENTION_QUALIFIER
#endif
/// \defgroup SingletonGroup Singleton
@@ -42,7 +42,7 @@
/// \ingroup SingletonGroup
/// The lifetimes of the singleton.
/// \par Special lifetime for SmallObjects
-/// When the holded object is a Small(Value)Object or the holded object
+/// When the holded object is a Small(Value)Object or the holded object
/// uses objects which are or inherit from Small(Value)Object
/// then you can't use the default lifetime: you must use the lifetime
/// \code Loki::LongevityLifetime::DieAsSmallObjectChild \endcode
@@ -52,820 +52,820 @@
namespace Loki
{
- typedef void (LOKI_C_CALLING_CONVENTION_QUALIFIER *atexit_pfn_t)();
+typedef void (LOKI_C_CALLING_CONVENTION_QUALIFIER* atexit_pfn_t)();
- namespace Private
- {
+namespace Private
+{
#ifndef LOKI_MAKE_DLL
- void LOKI_C_CALLING_CONVENTION_QUALIFIER AtExitFn(); // declaration needed below
+void LOKI_C_CALLING_CONVENTION_QUALIFIER AtExitFn(); // declaration needed below
#else
- void LOKI_EXPORT AtExitFn();
+void LOKI_EXPORT AtExitFn();
#endif
- class LifetimeTracker;
+class LifetimeTracker;
-#define LOKI_ENABLE_NEW_SETLONGLIVITY_HELPER_DATA_IMPL
+#define LOKI_ENABLE_NEW_SETLONGLIVITY_HELPER_DATA_IMPL
#ifdef LOKI_ENABLE_NEW_SETLONGLIVITY_HELPER_DATA_IMPL
- // Helper data
- // std::list because of the inserts
- typedef std::list<LifetimeTracker*> TrackerArray;
- extern LOKI_EXPORT TrackerArray* pTrackerArray;
+// Helper data
+// std::list because of the inserts
+typedef std::list<LifetimeTracker*> TrackerArray;
+extern LOKI_EXPORT TrackerArray* pTrackerArray;
#else
- // Helper data
- typedef LifetimeTracker** TrackerArray;
- extern TrackerArray pTrackerArray;
- extern unsigned int elements;
+// Helper data
+typedef LifetimeTracker** TrackerArray;
+extern TrackerArray pTrackerArray;
+extern unsigned int elements;
#endif
- ////////////////////////////////////////////////////////////////////////////////
- // class LifetimeTracker
- // Helper class for SetLongevity
- ////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// class LifetimeTracker
+// Helper class for SetLongevity
+////////////////////////////////////////////////////////////////////////////////
- class LifetimeTracker
- {
- public:
- LifetimeTracker(unsigned int x) : longevity_(x)
- {}
-
- virtual ~LifetimeTracker() = 0;
-
- static bool Compare(const LifetimeTracker* lhs,
- const LifetimeTracker* rhs)
- {
- return lhs->longevity_ > rhs->longevity_;
- }
-
- private:
- unsigned int longevity_;
- };
-
- // Definition required
- inline LifetimeTracker::~LifetimeTracker() {}
+class LifetimeTracker
+{
+public:
+ LifetimeTracker(unsigned int x) : longevity_(x)
+ {}
- // Helper destroyer function
- template <typename T>
- struct Deleter
- {
- typedef void (*Type)(T*);
- static void Delete(T* pObj)
- { delete pObj; }
- };
+ virtual ~LifetimeTracker() = 0;
- // Concrete lifetime tracker for objects of type T
- template <typename T, typename Destroyer>
- class ConcreteLifetimeTracker : public LifetimeTracker
- {
- public:
- ConcreteLifetimeTracker(T* p,unsigned int longevity, Destroyer d)
- : LifetimeTracker(longevity)
- , pTracked_(p)
- , destroyer_(d)
- {}
-
- ~ConcreteLifetimeTracker()
- { destroyer_(pTracked_); }
-
- private:
- T* pTracked_;
- Destroyer destroyer_;
- };
+ static bool Compare(const LifetimeTracker* lhs,
+ const LifetimeTracker* rhs)
+ {
+ return lhs->longevity_ > rhs->longevity_;
+ }
- } // namespace Private
+private:
+ unsigned int longevity_;
+};
- ////////////////////////////////////////////////////////////////////////////////
- /// \ingroup LifetimeGroup
- ///
- /// Assigns an object a longevity; ensures ordered destructions of objects
- /// registered thusly during the exit sequence of the application
- ////////////////////////////////////////////////////////////////////////////////
+// Definition required
+inline LifetimeTracker::~LifetimeTracker() {}
+
+// Helper destroyer function
+template <typename T>
+struct Deleter
+{
+ typedef void (*Type)(T*);
+ static void Delete(T* pObj)
+ { delete pObj; }
+};
+
+// Concrete lifetime tracker for objects of type T
+template <typename T, typename Destroyer>
+class ConcreteLifetimeTracker : public LifetimeTracker
+{
+public:
+ ConcreteLifetimeTracker(T* p,unsigned int longevity, Destroyer d)
+ : LifetimeTracker(longevity)
+ , pTracked_(p)
+ , destroyer_(d)
+ {}
+
+ ~ConcreteLifetimeTracker()
+ { destroyer_(pTracked_); }
+
+private:
+ T* pTracked_;
+ Destroyer destroyer_;
+};
+
+} // namespace Private
+
+////////////////////////////////////////////////////////////////////////////////
+/// \ingroup LifetimeGroup
+///
+/// Assigns an object a longevity; ensures ordered destructions of objects
+/// registered thusly during the exit sequence of the application
+////////////////////////////////////////////////////////////////////////////////
#ifdef LOKI_ENABLE_NEW_SETLONGLIVITY_HELPER_DATA_IMPL
- template <typename T, typename Destroyer>
- void SetLongevity(T* pDynObject, unsigned int longevity,
- Destroyer d)
- {
- using namespace Private;
-
- // manage lifetime of stack manually
- if(pTrackerArray==0)
- pTrackerArray = new TrackerArray;
-
- // automatically delete the ConcreteLifetimeTracker object when a exception is thrown
- std::auto_ptr<LifetimeTracker>
- p( new ConcreteLifetimeTracker<T, Destroyer>(pDynObject, longevity, d) );
-
- // Find correct position
- TrackerArray::iterator pos = std::upper_bound(
- pTrackerArray->begin(),
- pTrackerArray->end(),
- p.get(),
- LifetimeTracker::Compare);
-
- // Insert the pointer to the ConcreteLifetimeTracker object into the queue
- pTrackerArray->insert(pos, p.get());
-
- // nothing has thrown: don't delete the ConcreteLifetimeTracker object
- p.release();
-
- // Register a call to AtExitFn
- std::atexit(Private::AtExitFn);
- }
+template <typename T, typename Destroyer>
+void SetLongevity(T* pDynObject, unsigned int longevity,
+ Destroyer d)
+{
+ using namespace Private;
+
+ // manage lifetime of stack manually
+ if(pTrackerArray==0)
+ pTrackerArray = new TrackerArray;
+
+ // automatically delete the ConcreteLifetimeTracker object when a exception is thrown
+ std::auto_ptr<LifetimeTracker>
+ p( new ConcreteLifetimeTracker<T, Destroyer>(pDynObject, longevity, d) );
+
+ // Find correct position
+ TrackerArray::iterator pos = std::upper_bound(
+ pTrackerArray->begin(),
+ pTrackerArray->end(),
+ p.get(),
+ LifetimeTracker::Compare);
+
+ // Insert the pointer to the ConcreteLifetimeTracker object into the queue
+ pTrackerArray->insert(pos, p.get());
+
+ // nothing has thrown: don't delete the ConcreteLifetimeTracker object
+ p.release();
+
+ // Register a call to AtExitFn
+ std::atexit(Private::AtExitFn);
+}
#else
-
- template <typename T, typename Destroyer>
- void SetLongevity(T* pDynObject, unsigned int longevity,
- Destroyer d)
- {
- using namespace Private;
-
- TrackerArray pNewArray = static_cast<TrackerArray>(
- std::realloc(pTrackerArray,
- sizeof(*pTrackerArray) * (elements + 1)));
- if (!pNewArray) throw std::bad_alloc();
-
- // Delayed assignment for exception safety
- pTrackerArray = pNewArray;
-
- LifetimeTracker* p = new ConcreteLifetimeTracker<T, Destroyer>(
- pDynObject, longevity, d);
-
- // Insert a pointer to the object into the queue
- TrackerArray pos = std::upper_bound(
- pTrackerArray,
- pTrackerArray + elements,
- p,
- LifetimeTracker::Compare);
- std::copy_backward(
- pos,
- pTrackerArray + elements,
- pTrackerArray + elements + 1);
- *pos = p;
- ++elements;
-
- // Register a call to AtExitFn
- std::atexit(Private::AtExitFn);
- }
+
+template <typename T, typename Destroyer>
+void SetLongevity(T* pDynObject, unsigned int longevity,
+ Destroyer d)
+{
+ using namespace Private;
+
+ TrackerArray pNewArray = static_cast<TrackerArray>(
+ std::realloc(pTrackerArray,
+ sizeof(*pTrackerArray) * (elements + 1)));
+ if (!pNewArray) throw std::bad_alloc();
+
+ // Delayed assignment for exception safety
+ pTrackerArray = pNewArray;
+
+ LifetimeTracker* p = new ConcreteLifetimeTracker<T, Destroyer>(
+ pDynObject, longevity, d);
+
+ // Insert a pointer to the object into the queue
+ TrackerArray pos = std::upper_bound(
+ pTrackerArray,
+ pTrackerArray + elements,
+ p,
+ LifetimeTracker::Compare);
+ std::copy_backward(
+ pos,
+ pTrackerArray + elements,
+ pTrackerArray + elements + 1);
+ *pos = p;
+ ++elements;
+
+ // Register a call to AtExitFn
+ std::atexit(Private::AtExitFn);
+}
#endif
- template <typename T>
- void SetLongevity(T* pDynObject, unsigned int longevity,
- typename Private::Deleter<T>::Type d = Private::Deleter<T>::Delete)
- {
- SetLongevity<T, typename Private::Deleter<T>::Type>(pDynObject, longevity, d);
- }
+template <typename T>
+void SetLongevity(T* pDynObject, unsigned int longevity,
+ typename Private::Deleter<T>::Type d = Private::Deleter<T>::Delete)
+{
+ SetLongevity<T, typename Private::Deleter<T>::Type>(pDynObject, longevity, d);
+}
- ////////////////////////////////////////////////////////////////////////////////
- /// \struct CreateUsingNew
- ///
- /// \ingroup CreationGroup
- /// Implementation of the CreationPolicy used by SingletonHolder
- /// Creates objects using a straight call to the new operator
- ////////////////////////////////////////////////////////////////////////////////
- template <class T> struct CreateUsingNew
- {
- static T* Create()
- { return new T; }
-
- static void Destroy(T* p)
- { delete p; }
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- /// \struct CreateUsing
- ///
- /// \ingroup CreationGroup
- /// Implementation of the CreationPolicy used by SingletonHolder
- /// Creates objects using a custom allocater.
- /// Usage: e.g. CreateUsing<std::allocator>::Allocator
- ////////////////////////////////////////////////////////////////////////////////
- template<template<class> class Alloc>
- struct CreateUsing
- {
- template <class T>
- struct Allocator
- {
- static Alloc<T> allocator;
+////////////////////////////////////////////////////////////////////////////////
+/// \struct CreateUsingNew
+///
+/// \ingroup CreationGroup
+/// Implementation of the CreationPolicy used by SingletonHolder
+/// Creates objects using a straight call to the new operator
+////////////////////////////////////////////////////////////////////////////////
+template <class T> struct CreateUsingNew
+{
+ static T* Create()
+ { return new T; }
- static T* Create()
- {
- return new (allocator.allocate(1)) T;
- }
+ static void Destroy(T* p)
+ { delete p; }
+};
- static void Destroy(T* p)
- {
- //allocator.destroy(p);
- p->~T();
- allocator.deallocate(p,1);
- }
- };
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- /// \struct CreateUsingMalloc
- ///
- /// \ingroup CreationGroup
- /// Implementation of the CreationPolicy used by SingletonHolder
- /// Creates objects using a call to std::malloc, followed by a call to the
- /// placement new operator
- ////////////////////////////////////////////////////////////////////////////////
- template <class T> struct CreateUsingMalloc
+////////////////////////////////////////////////////////////////////////////////
+/// \struct CreateUsing
+///
+/// \ingroup CreationGroup
+/// Implementation of the CreationPolicy used by SingletonHolder
+/// Creates objects using a custom allocater.
+/// Usage: e.g. CreateUsing<std::allocator>::Allocator
+////////////////////////////////////////////////////////////////////////////////
+template<template<class> class Alloc>
+struct CreateUsing
+{
+ template <class T>
+ struct Allocator
{
+ static Alloc<T> allocator;
+
static T* Create()
{
- void* p = std::malloc(sizeof(T));
- if (!p) return 0;
- return new(p) T;
+ return new (allocator.allocate(1)) T;
}
-
+
static void Destroy(T* p)
{
+ //allocator.destroy(p);
p->~T();
- std::free(p);
+ allocator.deallocate(p,1);
}
};
-
-
- ////////////////////////////////////////////////////////////////////////////////
- /// \struct CreateStatic
- ///
- /// \ingroup CreationGroup
- /// Implementation of the CreationPolicy used by SingletonHolder
- /// Creates an object in static memory
- /// Implementation is slightly nonportable because it uses the MaxAlign trick
- /// (an union of all types to ensure proper memory alignment). This trick is
- /// nonportable in theory but highly portable in practice.
- ////////////////////////////////////////////////////////////////////////////////
- template <class T> struct CreateStatic
+};
+
+////////////////////////////////////////////////////////////////////////////////
+/// \struct CreateUsingMalloc
+///
+/// \ingroup CreationGroup
+/// Implementation of the CreationPolicy used by SingletonHolder
+/// Creates objects using a call to std::malloc, followed by a call to the
+/// placement new operator
+////////////////////////////////////////////////////////////////////////////////
+template <class T> struct CreateUsingMalloc
+{
+ static T* Create()
{
-
+ void* p = std::malloc(sizeof(T));
+ if (!p) return 0;
+ return new(p) T;
+ }
+
+ static void Destroy(T* p)
+ {
+ p->~T();
+ std::free(p);
+ }
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+/// \struct CreateStatic
+///
+/// \ingroup CreationGroup
+/// Implementation of the CreationPolicy used by SingletonHolder
+/// Creates an object in static memory
+/// Implementation is slightly nonportable because it uses the MaxAlign trick
+/// (an union of all types to ensure proper memory alignment). This trick is
+/// nonportable in theory but highly portable in practice.
+////////////////////////////////////////////////////////////////////////////////
+template <class T> struct CreateStatic
+{
+
#ifdef _MSC_VER
-#pragma warning( push )
+#pragma warning( push )
#pragma warning( disable : 4121 )
-// alignment of a member was sensitive to packing
+ // alignment of a member was sensitive to packing
#endif // _MSC_VER
- union MaxAlign
- {
- char t_[sizeof(T)];
- short int shortInt_;
- int int_;
- long int longInt_;
- float float_;
- double double_;
- long double longDouble_;
- struct Test;
- int Test::* pMember_;
- int (Test::*pMemberFn_)(int);
- };
-
+ union MaxAlign
+ {
+ char t_[sizeof(T)];
+ short int shortInt_;
+ int int_;
+ long int longInt_;
+ float float_;
+ double double_;
+ long double longDouble_;
+ struct Test;
+ int Test::* pMember_;
+ int (Test::*pMemberFn_)(int);
+ };
+
#ifdef _MSC_VER
#pragma warning( pop )
#endif // _MSC_VER
-
- static T* Create()
- {
- static MaxAlign staticMemory_;
- return new(&staticMemory_) T;
- }
-
- static void Destroy(T* p)
- {
- p->~T();
- }
- };
- ////////////////////////////////////////////////////////////////////////////////
- /// \struct DefaultLifetime
- ///
- /// \ingroup LifetimeGroup
- /// Implementation of the LifetimePolicy used by SingletonHolder
- /// Schedules an object's destruction as per C++ rules
- /// Forwards to std::atexit
- ////////////////////////////////////////////////////////////////////////////////
- template <class T>
- struct DefaultLifetime
+ static T* Create()
{
- static void ScheduleDestruction(T*, atexit_pfn_t pFun)
- { std::atexit(pFun); }
-
- static void OnDeadReference()
- { throw std::logic_error("Dead Reference Detected"); }
- };
+ static MaxAlign staticMemory_;
+ return new(&staticMemory_) T;
+ }
- ////////////////////////////////////////////////////////////////////////////////
- /// \struct PhoenixSingleton
- ///
- /// \ingroup LifetimeGroup
- /// Implementation of the LifetimePolicy used by SingletonHolder
- /// Schedules an object's destruction as per C++ rules, and it allows object
- /// recreation by not throwing an exception from OnDeadReference
- ////////////////////////////////////////////////////////////////////////////////
- template <class T>
- class PhoenixSingleton
+ static void Destroy(T* p)
+ {
+ p->~T();
+ }
+};
+
+////////////////////////////////////////////////////////////////////////////////
+/// \struct DefaultLifetime
+///
+/// \ingroup LifetimeGroup
+/// Implementation of the LifetimePolicy used by SingletonHolder
+/// Schedules an object's destruction as per C++ rules
+/// Forwards to std::atexit
+////////////////////////////////////////////////////////////////////////////////
+template <class T>
+struct DefaultLifetime
+{
+ static void ScheduleDestruction(T*, atexit_pfn_t pFun)
+ { std::atexit(pFun); }
+
+ static void OnDeadReference()
+ { throw std::logic_error("Dead Reference Detected"); }
+};
+
+////////////////////////////////////////////////////////////////////////////////
+/// \struct PhoenixSingleton
+///
+/// \ingroup LifetimeGroup
+/// Implementation of the LifetimePolicy used by SingletonHolder
+/// Schedules an object's destruction as per C++ rules, and it allows object
+/// recreation by not throwing an exception from OnDeadReference
+////////////////////////////////////////////////////////////////////////////////
+template <class T>
+class PhoenixSingleton
+{
+public:
+ static void ScheduleDestruction(T*, atexit_pfn_t pFun)
{
- public:
- static void ScheduleDestruction(T*, atexit_pfn_t pFun)
- {
#ifndef ATEXIT_FIXED
- if (!destroyedOnce_)
+ if (!destroyedOnce_)
#endif
- std::atexit(pFun);
- }
-
- static void OnDeadReference()
- {
+ std::atexit(pFun);
+ }
+
+ static void OnDeadReference()
+ {
#ifndef ATEXIT_FIXED
- destroyedOnce_ = true;
+ destroyedOnce_ = true;
#endif
- }
-
- private:
+ }
+
+private:
#ifndef ATEXIT_FIXED
- static bool destroyedOnce_;
+ static bool destroyedOnce_;
#endif
- };
-
+};
+
#ifndef ATEXIT_FIXED
- template <class T> bool PhoenixSingleton<T>::destroyedOnce_ = false;
+template <class T> bool PhoenixSingleton<T>::destroyedOnce_ = false;
#endif
- ////////////////////////////////////////////////////////////////////////////////
- // Copyright (c) 2004 by Curtis Krauskopf - curtis@decompile.com
- ///
- /// \struct DeletableSingleton
- ///
- /// \ingroup LifetimeGroup
- ///
- /// A DeletableSingleton allows the instantiated singleton to be
- /// destroyed at any time. The singleton can be reinstantiated at
- /// any time, even during program termination.
- /// If the singleton exists when the program terminates, it will
- /// be automatically deleted.
- ///
- /// \par Usage:
- /// The singleton can be deleted manually:
- ///
- /// DeletableSingleton<MyClass>::GracefulDelete();
- ////////////////////////////////////////////////////////////////////////////////
- template <class T>
- class DeletableSingleton
- {
- public:
+////////////////////////////////////////////////////////////////////////////////
+// Copyright (c) 2004 by Curtis Krauskopf - curtis@decompile.com
+///
+/// \struct DeletableSingleton
+///
+/// \ingroup LifetimeGroup
+///
+/// A DeletableSingleton allows the instantiated singleton to be
+/// destroyed at any time. The singleton can be reinstantiated at
+/// any time, even during program termination.
+/// If the singleton exists when the program terminates, it will
+/// be automatically deleted.
+///
+/// \par Usage:
+/// The singleton can be deleted manually:
+///
+/// DeletableSingleton<MyClass>::GracefulDelete();
+////////////////////////////////////////////////////////////////////////////////
+template <class T>
+class DeletableSingleton
+{
+public:
- static void ScheduleDestruction(T*, atexit_pfn_t pFun)
- {
- static bool firstPass = true;
- isDead = false;
- deleter = pFun;
- if (firstPass || needCallback)
- {
- std::atexit(atexitCallback);
- firstPass = false;
- needCallback = false;
- }
- }
-
- static void OnDeadReference()
- {
- }
- /// delete singleton object manually
- static void GracefulDelete()
+ static void ScheduleDestruction(T*, atexit_pfn_t pFun)
+ {
+ static bool firstPass = true;
+ isDead = false;
+ deleter = pFun;
+ if (firstPass || needCallback)
{
- if (isDead)
- return;
- isDead = true;
- deleter();
+ std::atexit(atexitCallback);
+ firstPass = false;
+ needCallback = false;
}
-
- protected:
- static atexit_pfn_t deleter;
- static bool isDead;
- static bool needCallback;
-
- static void atexitCallback()
- {
+ }
+
+ static void OnDeadReference()
+ {
+ }
+ /// delete singleton object manually
+ static void GracefulDelete()
+ {
+ if (isDead)
+ return;
+ isDead = true;
+ deleter();
+ }
+
+protected:
+ static atexit_pfn_t deleter;
+ static bool isDead;
+ static bool needCallback;
+
+ static void atexitCallback()
+ {
#ifdef ATEXIT_FIXED
- needCallback = true;
+ needCallback = true;
#else
- needCallback = false;
+ needCallback = false;
#endif
- GracefulDelete();
- }
- };
-
- template <class T>
- atexit_pfn_t DeletableSingleton<T>::deleter = 0;
-
- template <class T>
- bool DeletableSingleton<T>::isDead = true;
-
- template <class T>
- bool DeletableSingleton<T>::needCallback = true;
+ GracefulDelete();
+ }
+};
+
+template <class T>
+atexit_pfn_t DeletableSingleton<T>::deleter = 0;
+
+template <class T>
+bool DeletableSingleton<T>::isDead = true;
+
+template <class T>
+bool DeletableSingleton<T>::needCallback = true;
- ////////////////////////////////////////////////////////////////////////////////
- // class template Adapter
- // Helper for SingletonWithLongevity below
- ////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+// class template Adapter
+// Helper for SingletonWithLongevity below
+////////////////////////////////////////////////////////////////////////////////
+
+namespace Private
+{
+template <class T>
+struct Adapter
+{
+ void operator()(T*) { return pFun_(); }
+ atexit_pfn_t pFun_;
+};
+}
- namespace Private
+////////////////////////////////////////////////////////////////////////////////
+/// \struct SingletonWithLongevity
+///
+/// \ingroup LifetimeGroup
+/// Implementation of the LifetimePolicy used by SingletonHolder
+/// Schedules an object's destruction in order of their longevities
+/// Assumes a visible function GetLongevity(T*) that returns the longevity of the
+/// object.
+////////////////////////////////////////////////////////////////////////////////
+template <class T>
+class SingletonWithLongevity
+{
+public:
+ static void ScheduleDestruction(T* pObj, atexit_pfn_t pFun)
{
- template <class T>
- struct Adapter
- {
- void operator()(T*) { return pFun_(); }
- atexit_pfn_t pFun_;
- };
+ Private::Adapter<T> adapter = { pFun };
+ SetLongevity(pObj, GetLongevity(pObj), adapter);
}
- ////////////////////////////////////////////////////////////////////////////////
- /// \struct SingletonWithLongevity
- ///
- /// \ingroup LifetimeGroup
- /// Implementation of the LifetimePolicy used by SingletonHolder
- /// Schedules an object's destruction in order of their longevities
- /// Assumes a visible function GetLongevity(T*) that returns the longevity of the
- /// object.
- ////////////////////////////////////////////////////////////////////////////////
- template <class T>
- class SingletonWithLongevity
+ static void OnDeadReference()
+ { throw std::logic_error("Dead Reference Detected"); }
+};
+
+////////////////////////////////////////////////////////////////////////////////
+/// \struct NoDestroy
+///
+/// \ingroup LifetimeGroup
+/// Implementation of the LifetimePolicy used by SingletonHolder
+/// Never destroys the object
+////////////////////////////////////////////////////////////////////////////////
+template <class T>
+struct NoDestroy
+{
+ static void ScheduleDestruction(T*, atexit_pfn_t)
+ {}
+
+ static void OnDeadReference()
+ {}
+};
+
+
+////////////////////////////////////////////////////////////////////////////////
+/// \defgroup LongevityLifetimeGroup LongevityLifetime
+/// \ingroup LifetimeGroup
+///
+/// \namespace LongevityLifetime
+///
+/// \ingroup LongevityLifetimeGroup
+/// \brief In this namespace are special lifetime policies to manage lifetime
+/// dependencies.
+////////////////////////////////////////////////////////////////////////////////
+namespace LongevityLifetime
+{
+////////////////////////////////////////////////////////////////////////////////
+/// \struct SingletonFixedLongevity
+///
+/// \ingroup LongevityLifetimeGroup
+/// Add your own lifetimes into the namespace 'LongevityLifetime'
+/// with your prefered lifetime by adding a struct like this:
+///
+/// template<class T>
+/// struct MyLifetime : SingletonFixedLongevity< MyLifetimeNumber ,T> {}
+////////////////////////////////////////////////////////////////////////////////
+template <unsigned int Longevity, class T>
+class SingletonFixedLongevity
+{
+public:
+ virtual ~SingletonFixedLongevity() {}
+
+ static void ScheduleDestruction(T* pObj, atexit_pfn_t pFun)
+ {
+ Private::Adapter<T> adapter = { pFun };
+ SetLongevity(pObj, Longevity , adapter);
+ }
+
+ static void OnDeadReference()
+ { throw std::logic_error("Dead Reference Detected"); }
+};
+
+/// \struct DieLast
+/// \ingroup LongevityLifetimeGroup
+/// \brief Longest possible SingletonWithLongevity lifetime: 0xFFFFFFFF
+template <class T>
+struct DieLast : SingletonFixedLongevity<0xFFFFFFFF ,T>
+ {};
+
+/// \struct DieDirectlyBeforeLast
+/// \ingroup LongevityLifetimeGroup
+/// \brief Lifetime is a one less than DieLast: 0xFFFFFFFF-1
+template <class T>
+struct DieDirectlyBeforeLast : SingletonFixedLongevity<0xFFFFFFFF-1 ,T>
+ {};
+
+/// \struct DieFirst
+/// \ingroup LongevityLifetimeGroup
+/// \brief Shortest possible SingletonWithLongevity lifetime: 0
+template <class T>
+struct DieFirst : SingletonFixedLongevity<0,T>
+ {};
+
+}//namespace LongevityLifetime
+
+////////////////////////////////////////////////////////////////////////////////
+/// \class FollowIntoDeath
+///
+/// \ingroup LifetimeGroup
+///
+/// Lifetime policyfor the SingletonHolder tempalte.
+/// Followers will die after the master dies Followers will not die, if
+/// - master never dies (NoDestroy policy)
+/// - master never created
+/// - master dies not in the function registered with atexit
+/// - master dies not by a call of a the atexit registerd function (DeletableSingleton::GracefulDelete)
+///
+/// \par Usage:
+///
+/// Lifetimes of the master and the follower singletons, e.g. with a M and a F class:
+/// \code SingletonHolder< M , FollowIntoDeath::With<DefaultLifetime>::AsMasterLifetime > MasterSingleton; \endcode
+/// \code SingletonHolder< F , CreateUsingNew, FollowIntoDeath::AfterMaster< MasterSingleton >::IsDestroyed > FollowerSingleton \endcode
+////////////////////////////////////////////////////////////////////////////////
+class FollowIntoDeath
+{
+ template<class T>
+ class Followers
{
+ typedef std::vector<atexit_pfn_t> Container;
+ typedef typename Container::iterator iterator;
+ static Container* followers_;
+
public:
- static void ScheduleDestruction(T* pObj, atexit_pfn_t pFun)
+ static void Init()
+ {
+ static bool done = false;
+ if(!done)
+ {
+ followers_ = new Container;
+ done = true;
+ }
+ }
+
+ static void AddFollower(atexit_pfn_t ae)
{
- Private::Adapter<T> adapter = { pFun };
- SetLongevity(pObj, GetLongevity(pObj), adapter);
+ Init();
+ followers_->push_back(ae);
}
-
- static void OnDeadReference()
- { throw std::logic_error("Dead Reference Detected"); }
- };
- ////////////////////////////////////////////////////////////////////////////////
- /// \struct NoDestroy
- ///
- /// \ingroup LifetimeGroup
- /// Implementation of the LifetimePolicy used by SingletonHolder
- /// Never destroys the object
- ////////////////////////////////////////////////////////////////////////////////
- template <class T>
- struct NoDestroy
- {
- static void ScheduleDestruction(T*, atexit_pfn_t)
- {}
-
- static void OnDeadReference()
- {}
+ static void DestroyFollowers()
+ {
+ Init();
+ for(iterator it = followers_->begin(); it != followers_->end(); ++it)
+ (*it)();
+ delete followers_;
+ }
};
-
-
- ////////////////////////////////////////////////////////////////////////////////
- /// \defgroup LongevityLifetimeGroup LongevityLifetime
- /// \ingroup LifetimeGroup
- ///
- /// \namespace LongevityLifetime
- ///
- /// \ingroup LongevityLifetimeGroup
- /// \brief In this namespace are special lifetime policies to manage lifetime
- /// dependencies.
- ////////////////////////////////////////////////////////////////////////////////
- namespace LongevityLifetime
+
+public:
+
+ /// \struct With
+ /// Template for the master
+ /// \param Lifetime Lifetime policy for the master
+ template<template <class> class Lifetime>
+ struct With
{
- ////////////////////////////////////////////////////////////////////////////////
- /// \struct SingletonFixedLongevity
- ///
- /// \ingroup LongevityLifetimeGroup
- /// Add your own lifetimes into the namespace 'LongevityLifetime'
- /// with your prefered lifetime by adding a struct like this:
- ///
- /// template<class T>
- /// struct MyLifetime : SingletonFixedLongevity< MyLifetimeNumber ,T> {}
- ////////////////////////////////////////////////////////////////////////////////
- template <unsigned int Longevity, class T>
- class SingletonFixedLongevity
+ /// \struct AsMasterLifetime
+ /// Policy for master
+ template<class Master>
+ struct AsMasterLifetime
{
- public:
- virtual ~SingletonFixedLongevity() {}
-
- static void ScheduleDestruction(T* pObj, atexit_pfn_t pFun)
+ static void ScheduleDestruction(Master* pObj, atexit_pfn_t pFun)
{
- Private::Adapter<T> adapter = { pFun };
- SetLongevity(pObj, Longevity , adapter);
+ Followers<Master>::Init();
+ Lifetime<Master>::ScheduleDestruction(pObj, pFun);
+
+ // use same policy for the followers and force a new
+ // template instantiation, this adds a additional atexit entry
+ // does not work with SetLonlevity, but there you can control
+ // the lifetime with the GetLongevity function.
+ Lifetime<Followers<Master> >::ScheduleDestruction(0,Followers<Master>::DestroyFollowers);
}
-
+
static void OnDeadReference()
- { throw std::logic_error("Dead Reference Detected"); }
+ {
+ throw std::logic_error("Dead Reference Detected");
+ }
};
+ };
- /// \struct DieLast
- /// \ingroup LongevityLifetimeGroup
- /// \brief Longest possible SingletonWithLongevity lifetime: 0xFFFFFFFF
- template <class T>
- struct DieLast : SingletonFixedLongevity<0xFFFFFFFF ,T>
- {};
-
- /// \struct DieDirectlyBeforeLast
- /// \ingroup LongevityLifetimeGroup
- /// \brief Lifetime is a one less than DieLast: 0xFFFFFFFF-1
- template <class T>
- struct DieDirectlyBeforeLast : SingletonFixedLongevity<0xFFFFFFFF-1 ,T>
- {};
-
- /// \struct DieFirst
- /// \ingroup LongevityLifetimeGroup
- /// \brief Shortest possible SingletonWithLongevity lifetime: 0
- template <class T>
- struct DieFirst : SingletonFixedLongevity<0,T>
- {};
-
- }//namespace LongevityLifetime
-
- ////////////////////////////////////////////////////////////////////////////////
- /// \class FollowIntoDeath
- ///
- /// \ingroup LifetimeGroup
- ///
- /// Lifetime policyfor the SingletonHolder tempalte.
- /// Followers will die after the master dies Followers will not die, if
- /// - master never dies (NoDestroy policy)
- /// - master never created
- /// - master dies not in the function registered with atexit
- /// - master dies not by a call of a the atexit registerd function (DeletableSingleton::GracefulDelete)
- ///
- /// \par Usage:
- ///
- /// Lifetimes of the master and the follower singletons, e.g. with a M and a F class:
- /// \code SingletonHolder< M , FollowIntoDeath::With<DefaultLifetime>::AsMasterLifetime > MasterSingleton; \endcode
- /// \code SingletonHolder< F , CreateUsingNew, FollowIntoDeath::AfterMaster< MasterSingleton >::IsDestroyed > FollowerSingleton \endcode
- ////////////////////////////////////////////////////////////////////////////////
- class FollowIntoDeath
+ /// \struct AfterMaster
+ /// Template for the follower
+ /// \param Master Master to follow into death
+ template<class Master>
+ struct AfterMaster
{
- template<class T>
- class Followers
+ /// \struct IsDestroyed
+ /// Policy for followers
+ template<class F>
+ struct IsDestroyed
{
- typedef std::vector<atexit_pfn_t> Container;
- typedef typename Container::iterator iterator;
- static Container* followers_;
-
- public:
- static void Init()
+ static void ScheduleDestruction(F*, atexit_pfn_t pFun)
{
- static bool done = false;
- if(!done)
- {
- followers_ = new Container;
- done = true;
- }
+ Followers<Master>::AddFollower(pFun);
}
- static void AddFollower(atexit_pfn_t ae)
- {
- Init();
- followers_->push_back(ae);
- }
-
- static void DestroyFollowers()
+ static void OnDeadReference()
{
- Init();
- for(iterator it = followers_->begin();it != followers_->end();++it)
- (*it)();
- delete followers_;
+ throw std::logic_error("Dead Reference Detected");
}
};
+ };
+};
- public:
+template<class T>
+typename FollowIntoDeath::Followers<T>::Container*
+FollowIntoDeath::Followers<T>::followers_ = 0;
- /// \struct With
- /// Template for the master
- /// \param Lifetime Lifetime policy for the master
- template<template <class> class Lifetime>
- struct With
- {
- /// \struct AsMasterLifetime
- /// Policy for master
- template<class Master>
- struct AsMasterLifetime
- {
- static void ScheduleDestruction(Master* pObj, atexit_pfn_t pFun)
- {
- Followers<Master>::Init();
- Lifetime<Master>::ScheduleDestruction(pObj, pFun);
-
- // use same policy for the followers and force a new
- // template instantiation, this adds a additional atexit entry
- // does not work with SetLonlevity, but there you can control
- // the lifetime with the GetLongevity function.
- Lifetime<Followers<Master> >::ScheduleDestruction(0,Followers<Master>::DestroyFollowers);
- }
-
- static void OnDeadReference()
- {
- throw std::logic_error("Dead Reference Detected");
- }
- };
- };
- /// \struct AfterMaster
- /// Template for the follower
- /// \param Master Master to follow into death
- template<class Master>
- struct AfterMaster
- {
- /// \struct IsDestroyed
- /// Policy for followers
- template<class F>
- struct IsDestroyed
- {
- static void ScheduleDestruction(F*, atexit_pfn_t pFun)
- {
- Followers<Master>::AddFollower(pFun);
- }
-
- static void OnDeadReference()
- {
- throw std::logic_error("Dead Reference Detected");
- }
- };
- };
- };
- template<class T>
- typename FollowIntoDeath::Followers<T>::Container*
- FollowIntoDeath::Followers<T>::followers_ = 0;
-
-
-
- ////////////////////////////////////////////////////////////////////////////////
- /// \class SingletonHolder
- ///
- /// \ingroup SingletonGroup
- ///
- /// Provides Singleton amenities for a type T
- /// To protect that type from spurious instantiations,
- /// you have to protect it yourself.
- ///
- /// \param CreationPolicy Creation policy, default: CreateUsingNew
- /// \param LifetimePolicy Lifetime policy, default: DefaultLifetime,
- /// \param ThreadingModel Threading policy,
- /// default: LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL
- ////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class CreationPolicy = CreateUsingNew,
- template <class> class LifetimePolicy = DefaultLifetime,
- template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL,
- class MutexPolicy = LOKI_DEFAULT_MUTEX
- >
- class SingletonHolder
- {
- public:
+////////////////////////////////////////////////////////////////////////////////
+/// \class SingletonHolder
+///
+/// \ingroup SingletonGroup
+///
+/// Provides Singleton amenities for a type T
+/// To protect that type from spurious instantiations,
+/// you have to protect it yourself.
+///
+/// \param CreationPolicy Creation policy, default: CreateUsingNew
+/// \param LifetimePolicy Lifetime policy, default: DefaultLifetime,
+/// \param ThreadingModel Threading policy,
+/// default: LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL
+////////////////////////////////////////////////////////////////////////////////
+template
+<
+typename T,
+ template <class> class CreationPolicy = CreateUsingNew,
+ template <class> class LifetimePolicy = DefaultLifetime,
+ template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL,
+ class MutexPolicy = LOKI_DEFAULT_MUTEX
+ >
+class SingletonHolder
+{
+public:
- /// Type of the singleton object
- typedef T ObjectType;
-
- /// Returns a reference to singleton object
- static T& Instance();
-
- private:
- // Helpers
- static void MakeInstance();
- static void LOKI_C_CALLING_CONVENTION_QUALIFIER DestroySingleton();
-
- // Protection
- SingletonHolder();
-
- // Data
- typedef typename ThreadingModel<T*,MutexPolicy>::VolatileType PtrInstanceType;
- static PtrInstanceType pInstance_;
- static bool destroyed_;
- };
-
- ////////////////////////////////////////////////////////////////////////////////
- // SingletonHolder's data
- ////////////////////////////////////////////////////////////////////////////////
-
- template
- <
- class T,
- template <class> class C,
- template <class> class L,
- template <class, class> class M,
- class X
- >
- typename SingletonHolder<T, C, L, M, X>::PtrInstanceType
- SingletonHolder<T, C, L, M, X>::pInstance_ = 0;
-
- template
- <
- class T,
- template <class> class C,
- template <class> class L,
- template <class, class> class M,
- class X
- >
- bool SingletonHolder<T, C, L, M, X>::destroyed_ = false;
-
- ////////////////////////////////////////////////////////////////////////////////
- // SingletonHolder::Instance
- ////////////////////////////////////////////////////////////////////////////////
-
- template
- <
- class T,
- template <class> class CreationPolicy,
- template <class> class LifetimePolicy,
- template <class, class> class ThreadingModel,
- class MutexPolicy
- >
- inline T& SingletonHolder<T, CreationPolicy,
- LifetimePolicy, ThreadingModel, MutexPolicy>::Instance()
+ /// Type of the singleton object
+ typedef T ObjectType;
+
+ /// Returns a reference to singleton object
+ static T& Instance();
+
+private:
+ // Helpers
+ static void MakeInstance();
+ static void LOKI_C_CALLING_CONVENTION_QUALIFIER DestroySingleton();
+
+ // Protection
+ SingletonHolder();
+
+ // Data
+ typedef typename ThreadingModel<T*,MutexPolicy>::VolatileType PtrInstanceType;
+ static PtrInstanceType pInstance_;
+ static bool destroyed_;
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// SingletonHolder's data
+////////////////////////////////////////////////////////////////////////////////
+
+template
+<
+class T,
+ template <class> class C,
+ template <class> class L,
+ template <class, class> class M,
+ class X
+ >
+typename SingletonHolder<T, C, L, M, X>::PtrInstanceType
+SingletonHolder<T, C, L, M, X>::pInstance_ = 0;
+
+template
+<
+class T,
+ template <class> class C,
+ template <class> class L,
+ template <class, class> class M,
+ class X
+ >
+bool SingletonHolder<T, C, L, M, X>::destroyed_ = false;
+
+////////////////////////////////////////////////////////////////////////////////
+// SingletonHolder::Instance
+////////////////////////////////////////////////////////////////////////////////
+
+template
+<
+class T,
+ template <class> class CreationPolicy,
+ template <class> class LifetimePolicy,
+ template <class, class> class ThreadingModel,
+ class MutexPolicy
+ >
+inline T& SingletonHolder<T, CreationPolicy,
+ LifetimePolicy, ThreadingModel, MutexPolicy>::Instance()
+{
+ if (!pInstance_)
{
- if (!pInstance_)
- {
- MakeInstance();
- }
- return *pInstance_;
+ MakeInstance();
}
+ return *pInstance_;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// SingletonHolder::MakeInstance (helper for Instance)
+////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////
- // SingletonHolder::MakeInstance (helper for Instance)
- ////////////////////////////////////////////////////////////////////////////////
-
- template
- <
- class T,
- template <class> class CreationPolicy,
- template <class> class LifetimePolicy,
- template <class, class> class ThreadingModel,
- class MutexPolicy
- >
- void SingletonHolder<T, CreationPolicy,
- LifetimePolicy, ThreadingModel, MutexPolicy>::MakeInstance()
+template
+<
+class T,
+template <class> class CreationPolicy,
+template <class> class LifetimePolicy,
+template <class, class> class ThreadingModel,
+class MutexPolicy
+>
+void SingletonHolder<T, CreationPolicy,
+ LifetimePolicy, ThreadingModel, MutexPolicy>::MakeInstance()
+{
+ typename ThreadingModel<SingletonHolder,MutexPolicy>::Lock guard;
+ (void)guard;
+
+ if (!pInstance_)
{
- typename ThreadingModel<SingletonHolder,MutexPolicy>::Lock guard;
- (void)guard;
-
- if (!pInstance_)
+ if (destroyed_)
{
- if (destroyed_)
- {
- destroyed_ = false;
- LifetimePolicy<T>::OnDeadReference();
- }
- pInstance_ = CreationPolicy<T>::Create();
- LifetimePolicy<T>::ScheduleDestruction(pInstance_,
- &DestroySingleton);
+ destroyed_ = false;
+ LifetimePolicy<T>::OnDeadReference();
}
+ pInstance_ = CreationPolicy<T>::Create();
+ LifetimePolicy<T>::ScheduleDestruction(pInstance_,
+ &DestroySingleton);
}
+}
- template
- <
- class T,
- template <class> class CreationPolicy,
- template <class> class L,
- template <class, class> class M,
- class X
- >
- void LOKI_C_CALLING_CONVENTION_QUALIFIER
- SingletonHolder<T, CreationPolicy, L, M, X>::DestroySingleton()
- {
- assert(!destroyed_);
- CreationPolicy<T>::Destroy(pInstance_);
- pInstance_ = 0;
- destroyed_ = true;
- }
+template
+<
+class T,
+template <class> class CreationPolicy,
+template <class> class L,
+template <class, class> class M,
+class X
+>
+void LOKI_C_CALLING_CONVENTION_QUALIFIER
+SingletonHolder<T, CreationPolicy, L, M, X>::DestroySingleton()
+{
+ assert(!destroyed_);
+ CreationPolicy<T>::Destroy(pInstance_);
+ pInstance_ = 0;
+ destroyed_ = true;
+}
- ////////////////////////////////////////////////////////////////////////////////
- /// \class Singleton
- ///
- /// \ingroup SingletonGroup
- ///
- /// Convenience template to implement a getter function for a singleton object.
- /// Often needed in a shared library which hosts singletons.
- ///
- /// \par Usage
- ///
- /// see test/SingletonDll
- ///
- ////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+/// \class Singleton
+///
+/// \ingroup SingletonGroup
+///
+/// Convenience template to implement a getter function for a singleton object.
+/// Often needed in a shared library which hosts singletons.
+///
+/// \par Usage
+///
+/// see test/SingletonDll
+///
+////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_SINGLETON_EXPORT
#define LOKI_SINGLETON_EXPORT
#endif
- template<class T>
- class LOKI_SINGLETON_EXPORT Singleton
- {
- public:
- static T& Instance();
- };
+template<class T>
+class LOKI_SINGLETON_EXPORT Singleton
+{
+public:
+ static T& Instance();
+};
} // namespace Loki
diff --git a/shared/loki/SmallObj.cpp b/shared/loki/SmallObj.cpp
index adb54c55..0d82c1bb 100644
--- a/shared/loki/SmallObj.cpp
+++ b/shared/loki/SmallObj.cpp
@@ -28,274 +28,274 @@
//#define LOKI_CHECK_FOR_CORRUPTION
#ifdef DO_EXTRA_LOKI_TESTS
- #include <iostream>
+#include <iostream>
#endif
namespace Loki
{
- /** @struct Chunk
- @ingroup SmallObjectGroupInternal
- Contains info about each allocated Chunk - which is a collection of
- contiguous blocks. Each block is the same size, as specified by the
- FixedAllocator. The number of blocks in a Chunk depends upon page size.
- This is a POD-style struct with value-semantics. All functions and data
- are private so that they can not be changed by anything other than the
- FixedAllocator which owns the Chunk.
-
- @par Minimal Interface
- For the sake of runtime efficiency, no constructor, destructor, or
- copy-assignment operator is defined. The inline functions made by the
- compiler should be sufficient, and perhaps faster than hand-crafted
- functions. The lack of these functions allows vector to create and copy
- Chunks as needed without overhead. The Init and Release functions do
- what the default constructor and destructor would do. A Chunk is not in
- a usable state after it is constructed and before calling Init. Nor is
- a Chunk usable after Release is called, but before the destructor.
-
- @par Efficiency
- Down near the lowest level of the allocator, runtime efficiencies trump
- almost all other considerations. Each function does the minimum required
- of it. All functions should execute in constant time to prevent higher-
- level code from unwittingly using a version of Shlemiel the Painter's
- Algorithm.
-
- @par Stealth Indexes
- The first char of each empty block contains the index of the next empty
- block. These stealth indexes form a singly-linked list within the blocks.
- A Chunk is corrupt if this singly-linked list has a loop or is shorter
- than blocksAvailable_. Much of the allocator's time and space efficiency
- comes from how these stealth indexes are implemented.
+/** @struct Chunk
+ @ingroup SmallObjectGroupInternal
+ Contains info about each allocated Chunk - which is a collection of
+ contiguous blocks. Each block is the same size, as specified by the
+ FixedAllocator. The number of blocks in a Chunk depends upon page size.
+ This is a POD-style struct with value-semantics. All functions and data
+ are private so that they can not be changed by anything other than the
+ FixedAllocator which owns the Chunk.
+
+ @par Minimal Interface
+ For the sake of runtime efficiency, no constructor, destructor, or
+ copy-assignment operator is defined. The inline functions made by the
+ compiler should be sufficient, and perhaps faster than hand-crafted
+ functions. The lack of these functions allows vector to create and copy
+ Chunks as needed without overhead. The Init and Release functions do
+ what the default constructor and destructor would do. A Chunk is not in
+ a usable state after it is constructed and before calling Init. Nor is
+ a Chunk usable after Release is called, but before the destructor.
+
+ @par Efficiency
+ Down near the lowest level of the allocator, runtime efficiencies trump
+ almost all other considerations. Each function does the minimum required
+ of it. All functions should execute in constant time to prevent higher-
+ level code from unwittingly using a version of Shlemiel the Painter's
+ Algorithm.
+
+ @par Stealth Indexes
+ The first char of each empty block contains the index of the next empty
+ block. These stealth indexes form a singly-linked list within the blocks.
+ A Chunk is corrupt if this singly-linked list has a loop or is shorter
+ than blocksAvailable_. Much of the allocator's time and space efficiency
+ comes from how these stealth indexes are implemented.
+ */
+class Chunk
+{
+private:
+ friend class FixedAllocator;
+
+ /** Initializes a just-constructed Chunk.
+ @param blockSize Number of bytes per block.
+ @param blocks Number of blocks per Chunk.
+ @return True for success, false for failure.
*/
- class Chunk
- {
- private:
- friend class FixedAllocator;
+ bool Init( std::size_t blockSize, unsigned char blocks );
- /** Initializes a just-constructed Chunk.
- @param blockSize Number of bytes per block.
- @param blocks Number of blocks per Chunk.
- @return True for success, false for failure.
- */
- bool Init( std::size_t blockSize, unsigned char blocks );
+ /** Allocate a block within the Chunk. Complexity is always O(1), and
+ this will never throw. Does not actually "allocate" by calling
+ malloc, new, or any other function, but merely adjusts some internal
+ indexes to indicate an already allocated block is no longer available.
+ @return Pointer to block within Chunk.
+ */
+ void* Allocate( std::size_t blockSize );
+
+ /** Deallocate a block within the Chunk. Complexity is always O(1), and
+ this will never throw. For efficiency, this assumes the address is
+ within the block and aligned along the correct byte boundary. An
+ assertion checks the alignment, and a call to HasBlock is done from
+ within VicinityFind. Does not actually "deallocate" by calling free,
+ delete, or other function, but merely adjusts some internal indexes to
+ indicate a block is now available.
+ */
+ void Deallocate( void* p, std::size_t blockSize );
- /** Allocate a block within the Chunk. Complexity is always O(1), and
- this will never throw. Does not actually "allocate" by calling
- malloc, new, or any other function, but merely adjusts some internal
- indexes to indicate an already allocated block is no longer available.
- @return Pointer to block within Chunk.
- */
- void * Allocate( std::size_t blockSize );
-
- /** Deallocate a block within the Chunk. Complexity is always O(1), and
- this will never throw. For efficiency, this assumes the address is
- within the block and aligned along the correct byte boundary. An
- assertion checks the alignment, and a call to HasBlock is done from
- within VicinityFind. Does not actually "deallocate" by calling free,
- delete, or other function, but merely adjusts some internal indexes to
- indicate a block is now available.
- */
- void Deallocate( void * p, std::size_t blockSize );
+ /** Resets the Chunk back to pristine values. The available count is
+ set back to zero, and the first available index is set to the zeroth
+ block. The stealth indexes inside each block are set to point to the
+ next block. This assumes the Chunk's data was already using Init.
+ */
+ void Reset( std::size_t blockSize, unsigned char blocks );
+
+ /// Releases the allocated block of memory.
+ void Release();
+
+ /** Determines if the Chunk has been corrupted.
+ @param numBlocks Total # of blocks in the Chunk.
+ @param blockSize # of bytes in each block.
+ @param checkIndexes True if caller wants to check indexes of available
+ blocks for corruption. If false, then caller wants to skip some
+ tests tests just to run faster. (Debug version does more checks, but
+ release version runs faster.)
+ @return True if Chunk is corrupt.
+ */
+ bool IsCorrupt( unsigned char numBlocks, std::size_t blockSize,
+ bool checkIndexes ) const;
+
+ /** Determines if block is available.
+ @param p Address of block managed by Chunk.
+ @param numBlocks Total # of blocks in the Chunk.
+ @param blockSize # of bytes in each block.
+ @return True if block is available, else false if allocated.
+ */
+ bool IsBlockAvailable( void* p, unsigned char numBlocks,
+ std::size_t blockSize ) const;
- /** Resets the Chunk back to pristine values. The available count is
- set back to zero, and the first available index is set to the zeroth
- block. The stealth indexes inside each block are set to point to the
- next block. This assumes the Chunk's data was already using Init.
- */
- void Reset( std::size_t blockSize, unsigned char blocks );
-
- /// Releases the allocated block of memory.
- void Release();
-
- /** Determines if the Chunk has been corrupted.
- @param numBlocks Total # of blocks in the Chunk.
- @param blockSize # of bytes in each block.
- @param checkIndexes True if caller wants to check indexes of available
- blocks for corruption. If false, then caller wants to skip some
- tests tests just to run faster. (Debug version does more checks, but
- release version runs faster.)
- @return True if Chunk is corrupt.
- */
- bool IsCorrupt( unsigned char numBlocks, std::size_t blockSize,
- bool checkIndexes ) const;
-
- /** Determines if block is available.
- @param p Address of block managed by Chunk.
- @param numBlocks Total # of blocks in the Chunk.
- @param blockSize # of bytes in each block.
- @return True if block is available, else false if allocated.
- */
- bool IsBlockAvailable( void * p, unsigned char numBlocks,
- std::size_t blockSize ) const;
+ /// Returns true if block at address P is inside this Chunk.
+ inline bool HasBlock( void* p, std::size_t chunkLength ) const
+ {
+ unsigned char* pc = static_cast< unsigned char* >( p );
+ return ( pData_ <= pc ) && ( pc < pData_ + chunkLength );
+ }
- /// Returns true if block at address P is inside this Chunk.
- inline bool HasBlock( void * p, std::size_t chunkLength ) const
- {
- unsigned char * pc = static_cast< unsigned char * >( p );
- return ( pData_ <= pc ) && ( pc < pData_ + chunkLength );
- }
+ inline bool HasAvailable( unsigned char numBlocks ) const
+ { return ( blocksAvailable_ == numBlocks ); }
+
+ inline bool IsFilled( void ) const
+ { return ( 0 == blocksAvailable_ ); }
+
+ /// Pointer to array of allocated blocks.
+ unsigned char* pData_;
+ /// Index of first empty block.
+ unsigned char firstAvailableBlock_;
+ /// Count of empty blocks.
+ unsigned char blocksAvailable_;
+};
+
+/** @class FixedAllocator
+ @ingroup SmallObjectGroupInternal
+ Offers services for allocating fixed-sized objects. It has a container
+ of "containers" of fixed-size blocks. The outer container has all the
+ Chunks. The inner container is a Chunk which owns some blocks.
+
+ @par Class Level Invariants
+ - There is always either zero or one Chunk which is empty.
+ - If this has no empty Chunk, then emptyChunk_ is NULL.
+ - If this has an empty Chunk, then emptyChunk_ points to it.
+ - If the Chunk container is empty, then deallocChunk_ and allocChunk_
+ are NULL.
+ - If the Chunk container is not-empty, then deallocChunk_ and allocChunk_
+ are either NULL or point to Chunks within the container.
+ - allocChunk_ will often point to the last Chunk in the container since
+ it was likely allocated most recently, and therefore likely to have an
+ available block.
+ */
+class FixedAllocator
+{
+private:
- inline bool HasAvailable( unsigned char numBlocks ) const
- { return ( blocksAvailable_ == numBlocks ); }
-
- inline bool IsFilled( void ) const
- { return ( 0 == blocksAvailable_ ); }
-
- /// Pointer to array of allocated blocks.
- unsigned char * pData_;
- /// Index of first empty block.
- unsigned char firstAvailableBlock_;
- /// Count of empty blocks.
- unsigned char blocksAvailable_;
- };
-
- /** @class FixedAllocator
- @ingroup SmallObjectGroupInternal
- Offers services for allocating fixed-sized objects. It has a container
- of "containers" of fixed-size blocks. The outer container has all the
- Chunks. The inner container is a Chunk which owns some blocks.
-
- @par Class Level Invariants
- - There is always either zero or one Chunk which is empty.
- - If this has no empty Chunk, then emptyChunk_ is NULL.
- - If this has an empty Chunk, then emptyChunk_ points to it.
- - If the Chunk container is empty, then deallocChunk_ and allocChunk_
- are NULL.
- - If the Chunk container is not-empty, then deallocChunk_ and allocChunk_
- are either NULL or point to Chunks within the container.
- - allocChunk_ will often point to the last Chunk in the container since
- it was likely allocated most recently, and therefore likely to have an
- available block.
+ /** Deallocates the block at address p, and then handles the internal
+ bookkeeping needed to maintain class invariants. This assumes that
+ deallocChunk_ points to the correct chunk.
*/
- class FixedAllocator
- {
- private:
-
- /** Deallocates the block at address p, and then handles the internal
- bookkeeping needed to maintain class invariants. This assumes that
- deallocChunk_ points to the correct chunk.
- */
- void DoDeallocate( void * p );
+ void DoDeallocate( void* p );
- /** Creates an empty Chunk and adds it to the end of the ChunkList.
- All calls to the lower-level memory allocation functions occur inside
- this function, and so the only try-catch block is inside here.
- @return true for success, false for failure.
- */
- bool MakeNewChunk( void );
-
- /** Finds the Chunk which owns the block at address p. It starts at
- deallocChunk_ and searches in both forwards and backwards directions
- from there until it finds the Chunk which owns p. This algorithm
- should find the Chunk quickly if it is deallocChunk_ or is close to it
- in the Chunks container. This goes both forwards and backwards since
- that works well for both same-order and opposite-order deallocations.
- (Same-order = objects are deallocated in the same order in which they
- were allocated. Opposite order = objects are deallocated in a last to
- first order. Complexity is O(C) where C is count of all Chunks. This
- never throws.
- @return Pointer to Chunk that owns p, or NULL if no owner found.
- */
- Chunk * VicinityFind( void * p ) const;
-
- /// Not implemented.
- FixedAllocator(const FixedAllocator&);
- /// Not implemented.
- FixedAllocator& operator=(const FixedAllocator&);
-
- /// Type of container used to hold Chunks.
- typedef std::vector< Chunk > Chunks;
- /// Iterator through container of Chunks.
- typedef Chunks::iterator ChunkIter;
- /// Iterator through const container of Chunks.
- typedef Chunks::const_iterator ChunkCIter;
-
- /// Fewest # of objects managed by a Chunk.
- static unsigned char MinObjectsPerChunk_;
-
- /// Most # of objects managed by a Chunk - never exceeds UCHAR_MAX.
- static unsigned char MaxObjectsPerChunk_;
-
- /// Number of bytes in a single block within a Chunk.
- std::size_t blockSize_;
- /// Number of blocks managed by each Chunk.
- unsigned char numBlocks_;
-
- /// Container of Chunks.
- Chunks chunks_;
- /// Pointer to Chunk used for last or next allocation.
- Chunk * allocChunk_;
- /// Pointer to Chunk used for last or next deallocation.
- Chunk * deallocChunk_;
- /// Pointer to the only empty Chunk if there is one, else NULL.
- Chunk * emptyChunk_;
-
- public:
- /// Create a FixedAllocator which manages blocks of 'blockSize' size.
- FixedAllocator();
-
- /// Destroy the FixedAllocator and release all its Chunks.
- ~FixedAllocator();
-
- /// Initializes a FixedAllocator by calculating # of blocks per Chunk.
- void Initialize( std::size_t blockSize, std::size_t pageSize );
-
- /** Returns pointer to allocated memory block of fixed size - or NULL
- if it failed to allocate.
- */
- void * Allocate( void );
+ /** Creates an empty Chunk and adds it to the end of the ChunkList.
+ All calls to the lower-level memory allocation functions occur inside
+ this function, and so the only try-catch block is inside here.
+ @return true for success, false for failure.
+ */
+ bool MakeNewChunk( void );
+
+ /** Finds the Chunk which owns the block at address p. It starts at
+ deallocChunk_ and searches in both forwards and backwards directions
+ from there until it finds the Chunk which owns p. This algorithm
+ should find the Chunk quickly if it is deallocChunk_ or is close to it
+ in the Chunks container. This goes both forwards and backwards since
+ that works well for both same-order and opposite-order deallocations.
+ (Same-order = objects are deallocated in the same order in which they
+ were allocated. Opposite order = objects are deallocated in a last to
+ first order. Complexity is O(C) where C is count of all Chunks. This
+ never throws.
+ @return Pointer to Chunk that owns p, or NULL if no owner found.
+ */
+ Chunk* VicinityFind( void* p ) const;
+
+ /// Not implemented.
+ FixedAllocator(const FixedAllocator&);
+ /// Not implemented.
+ FixedAllocator& operator=(const FixedAllocator&);
+
+ /// Type of container used to hold Chunks.
+ typedef std::vector< Chunk > Chunks;
+ /// Iterator through container of Chunks.
+ typedef Chunks::iterator ChunkIter;
+ /// Iterator through const container of Chunks.
+ typedef Chunks::const_iterator ChunkCIter;
+
+ /// Fewest # of objects managed by a Chunk.
+ static unsigned char MinObjectsPerChunk_;
+
+ /// Most # of objects managed by a Chunk - never exceeds UCHAR_MAX.
+ static unsigned char MaxObjectsPerChunk_;
+
+ /// Number of bytes in a single block within a Chunk.
+ std::size_t blockSize_;
+ /// Number of blocks managed by each Chunk.
+ unsigned char numBlocks_;
+
+ /// Container of Chunks.
+ Chunks chunks_;
+ /// Pointer to Chunk used for last or next allocation.
+ Chunk* allocChunk_;
+ /// Pointer to Chunk used for last or next deallocation.
+ Chunk* deallocChunk_;
+ /// Pointer to the only empty Chunk if there is one, else NULL.
+ Chunk* emptyChunk_;
+
+public:
+ /// Create a FixedAllocator which manages blocks of 'blockSize' size.
+ FixedAllocator();
+
+ /// Destroy the FixedAllocator and release all its Chunks.
+ ~FixedAllocator();
+
+ /// Initializes a FixedAllocator by calculating # of blocks per Chunk.
+ void Initialize( std::size_t blockSize, std::size_t pageSize );
+
+ /** Returns pointer to allocated memory block of fixed size - or NULL
+ if it failed to allocate.
+ */
+ void* Allocate( void );
- /** Deallocate a memory block previously allocated with Allocate. If
- the block is not owned by this FixedAllocator, it returns false so
- that SmallObjAllocator can call the default deallocator. If the
- block was found, this returns true.
- */
- bool Deallocate( void * p, Chunk * hint );
+ /** Deallocate a memory block previously allocated with Allocate. If
+ the block is not owned by this FixedAllocator, it returns false so
+ that SmallObjAllocator can call the default deallocator. If the
+ block was found, this returns true.
+ */
+ bool Deallocate( void* p, Chunk* hint );
- /// Returns block size with which the FixedAllocator was initialized.
- inline std::size_t BlockSize() const { return blockSize_; }
+ /// Returns block size with which the FixedAllocator was initialized.
+ inline std::size_t BlockSize() const { return blockSize_; }
- /** Releases the memory used by the empty Chunk. This will take
- constant time under any situation.
- @return True if empty chunk found and released, false if none empty.
- */
- bool TrimEmptyChunk( void );
+ /** Releases the memory used by the empty Chunk. This will take
+ constant time under any situation.
+ @return True if empty chunk found and released, false if none empty.
+ */
+ bool TrimEmptyChunk( void );
- /** Releases unused spots from ChunkList. This takes constant time
- with respect to # of Chunks, but actual time depends on underlying
- memory allocator.
- @return False if no unused spots, true if some found and released.
- */
- bool TrimChunkList( void );
+ /** Releases unused spots from ChunkList. This takes constant time
+ with respect to # of Chunks, but actual time depends on underlying
+ memory allocator.
+ @return False if no unused spots, true if some found and released.
+ */
+ bool TrimChunkList( void );
- /** Returns count of empty Chunks held by this allocator. Complexity
- is O(C) where C is the total number of Chunks - empty or used.
- */
- std::size_t CountEmptyChunks( void ) const;
+ /** Returns count of empty Chunks held by this allocator. Complexity
+ is O(C) where C is the total number of Chunks - empty or used.
+ */
+ std::size_t CountEmptyChunks( void ) const;
- /** Determines if FixedAllocator is corrupt. Checks data members to
- see if any have erroneous values, or violate class invariants. It
- also checks if any Chunk is corrupt. Complexity is O(C) where C is
- the number of Chunks. If any data is corrupt, this will return true
- in release mode, or assert in debug mode.
- */
- bool IsCorrupt( void ) const;
+ /** Determines if FixedAllocator is corrupt. Checks data members to
+ see if any have erroneous values, or violate class invariants. It
+ also checks if any Chunk is corrupt. Complexity is O(C) where C is
+ the number of Chunks. If any data is corrupt, this will return true
+ in release mode, or assert in debug mode.
+ */
+ bool IsCorrupt( void ) const;
- /** Returns true if the block at address p is within a Chunk owned by
- this FixedAllocator. Complexity is O(C) where C is the total number
- of Chunks - empty or used.
- */
- const Chunk * HasBlock( void * p ) const;
- inline Chunk * HasBlock( void * p )
- {
- return const_cast< Chunk * >(
- const_cast< const FixedAllocator * >( this )->HasBlock( p ) );
- }
+ /** Returns true if the block at address p is within a Chunk owned by
+ this FixedAllocator. Complexity is O(C) where C is the total number
+ of Chunks - empty or used.
+ */
+ const Chunk* HasBlock( void* p ) const;
+ inline Chunk* HasBlock( void* p )
+ {
+ return const_cast< Chunk* >(
+ const_cast< const FixedAllocator* >( this )->HasBlock( p ) );
+ }
- };
+};
- unsigned char FixedAllocator::MinObjectsPerChunk_ = 8;
- unsigned char FixedAllocator::MaxObjectsPerChunk_ = UCHAR_MAX;
+unsigned char FixedAllocator::MinObjectsPerChunk_ = 8;
+unsigned char FixedAllocator::MaxObjectsPerChunk_ = UCHAR_MAX;
// Chunk::Init ----------------------------------------------------------------
@@ -310,11 +310,11 @@ bool Chunk::Init( std::size_t blockSize, unsigned char blocks )
#ifdef USE_NEW_TO_ALLOCATE
// If this new operator fails, it will throw, and the exception will get
// caught one layer up.
- pData_ = static_cast< unsigned char * >( ::operator new ( allocSize ) );
+ pData_ = static_cast< unsigned char* >( ::operator new ( allocSize ) );
#else
// malloc can't throw, so its only way to indicate an error is to return
// a NULL pointer, so we have to check for that.
- pData_ = static_cast< unsigned char * >( ::std::malloc( allocSize ) );
+ pData_ = static_cast< unsigned char* >( ::std::malloc( allocSize ) );
if ( NULL == pData_ ) return false;
#endif
@@ -335,7 +335,7 @@ void Chunk::Reset(std::size_t blockSize, unsigned char blocks)
blocksAvailable_ = blocks;
unsigned char i = 0;
- for ( unsigned char * p = pData_; i != blocks; p += blockSize )
+ for ( unsigned char* p = pData_; i != blocks; p += blockSize )
{
*p = ++i;
}
@@ -349,7 +349,7 @@ void Chunk::Release()
#ifdef USE_NEW_TO_ALLOCATE
::operator delete ( pData_ );
#else
- ::std::free( static_cast< void * >( pData_ ) );
+ ::std::free( static_cast< void* >( pData_ ) );
#endif
}
@@ -360,8 +360,8 @@ void* Chunk::Allocate(std::size_t blockSize)
if ( IsFilled() ) return NULL;
assert((firstAvailableBlock_ * blockSize) / blockSize ==
- firstAvailableBlock_);
- unsigned char * pResult = pData_ + (firstAvailableBlock_ * blockSize);
+ firstAvailableBlock_);
+ unsigned char* pResult = pData_ + (firstAvailableBlock_ * blockSize);
firstAvailableBlock_ = *pResult;
--blocksAvailable_;
@@ -378,7 +378,7 @@ void Chunk::Deallocate(void* p, std::size_t blockSize)
// Alignment check
assert((toRelease - pData_) % blockSize == 0);
unsigned char index = static_cast< unsigned char >(
- ( toRelease - pData_ ) / blockSize);
+ ( toRelease - pData_ ) / blockSize);
#if defined(DEBUG) || defined(_DEBUG)
// Check if block was already deleted. Attempting to delete the same
@@ -399,7 +399,7 @@ void Chunk::Deallocate(void* p, std::size_t blockSize)
// Chunk::IsCorrupt -----------------------------------------------------------
bool Chunk::IsCorrupt( unsigned char numBlocks, std::size_t blockSize,
- bool checkIndexes ) const
+ bool checkIndexes ) const
{
if ( numBlocks < blocksAvailable_ )
@@ -428,7 +428,7 @@ bool Chunk::IsCorrupt( unsigned char numBlocks, std::size_t blockSize,
found on the linked-list.
*/
std::bitset< UCHAR_MAX > foundBlocks;
- unsigned char * nextBlock = NULL;
+ unsigned char* nextBlock = NULL;
/* The loop goes along singly linked-list of stealth indexes and makes sure
that each index is within bounds (0 <= index < numBlocks) and that the
@@ -499,19 +499,19 @@ bool Chunk::IsCorrupt( unsigned char numBlocks, std::size_t blockSize,
// Chunk::IsBlockAvailable ----------------------------------------------------
-bool Chunk::IsBlockAvailable( void * p, unsigned char numBlocks,
- std::size_t blockSize ) const
+bool Chunk::IsBlockAvailable( void* p, unsigned char numBlocks,
+ std::size_t blockSize ) const
{
(void) numBlocks;
if ( IsFilled() )
return false;
- unsigned char * place = static_cast< unsigned char * >( p );
+ unsigned char* place = static_cast< unsigned char* >( p );
// Alignment check
assert( ( place - pData_ ) % blockSize == 0 );
unsigned char blockIndex = static_cast< unsigned char >(
- ( place - pData_ ) / blockSize );
+ ( place - pData_ ) / blockSize );
unsigned char index = firstAvailableBlock_;
assert( numBlocks > index );
@@ -522,7 +522,7 @@ bool Chunk::IsBlockAvailable( void * p, unsigned char numBlocks,
found on the linked-list.
*/
std::bitset< UCHAR_MAX > foundBlocks;
- unsigned char * nextBlock = NULL;
+ unsigned char* nextBlock = NULL;
for ( unsigned char cc = 0; ; )
{
nextBlock = pData_ + ( index * blockSize );
@@ -562,7 +562,7 @@ FixedAllocator::~FixedAllocator()
assert( chunks_.empty() && "Memory leak detected!" );
#endif
for ( ChunkIter i( chunks_.begin() ); i != chunks_.end(); ++i )
- i->Release();
+ i->Release();
}
// FixedAllocator::Initialize -------------------------------------------------
@@ -592,7 +592,7 @@ std::size_t FixedAllocator::CountEmptyChunks( void ) const
std::size_t count = 0;
for ( ChunkCIter it( chunks_.begin() ); it != chunks_.end(); ++it )
{
- const Chunk & chunk = *it;
+ const Chunk& chunk = *it;
if ( chunk.HasAvailable( numBlocks_ ) )
++count;
}
@@ -642,8 +642,8 @@ bool FixedAllocator::IsCorrupt( void ) const
else
{
- const Chunk * front = &chunks_.front();
- const Chunk * back = &chunks_.back();
+ const Chunk* front = &chunks_.front();
+ const Chunk* back = &chunks_.back();
if ( start >= last )
{
assert( false );
@@ -708,7 +708,7 @@ bool FixedAllocator::IsCorrupt( void ) const
}
for ( ChunkCIter it( start ); it != last; ++it )
{
- const Chunk & chunk = *it;
+ const Chunk& chunk = *it;
if ( chunk.IsCorrupt( numBlocks_, blockSize_, true ) )
return true;
}
@@ -719,12 +719,12 @@ bool FixedAllocator::IsCorrupt( void ) const
// FixedAllocator::HasBlock ---------------------------------------------------
-const Chunk * FixedAllocator::HasBlock( void * p ) const
+const Chunk* FixedAllocator::HasBlock( void* p ) const
{
const std::size_t chunkLength = numBlocks_ * blockSize_;
for ( ChunkCIter it( chunks_.begin() ); it != chunks_.end(); ++it )
{
- const Chunk & chunk = *it;
+ const Chunk& chunk = *it;
if ( chunk.HasBlock( p, chunkLength ) )
return &chunk;
}
@@ -744,7 +744,7 @@ bool FixedAllocator::TrimEmptyChunk( void )
// And there should be exactly 1 empty Chunk.
assert( 1 == CountEmptyChunks() );
- Chunk * lastChunk = &chunks_.back();
+ Chunk* lastChunk = &chunks_.back();
if ( lastChunk != emptyChunk_ )
std::swap( *emptyChunk_, *lastChunk );
assert( lastChunk->HasAvailable( numBlocks_ ) );
@@ -828,7 +828,7 @@ bool FixedAllocator::MakeNewChunk( void )
// FixedAllocator::Allocate ---------------------------------------------------
-void * FixedAllocator::Allocate( void )
+void* FixedAllocator::Allocate( void )
{
// prove either emptyChunk_ points nowhere, or points to a truly empty Chunk.
assert( ( NULL == emptyChunk_ ) || ( emptyChunk_->HasAvailable( numBlocks_ ) ) );
@@ -867,7 +867,7 @@ void * FixedAllocator::Allocate( void )
assert( allocChunk_ != NULL );
assert( !allocChunk_->IsFilled() );
- void * place = allocChunk_->Allocate( blockSize_ );
+ void* place = allocChunk_->Allocate( blockSize_ );
// prove either emptyChunk_ points nowhere, or points to a truly empty Chunk.
assert( ( NULL == emptyChunk_ ) || ( emptyChunk_->HasAvailable( numBlocks_ ) ) );
@@ -885,7 +885,7 @@ void * FixedAllocator::Allocate( void )
// FixedAllocator::Deallocate -------------------------------------------------
-bool FixedAllocator::Deallocate( void * p, Chunk * hint )
+bool FixedAllocator::Deallocate( void* p, Chunk* hint )
{
assert(!chunks_.empty());
assert(&chunks_.front() <= deallocChunk_);
@@ -894,7 +894,7 @@ bool FixedAllocator::Deallocate( void * p, Chunk * hint )
assert( &chunks_.back() >= allocChunk_ );
assert( CountEmptyChunks() < 2 );
- Chunk * foundChunk = ( NULL == hint ) ? VicinityFind( p ) : hint;
+ Chunk* foundChunk = ( NULL == hint ) ? VicinityFind( p ) : hint;
if ( NULL == foundChunk )
return false;
@@ -920,16 +920,16 @@ bool FixedAllocator::Deallocate( void * p, Chunk * hint )
// FixedAllocator::VicinityFind -----------------------------------------------
-Chunk * FixedAllocator::VicinityFind( void * p ) const
+Chunk* FixedAllocator::VicinityFind( void* p ) const
{
if ( chunks_.empty() ) return NULL;
assert(deallocChunk_);
const std::size_t chunkLength = numBlocks_ * blockSize_;
- Chunk * lo = deallocChunk_;
- Chunk * hi = deallocChunk_ + 1;
- const Chunk * loBound = &chunks_.front();
- const Chunk * hiBound = &chunks_.back() + 1;
+ Chunk* lo = deallocChunk_;
+ Chunk* hi = deallocChunk_ + 1;
+ const Chunk* loBound = &chunks_.front();
+ const Chunk* hiBound = &chunks_.back() + 1;
// Special case: deallocChunk_ is the last in the array
if (hi == hiBound) hi = NULL;
@@ -989,7 +989,7 @@ void FixedAllocator::DoDeallocate(void* p)
// If last Chunk is empty, just change what deallocChunk_
// points to, and release the last. Otherwise, swap an empty
// Chunk with the last, and then release it.
- Chunk * lastChunk = &chunks_.back();
+ Chunk* lastChunk = &chunks_.back();
if ( lastChunk == deallocChunk_ )
deallocChunk_ = emptyChunk_;
else if ( lastChunk != emptyChunk_ )
@@ -1025,13 +1025,13 @@ inline std::size_t GetOffset( std::size_t numBytes, std::size_t alignment )
@param doThrow True if this function should throw an exception, or false if it
should indicate failure by returning a NULL pointer.
*/
-void * DefaultAllocator( std::size_t numBytes, bool doThrow )
+void* DefaultAllocator( std::size_t numBytes, bool doThrow )
{
#ifdef USE_NEW_TO_ALLOCATE
return doThrow ? ::operator new( numBytes ) :
- ::operator new( numBytes, std::nothrow_t() );
+ ::operator new( numBytes, std::nothrow_t() );
#else
- void * p = ::std::malloc( numBytes );
+ void* p = ::std::malloc( numBytes );
if ( doThrow && ( NULL == p ) )
throw std::bad_alloc();
return p;
@@ -1046,7 +1046,7 @@ void * DefaultAllocator( std::size_t numBytes, bool doThrow )
it matches malloc which is the preferred default allocator. SmallObjAllocator
will call this if an address was not found among any of its own blocks.
*/
-void DefaultDeallocator( void * p )
+void DefaultDeallocator( void* p )
{
#ifdef USE_NEW_TO_ALLOCATE
::operator delete( p );
@@ -1058,7 +1058,7 @@ void DefaultDeallocator( void * p )
// SmallObjAllocator::SmallObjAllocator ---------------------------------------
SmallObjAllocator::SmallObjAllocator( std::size_t pageSize,
- std::size_t maxObjectSize, std::size_t objectAlignSize ) :
+ std::size_t maxObjectSize, std::size_t objectAlignSize ) :
pool_( NULL ),
maxSmallObjectSize_( maxObjectSize ),
objectAlignSize_( objectAlignSize )
@@ -1106,7 +1106,7 @@ bool SmallObjAllocator::TrimExcessMemory( void )
// SmallObjAllocator::Allocate ------------------------------------------------
-void * SmallObjAllocator::Allocate( std::size_t numBytes, bool doThrow )
+void* SmallObjAllocator::Allocate( std::size_t numBytes, bool doThrow )
{
if ( numBytes > GetMaxObjectSize() )
return DefaultAllocator( numBytes, doThrow );
@@ -1118,10 +1118,10 @@ void * SmallObjAllocator::Allocate( std::size_t numBytes, bool doThrow )
(void) allocCount;
assert( index < allocCount );
- FixedAllocator & allocator = pool_[ index ];
+ FixedAllocator& allocator = pool_[ index ];
assert( allocator.BlockSize() >= numBytes );
assert( allocator.BlockSize() < numBytes + GetAlignment() );
- void * place = allocator.Allocate();
+ void* place = allocator.Allocate();
if ( ( NULL == place ) && TrimExcessMemory() )
place = allocator.Allocate();
@@ -1141,7 +1141,7 @@ void * SmallObjAllocator::Allocate( std::size_t numBytes, bool doThrow )
// SmallObjAllocator::Deallocate ----------------------------------------------
-void SmallObjAllocator::Deallocate( void * p, std::size_t numBytes )
+void SmallObjAllocator::Deallocate( void* p, std::size_t numBytes )
{
if ( NULL == p ) return;
if ( numBytes > GetMaxObjectSize() )
@@ -1155,7 +1155,7 @@ void SmallObjAllocator::Deallocate( void * p, std::size_t numBytes )
const std::size_t allocCount = GetOffset( GetMaxObjectSize(), GetAlignment() );
(void) allocCount;
assert( index < allocCount );
- FixedAllocator & allocator = pool_[ index ];
+ FixedAllocator& allocator = pool_[ index ];
assert( allocator.BlockSize() >= numBytes );
assert( allocator.BlockSize() < numBytes + GetAlignment() );
const bool found = allocator.Deallocate( p, NULL );
@@ -1165,13 +1165,13 @@ void SmallObjAllocator::Deallocate( void * p, std::size_t numBytes )
// SmallObjAllocator::Deallocate ----------------------------------------------
-void SmallObjAllocator::Deallocate( void * p )
+void SmallObjAllocator::Deallocate( void* p )
{
if ( NULL == p ) return;
assert( NULL != pool_ );
- FixedAllocator * pAllocator = NULL;
+ FixedAllocator* pAllocator = NULL;
const std::size_t allocCount = GetOffset( GetMaxObjectSize(), GetAlignment() );
- Chunk * chunk = NULL;
+ Chunk* chunk = NULL;
for ( std::size_t ii = 0; ii < allocCount; ++ii )
{
diff --git a/shared/loki/SmallObj.h b/shared/loki/SmallObj.h
index 65828bf2..8725b911 100644
--- a/shared/loki/SmallObj.h
+++ b/shared/loki/SmallObj.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_SMALLOBJ_INC_
@@ -53,590 +53,590 @@
namespace Loki
{
- namespace LongevityLifetime
- {
- /** @struct DieAsSmallObjectParent
- @ingroup SmallObjectGroup
- Lifetime policy to manage lifetime dependencies of
- SmallObject base and child classes.
- The Base class should have this lifetime
- */
- template <class T>
- struct DieAsSmallObjectParent : DieLast<T> {};
-
- /** @struct DieAsSmallObjectChild
- @ingroup SmallObjectGroup
- Lifetime policy to manage lifetime dependencies of
- SmallObject base and child classes.
- The Child class should have this lifetime
- */
- template <class T>
- struct DieAsSmallObjectChild : DieDirectlyBeforeLast<T> {};
-
- }
-
- class FixedAllocator;
-
- /** @class SmallObjAllocator
- @ingroup SmallObjectGroupInternal
- Manages pool of fixed-size allocators.
- Designed to be a non-templated base class of AllocatorSingleton so that
- implementation details can be safely hidden in the source code file.
+namespace LongevityLifetime
+{
+/** @struct DieAsSmallObjectParent
+ @ingroup SmallObjectGroup
+ Lifetime policy to manage lifetime dependencies of
+ SmallObject base and child classes.
+ The Base class should have this lifetime
+*/
+template <class T>
+struct DieAsSmallObjectParent : DieLast<T> {};
+
+/** @struct DieAsSmallObjectChild
+ @ingroup SmallObjectGroup
+ Lifetime policy to manage lifetime dependencies of
+ SmallObject base and child classes.
+ The Child class should have this lifetime
+*/
+template <class T>
+struct DieAsSmallObjectChild : DieDirectlyBeforeLast<T> {};
+
+}
+
+class FixedAllocator;
+
+/** @class SmallObjAllocator
+ @ingroup SmallObjectGroupInternal
+ Manages pool of fixed-size allocators.
+ Designed to be a non-templated base class of AllocatorSingleton so that
+ implementation details can be safely hidden in the source code file.
+ */
+class LOKI_EXPORT SmallObjAllocator
+{
+protected:
+ /** The only available constructor needs certain parameters in order to
+ initialize all the FixedAllocator's. This throws only if
+ @param pageSize # of bytes in a page of memory.
+ @param maxObjectSize Max # of bytes which this may allocate.
+ @param objectAlignSize # of bytes between alignment boundaries.
*/
- class LOKI_EXPORT SmallObjAllocator
- {
- protected:
- /** The only available constructor needs certain parameters in order to
- initialize all the FixedAllocator's. This throws only if
- @param pageSize # of bytes in a page of memory.
- @param maxObjectSize Max # of bytes which this may allocate.
- @param objectAlignSize # of bytes between alignment boundaries.
- */
- SmallObjAllocator( std::size_t pageSize, std::size_t maxObjectSize,
- std::size_t objectAlignSize );
-
- /** Destructor releases all blocks, all Chunks, and FixedAllocator's.
- Any outstanding blocks are unavailable, and should not be used after
- this destructor is called. The destructor is deliberately non-virtual
- because it is protected, not public.
- */
- ~SmallObjAllocator( void );
-
- public:
- /** Allocates a block of memory of requested size. Complexity is often
- constant-time, but might be O(C) where C is the number of Chunks in a
- FixedAllocator.
-
- @par Exception Safety Level
- Provides either strong-exception safety, or no-throw exception-safety
- level depending upon doThrow parameter. The reason it provides two
- levels of exception safety is because it is used by both the nothrow
- and throwing new operators. The underlying implementation will never
- throw of its own accord, but this can decide to throw if it does not
- allocate. The only exception it should emit is std::bad_alloc.
-
- @par Allocation Failure
- If it does not allocate, it will call TrimExcessMemory and attempt to
- allocate again, before it decides to throw or return NULL. Many
- allocators loop through several new_handler functions, and terminate
- if they can not allocate, but not this one. It only makes one attempt
- using its own implementation of the new_handler, and then returns NULL
- or throws so that the program can decide what to do at a higher level.
- (Side note: Even though the C++ Standard allows allocators and
- new_handlers to terminate if they fail, the Loki allocator does not do
- that since that policy is not polite to a host program.)
-
- @param size # of bytes needed for allocation.
- @param doThrow True if this should throw if unable to allocate, false
- if it should provide no-throw exception safety level.
- @return NULL if nothing allocated and doThrow is false. Else the
- pointer to an available block of memory.
- */
- void * Allocate( std::size_t size, bool doThrow );
-
- /** Deallocates a block of memory at a given place and of a specific
- size. Complexity is almost always constant-time, and is O(C) only if
- it has to search for which Chunk deallocates. This never throws.
- */
- void Deallocate( void * p, std::size_t size );
-
- /** Deallocates a block of memory at a given place but of unknown size
- size. Complexity is O(F + C) where F is the count of FixedAllocator's
- in the pool, and C is the number of Chunks in all FixedAllocator's. This
- does not throw exceptions. This overloaded version of Deallocate is
- called by the nothow delete operator - which is called when the nothrow
- new operator is used, but a constructor throws an exception.
- */
- void Deallocate( void * p );
-
- /// Returns max # of bytes which this can allocate.
- inline std::size_t GetMaxObjectSize() const
- { return maxSmallObjectSize_; }
-
- /// Returns # of bytes between allocation boundaries.
- inline std::size_t GetAlignment() const { return objectAlignSize_; }
-
- /** Releases empty Chunks from memory. Complexity is O(F + C) where F
- is the count of FixedAllocator's in the pool, and C is the number of
- Chunks in all FixedAllocator's. This will never throw. This is called
- by AllocatorSingleto::ClearExtraMemory, the new_handler function for
- Loki's allocator, and is called internally when an allocation fails.
- @return True if any memory released, or false if none released.
- */
- bool TrimExcessMemory( void );
-
- /** Returns true if anything in implementation is corrupt. Complexity
- is O(F + C + B) where F is the count of FixedAllocator's in the pool,
- C is the number of Chunks in all FixedAllocator's, and B is the number
- of blocks in all Chunks. If it determines any data is corrupted, this
- will return true in release version, but assert in debug version at
- the line where it detects the corrupted data. If it does not detect
- any corrupted data, it returns false.
- */
- bool IsCorrupt( void ) const;
-
- private:
- /// Default-constructor is not implemented.
- SmallObjAllocator( void );
- /// Copy-constructor is not implemented.
- SmallObjAllocator( const SmallObjAllocator & );
- /// Copy-assignment operator is not implemented.
- SmallObjAllocator & operator = ( const SmallObjAllocator & );
-
- /// Pointer to array of fixed-size allocators.
- Loki::FixedAllocator * pool_;
-
- /// Largest object size supported by allocators.
- const std::size_t maxSmallObjectSize_;
-
- /// Size of alignment boundaries.
- const std::size_t objectAlignSize_;
- };
-
-
- /** @class AllocatorSingleton
- @ingroup SmallObjectGroupInternal
- This template class is derived from
- SmallObjAllocator in order to pass template arguments into it, and still
- have a default constructor for the singleton. Each instance is a unique
- combination of all the template parameters, and hence is singleton only
- with respect to those parameters. The template parameters have default
- values and the class has typedefs identical to both SmallObject and
- SmallValueObject so that this class can be used directly instead of going
- through SmallObject or SmallValueObject. That design feature allows
- clients to use the new_handler without having the name of the new_handler
- function show up in classes derived from SmallObject or SmallValueObject.
- Thus, the only functions in the allocator which show up in SmallObject or
- SmallValueObject inheritance hierarchies are the new and delete
- operators.
- */
- template
- <
- template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL,
- std::size_t chunkSize = LOKI_DEFAULT_CHUNK_SIZE,
- std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE,
- std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT,
- template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME,
- class MutexPolicy = LOKI_DEFAULT_MUTEX
- >
- class AllocatorSingleton : public SmallObjAllocator
- {
- public:
+ SmallObjAllocator( std::size_t pageSize, std::size_t maxObjectSize,
+ std::size_t objectAlignSize );
+
+ /** Destructor releases all blocks, all Chunks, and FixedAllocator's.
+ Any outstanding blocks are unavailable, and should not be used after
+ this destructor is called. The destructor is deliberately non-virtual
+ because it is protected, not public.
+ */
+ ~SmallObjAllocator( void );
+
+public:
+ /** Allocates a block of memory of requested size. Complexity is often
+ constant-time, but might be O(C) where C is the number of Chunks in a
+ FixedAllocator.
+
+ @par Exception Safety Level
+ Provides either strong-exception safety, or no-throw exception-safety
+ level depending upon doThrow parameter. The reason it provides two
+ levels of exception safety is because it is used by both the nothrow
+ and throwing new operators. The underlying implementation will never
+ throw of its own accord, but this can decide to throw if it does not
+ allocate. The only exception it should emit is std::bad_alloc.
+
+ @par Allocation Failure
+ If it does not allocate, it will call TrimExcessMemory and attempt to
+ allocate again, before it decides to throw or return NULL. Many
+ allocators loop through several new_handler functions, and terminate
+ if they can not allocate, but not this one. It only makes one attempt
+ using its own implementation of the new_handler, and then returns NULL
+ or throws so that the program can decide what to do at a higher level.
+ (Side note: Even though the C++ Standard allows allocators and
+ new_handlers to terminate if they fail, the Loki allocator does not do
+ that since that policy is not polite to a host program.)
+
+ @param size # of bytes needed for allocation.
+ @param doThrow True if this should throw if unable to allocate, false
+ if it should provide no-throw exception safety level.
+ @return NULL if nothing allocated and doThrow is false. Else the
+ pointer to an available block of memory.
+ */
+ void* Allocate( std::size_t size, bool doThrow );
+
+ /** Deallocates a block of memory at a given place and of a specific
+ size. Complexity is almost always constant-time, and is O(C) only if
+ it has to search for which Chunk deallocates. This never throws.
+ */
+ void Deallocate( void* p, std::size_t size );
+
+ /** Deallocates a block of memory at a given place but of unknown size
+ size. Complexity is O(F + C) where F is the count of FixedAllocator's
+ in the pool, and C is the number of Chunks in all FixedAllocator's. This
+ does not throw exceptions. This overloaded version of Deallocate is
+ called by the nothow delete operator - which is called when the nothrow
+ new operator is used, but a constructor throws an exception.
+ */
+ void Deallocate( void* p );
- /// Defines type of allocator.
- typedef AllocatorSingleton< ThreadingModel, chunkSize,
+ /// Returns max # of bytes which this can allocate.
+ inline std::size_t GetMaxObjectSize() const
+ { return maxSmallObjectSize_; }
+
+ /// Returns # of bytes between allocation boundaries.
+ inline std::size_t GetAlignment() const { return objectAlignSize_; }
+
+ /** Releases empty Chunks from memory. Complexity is O(F + C) where F
+ is the count of FixedAllocator's in the pool, and C is the number of
+ Chunks in all FixedAllocator's. This will never throw. This is called
+ by AllocatorSingleto::ClearExtraMemory, the new_handler function for
+ Loki's allocator, and is called internally when an allocation fails.
+ @return True if any memory released, or false if none released.
+ */
+ bool TrimExcessMemory( void );
+
+ /** Returns true if anything in implementation is corrupt. Complexity
+ is O(F + C + B) where F is the count of FixedAllocator's in the pool,
+ C is the number of Chunks in all FixedAllocator's, and B is the number
+ of blocks in all Chunks. If it determines any data is corrupted, this
+ will return true in release version, but assert in debug version at
+ the line where it detects the corrupted data. If it does not detect
+ any corrupted data, it returns false.
+ */
+ bool IsCorrupt( void ) const;
+
+private:
+ /// Default-constructor is not implemented.
+ SmallObjAllocator( void );
+ /// Copy-constructor is not implemented.
+ SmallObjAllocator( const SmallObjAllocator& );
+ /// Copy-assignment operator is not implemented.
+ SmallObjAllocator& operator = ( const SmallObjAllocator& );
+
+ /// Pointer to array of fixed-size allocators.
+ Loki::FixedAllocator* pool_;
+
+ /// Largest object size supported by allocators.
+ const std::size_t maxSmallObjectSize_;
+
+ /// Size of alignment boundaries.
+ const std::size_t objectAlignSize_;
+};
+
+
+/** @class AllocatorSingleton
+ @ingroup SmallObjectGroupInternal
+ This template class is derived from
+ SmallObjAllocator in order to pass template arguments into it, and still
+ have a default constructor for the singleton. Each instance is a unique
+ combination of all the template parameters, and hence is singleton only
+ with respect to those parameters. The template parameters have default
+ values and the class has typedefs identical to both SmallObject and
+ SmallValueObject so that this class can be used directly instead of going
+ through SmallObject or SmallValueObject. That design feature allows
+ clients to use the new_handler without having the name of the new_handler
+ function show up in classes derived from SmallObject or SmallValueObject.
+ Thus, the only functions in the allocator which show up in SmallObject or
+ SmallValueObject inheritance hierarchies are the new and delete
+ operators.
+*/
+template
+<
+template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL,
+ std::size_t chunkSize = LOKI_DEFAULT_CHUNK_SIZE,
+ std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE,
+ std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT,
+ template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME,
+ class MutexPolicy = LOKI_DEFAULT_MUTEX
+ >
+class AllocatorSingleton : public SmallObjAllocator
+{
+public:
+
+ /// Defines type of allocator.
+ typedef AllocatorSingleton< ThreadingModel, chunkSize,
maxSmallObjectSize, objectAlignSize, LifetimePolicy > MyAllocator;
- /// Defines type for thread-safety locking mechanism.
- typedef ThreadingModel< MyAllocator, MutexPolicy > MyThreadingModel;
+ /// Defines type for thread-safety locking mechanism.
+ typedef ThreadingModel< MyAllocator, MutexPolicy > MyThreadingModel;
- /// Defines singleton made from allocator.
- typedef Loki::SingletonHolder< MyAllocator, Loki::CreateStatic,
+ /// Defines singleton made from allocator.
+ typedef Loki::SingletonHolder< MyAllocator, Loki::CreateStatic,
LifetimePolicy, ThreadingModel > MyAllocatorSingleton;
- /// Returns reference to the singleton.
- inline static AllocatorSingleton & Instance( void )
- {
- return MyAllocatorSingleton::Instance();
- }
-
- /// The default constructor is not meant to be called directly.
- inline AllocatorSingleton() :
- SmallObjAllocator( chunkSize, maxSmallObjectSize, objectAlignSize )
- {}
-
- /// The destructor is not meant to be called directly.
- inline ~AllocatorSingleton( void ) {}
-
- /** Clears any excess memory used by the allocator. Complexity is
- O(F + C) where F is the count of FixedAllocator's in the pool, and C
- is the number of Chunks in all FixedAllocator's. This never throws.
- @note This function can be used as a new_handler when Loki and other
- memory allocators can no longer allocate. Although the C++ Standard
- allows new_handler functions to terminate the program when they can
- not release any memory, this will not do so.
- */
- static void ClearExtraMemory( void );
-
- /** Returns true if anything in implementation is corrupt. Complexity
- is O(F + C + B) where F is the count of FixedAllocator's in the pool,
- C is the number of Chunks in all FixedAllocator's, and B is the number
- of blocks in all Chunks. If it determines any data is corrupted, this
- will return true in release version, but assert in debug version at
- the line where it detects the corrupted data. If it does not detect
- any corrupted data, it returns false.
- */
- static bool IsCorrupted( void );
-
- private:
- /// Copy-constructor is not implemented.
- AllocatorSingleton( const AllocatorSingleton & );
- /// Copy-assignment operator is not implemented.
- AllocatorSingleton & operator = ( const AllocatorSingleton & );
- };
-
- template
- <
- template <class, class> class T,
- std::size_t C,
- std::size_t M,
- std::size_t O,
- template <class> class L,
- class X
- >
- void AllocatorSingleton< T, C, M, O, L, X >::ClearExtraMemory( void )
+ /// Returns reference to the singleton.
+ inline static AllocatorSingleton& Instance( void )
+ {
+ return MyAllocatorSingleton::Instance();
+ }
+
+ /// The default constructor is not meant to be called directly.
+ inline AllocatorSingleton() :
+ SmallObjAllocator( chunkSize, maxSmallObjectSize, objectAlignSize )
+ {}
+
+ /// The destructor is not meant to be called directly.
+ inline ~AllocatorSingleton( void ) {}
+
+ /** Clears any excess memory used by the allocator. Complexity is
+ O(F + C) where F is the count of FixedAllocator's in the pool, and C
+ is the number of Chunks in all FixedAllocator's. This never throws.
+ @note This function can be used as a new_handler when Loki and other
+ memory allocators can no longer allocate. Although the C++ Standard
+ allows new_handler functions to terminate the program when they can
+ not release any memory, this will not do so.
+ */
+ static void ClearExtraMemory( void );
+
+ /** Returns true if anything in implementation is corrupt. Complexity
+ is O(F + C + B) where F is the count of FixedAllocator's in the pool,
+ C is the number of Chunks in all FixedAllocator's, and B is the number
+ of blocks in all Chunks. If it determines any data is corrupted, this
+ will return true in release version, but assert in debug version at
+ the line where it detects the corrupted data. If it does not detect
+ any corrupted data, it returns false.
+ */
+ static bool IsCorrupted( void );
+
+private:
+ /// Copy-constructor is not implemented.
+ AllocatorSingleton( const AllocatorSingleton& );
+ /// Copy-assignment operator is not implemented.
+ AllocatorSingleton& operator = ( const AllocatorSingleton& );
+};
+
+template
+<
+template <class, class> class T,
+ std::size_t C,
+ std::size_t M,
+ std::size_t O,
+ template <class> class L,
+ class X
+ >
+void AllocatorSingleton< T, C, M, O, L, X >::ClearExtraMemory( void )
+{
+ typename MyThreadingModel::Lock lock;
+ (void)lock; // get rid of warning
+ Instance().TrimExcessMemory();
+}
+
+template
+<
+template <class, class> class T,
+ std::size_t C,
+ std::size_t M,
+ std::size_t O,
+ template <class> class L,
+ class X
+ >
+bool AllocatorSingleton< T, C, M, O, L, X >::IsCorrupted( void )
+{
+ typename MyThreadingModel::Lock lock;
+ (void)lock; // get rid of warning
+ return Instance().IsCorrupt();
+}
+
+/** This standalone function provides the longevity level for Small-Object
+ Allocators which use the Loki::SingletonWithLongevity policy. The
+ SingletonWithLongevity class can find this function through argument-
+ dependent lookup.
+
+ @par Longevity Levels
+ No Small-Object Allocator depends on any other Small-Object allocator, so
+ this does not need to calculate dependency levels among allocators, and
+ it returns just a constant. All allocators must live longer than the
+ objects which use the allocators, it must return a longevity level higher
+ than any such object.
+ */
+template
+<
+template <class, class> class T,
+ std::size_t C,
+ std::size_t M,
+ std::size_t O,
+ template <class> class L,
+ class X
+ >
+inline unsigned int GetLongevity(
+ AllocatorSingleton< T, C, M, O, L, X > * )
+{
+ // Returns highest possible value.
+ return 0xFFFFFFFF;
+}
+
+
+/** @class SmallObjectBase
+ @ingroup SmallObjectGroup
+ Base class for small object allocation classes.
+ The shared implementation of the new and delete operators are here instead
+ of being duplicated in both SmallObject or SmallValueObject, later just
+ called Small-Objects. This class is not meant to be used directly by clients,
+ or derived from by clients. Class has no data members so compilers can
+ use Empty-Base-Optimization.
+
+ @par ThreadingModel
+ This class doesn't support ObjectLevelLockable policy for ThreadingModel.
+ The allocator is a singleton, so a per-instance mutex is not necessary.
+ Nor is using ObjectLevelLockable recommended with SingletonHolder since
+ the SingletonHolder::MakeInstance function requires a mutex that exists
+ prior to when the object is created - which is not possible if the mutex
+ is inside the object, such as required for ObjectLevelLockable. If you
+ attempt to use ObjectLevelLockable, the compiler will emit errors because
+ it can't use the default constructor in ObjectLevelLockable. If you need
+ a thread-safe allocator, use the ClassLevelLockable policy.
+
+ @par Lifetime Policy
+
+ The SmallObjectBase template needs a lifetime policy because it owns
+ a singleton of SmallObjAllocator which does all the low level functions.
+ When using a Small-Object in combination with the SingletonHolder template
+ you have to choose two lifetimes, that of the Small-Object and that of
+ the singleton. The rule is: The Small-Object lifetime must be greater than
+ the lifetime of the singleton hosting the Small-Object. Violating this rule
+ results in a crash on exit, because the hosting singleton tries to delete
+ the Small-Object which is then already destroyed.
+
+ The lifetime policies recommended for use with Small-Objects hosted
+ by a SingletonHolder template are
+ - LongevityLifetime::DieAsSmallObjectParent / LongevityLifetime::DieAsSmallObjectChild
+ - SingletonWithLongevity
+ - FollowIntoDeath (not supported by MSVC 7.1)
+ - NoDestroy
+
+ The default lifetime of Small-Objects is
+ LongevityLifetime::DieAsSmallObjectParent to
+ insure that memory is not released before a object with the lifetime
+ LongevityLifetime::DieAsSmallObjectChild using that
+ memory is destroyed. The LongevityLifetime::DieAsSmallObjectParent
+ lifetime has the highest possible value of a SetLongevity lifetime, so
+ you can use it in combination with your own lifetime not having also
+ the highest possible value.
+
+ The DefaultLifetime and PhoenixSingleton policies are *not* recommended
+ since they can cause the allocator to be destroyed and release memory
+ for singletons hosting a object which inherit from either SmallObject
+ or SmallValueObject.
+
+ @par Lifetime usage
+
+ - LongevityLifetime: The Small-Object has
+ LongevityLifetime::DieAsSmallObjectParent policy and the Singleton
+ hosting the Small-Object has LongevityLifetime::DieAsSmallObjectChild.
+ The child lifetime has a hard coded SetLongevity lifetime which is
+ shorter than the lifetime of the parent, thus the child dies
+ before the parent.
+
+ - Both Small-Object and Singleton use SingletonWithLongevity policy.
+ The longevity level for the singleton must be lower than that for the
+ Small-Object. This is why the AllocatorSingleton's GetLongevity function
+ returns the highest value.
+
+ - FollowIntoDeath lifetime: The Small-Object has
+ FollowIntoDeath::With<LIFETIME>::AsMasterLiftime
+ policy and the Singleton has
+ FollowIntoDeath::AfterMaster<MASTERSINGLETON>::IsDestroyed policy,
+ where you could choose the LIFETIME.
+
+ - Both Small-Object and Singleton use NoDestroy policy.
+ Since neither is ever destroyed, the destruction order does not matter.
+ Note: you will get memory leaks!
+
+ - The Small-Object has NoDestroy policy but the Singleton has
+ SingletonWithLongevity policy. Note: you will get memory leaks!
+
+
+ You should *not* use NoDestroy for the singleton, and then use
+ SingletonWithLongevity for the Small-Object.
+
+ @par Examples:
+
+ - test/SmallObj/SmallSingleton.cpp
+ - test/Singleton/Dependencies.cpp
+ */
+template
+<
+template <class, class> class ThreadingModel,
+ std::size_t chunkSize,
+ std::size_t maxSmallObjectSize,
+ std::size_t objectAlignSize,
+ template <class> class LifetimePolicy,
+ class MutexPolicy
+ >
+class SmallObjectBase
+{
+
+#if (LOKI_MAX_SMALL_OBJECT_SIZE != 0) && (LOKI_DEFAULT_CHUNK_SIZE != 0) && (LOKI_DEFAULT_OBJECT_ALIGNMENT != 0)
+
+public:
+ /// Defines type of allocator singleton, must be public
+ /// to handle singleton lifetime dependencies.
+ typedef AllocatorSingleton< ThreadingModel, chunkSize,
+ maxSmallObjectSize, objectAlignSize, LifetimePolicy > ObjAllocatorSingleton;
+
+private:
+
+ /// Defines type for thread-safety locking mechanism.
+ typedef ThreadingModel< ObjAllocatorSingleton, MutexPolicy > MyThreadingModel;
+
+ /// Use singleton defined in AllocatorSingleton.
+ typedef typename ObjAllocatorSingleton::MyAllocatorSingleton MyAllocatorSingleton;
+
+public:
+
+ /// Throwing single-object new throws bad_alloc when allocation fails.
+#ifdef _MSC_VER
+ /// @note MSVC complains about non-empty exception specification lists.
+ static void* operator new ( std::size_t size )
+#else
+ static void* operator new ( std::size_t size ) throw ( std::bad_alloc )
+#endif
{
typename MyThreadingModel::Lock lock;
(void)lock; // get rid of warning
- Instance().TrimExcessMemory();
+ return MyAllocatorSingleton::Instance().Allocate( size, true );
}
- template
- <
- template <class, class> class T,
- std::size_t C,
- std::size_t M,
- std::size_t O,
- template <class> class L,
- class X
- >
- bool AllocatorSingleton< T, C, M, O, L, X >::IsCorrupted( void )
+ /// Non-throwing single-object new returns NULL if allocation fails.
+ static void* operator new ( std::size_t size, const std::nothrow_t& ) throw ()
{
typename MyThreadingModel::Lock lock;
(void)lock; // get rid of warning
- return Instance().IsCorrupt();
+ return MyAllocatorSingleton::Instance().Allocate( size, false );
}
- /** This standalone function provides the longevity level for Small-Object
- Allocators which use the Loki::SingletonWithLongevity policy. The
- SingletonWithLongevity class can find this function through argument-
- dependent lookup.
-
- @par Longevity Levels
- No Small-Object Allocator depends on any other Small-Object allocator, so
- this does not need to calculate dependency levels among allocators, and
- it returns just a constant. All allocators must live longer than the
- objects which use the allocators, it must return a longevity level higher
- than any such object.
- */
- template
- <
- template <class, class> class T,
- std::size_t C,
- std::size_t M,
- std::size_t O,
- template <class> class L,
- class X
- >
- inline unsigned int GetLongevity(
- AllocatorSingleton< T, C, M, O, L, X > * )
+ /// Placement single-object new merely calls global placement new.
+ inline static void* operator new ( std::size_t size, void* place )
{
- // Returns highest possible value.
- return 0xFFFFFFFF;
+ return ::operator new( size, place );
}
+ /// Single-object delete.
+ static void operator delete ( void* p, std::size_t size ) throw ()
+ {
+ typename MyThreadingModel::Lock lock;
+ (void)lock; // get rid of warning
+ MyAllocatorSingleton::Instance().Deallocate( p, size );
+ }
- /** @class SmallObjectBase
- @ingroup SmallObjectGroup
- Base class for small object allocation classes.
- The shared implementation of the new and delete operators are here instead
- of being duplicated in both SmallObject or SmallValueObject, later just
- called Small-Objects. This class is not meant to be used directly by clients,
- or derived from by clients. Class has no data members so compilers can
- use Empty-Base-Optimization.
-
- @par ThreadingModel
- This class doesn't support ObjectLevelLockable policy for ThreadingModel.
- The allocator is a singleton, so a per-instance mutex is not necessary.
- Nor is using ObjectLevelLockable recommended with SingletonHolder since
- the SingletonHolder::MakeInstance function requires a mutex that exists
- prior to when the object is created - which is not possible if the mutex
- is inside the object, such as required for ObjectLevelLockable. If you
- attempt to use ObjectLevelLockable, the compiler will emit errors because
- it can't use the default constructor in ObjectLevelLockable. If you need
- a thread-safe allocator, use the ClassLevelLockable policy.
-
- @par Lifetime Policy
-
- The SmallObjectBase template needs a lifetime policy because it owns
- a singleton of SmallObjAllocator which does all the low level functions.
- When using a Small-Object in combination with the SingletonHolder template
- you have to choose two lifetimes, that of the Small-Object and that of
- the singleton. The rule is: The Small-Object lifetime must be greater than
- the lifetime of the singleton hosting the Small-Object. Violating this rule
- results in a crash on exit, because the hosting singleton tries to delete
- the Small-Object which is then already destroyed.
-
- The lifetime policies recommended for use with Small-Objects hosted
- by a SingletonHolder template are
- - LongevityLifetime::DieAsSmallObjectParent / LongevityLifetime::DieAsSmallObjectChild
- - SingletonWithLongevity
- - FollowIntoDeath (not supported by MSVC 7.1)
- - NoDestroy
-
- The default lifetime of Small-Objects is
- LongevityLifetime::DieAsSmallObjectParent to
- insure that memory is not released before a object with the lifetime
- LongevityLifetime::DieAsSmallObjectChild using that
- memory is destroyed. The LongevityLifetime::DieAsSmallObjectParent
- lifetime has the highest possible value of a SetLongevity lifetime, so
- you can use it in combination with your own lifetime not having also
- the highest possible value.
-
- The DefaultLifetime and PhoenixSingleton policies are *not* recommended
- since they can cause the allocator to be destroyed and release memory
- for singletons hosting a object which inherit from either SmallObject
- or SmallValueObject.
-
- @par Lifetime usage
-
- - LongevityLifetime: The Small-Object has
- LongevityLifetime::DieAsSmallObjectParent policy and the Singleton
- hosting the Small-Object has LongevityLifetime::DieAsSmallObjectChild.
- The child lifetime has a hard coded SetLongevity lifetime which is
- shorter than the lifetime of the parent, thus the child dies
- before the parent.
-
- - Both Small-Object and Singleton use SingletonWithLongevity policy.
- The longevity level for the singleton must be lower than that for the
- Small-Object. This is why the AllocatorSingleton's GetLongevity function
- returns the highest value.
-
- - FollowIntoDeath lifetime: The Small-Object has
- FollowIntoDeath::With<LIFETIME>::AsMasterLiftime
- policy and the Singleton has
- FollowIntoDeath::AfterMaster<MASTERSINGLETON>::IsDestroyed policy,
- where you could choose the LIFETIME.
-
- - Both Small-Object and Singleton use NoDestroy policy.
- Since neither is ever destroyed, the destruction order does not matter.
- Note: you will get memory leaks!
-
- - The Small-Object has NoDestroy policy but the Singleton has
- SingletonWithLongevity policy. Note: you will get memory leaks!
-
-
- You should *not* use NoDestroy for the singleton, and then use
- SingletonWithLongevity for the Small-Object.
-
- @par Examples:
-
- - test/SmallObj/SmallSingleton.cpp
- - test/Singleton/Dependencies.cpp
+ /** Non-throwing single-object delete is only called when nothrow
+ new operator is used, and the constructor throws an exception.
*/
- template
- <
- template <class, class> class ThreadingModel,
- std::size_t chunkSize,
- std::size_t maxSmallObjectSize,
- std::size_t objectAlignSize,
- template <class> class LifetimePolicy,
- class MutexPolicy
- >
- class SmallObjectBase
+ static void operator delete ( void* p, const std::nothrow_t& ) throw()
{
+ typename MyThreadingModel::Lock lock;
+ (void)lock; // get rid of warning
+ MyAllocatorSingleton::Instance().Deallocate( p );
+ }
-#if (LOKI_MAX_SMALL_OBJECT_SIZE != 0) && (LOKI_DEFAULT_CHUNK_SIZE != 0) && (LOKI_DEFAULT_OBJECT_ALIGNMENT != 0)
-
- public:
- /// Defines type of allocator singleton, must be public
- /// to handle singleton lifetime dependencies.
- typedef AllocatorSingleton< ThreadingModel, chunkSize,
- maxSmallObjectSize, objectAlignSize, LifetimePolicy > ObjAllocatorSingleton;
-
- private:
-
- /// Defines type for thread-safety locking mechanism.
- typedef ThreadingModel< ObjAllocatorSingleton, MutexPolicy > MyThreadingModel;
+ /// Placement single-object delete merely calls global placement delete.
+ inline static void operator delete ( void* p, void* place )
+ {
+ ::operator delete ( p, place );
+ }
- /// Use singleton defined in AllocatorSingleton.
- typedef typename ObjAllocatorSingleton::MyAllocatorSingleton MyAllocatorSingleton;
-
- public:
+#ifdef LOKI_SMALL_OBJECT_USE_NEW_ARRAY
- /// Throwing single-object new throws bad_alloc when allocation fails.
+ /// Throwing array-object new throws bad_alloc when allocation fails.
#ifdef _MSC_VER
- /// @note MSVC complains about non-empty exception specification lists.
- static void * operator new ( std::size_t size )
+ /// @note MSVC complains about non-empty exception specification lists.
+ static void* operator new [] ( std::size_t size )
#else
- static void * operator new ( std::size_t size ) throw ( std::bad_alloc )
+ static void* operator new [] ( std::size_t size )
+ throw ( std::bad_alloc )
#endif
- {
- typename MyThreadingModel::Lock lock;
- (void)lock; // get rid of warning
- return MyAllocatorSingleton::Instance().Allocate( size, true );
- }
-
- /// Non-throwing single-object new returns NULL if allocation fails.
- static void * operator new ( std::size_t size, const std::nothrow_t & ) throw ()
- {
- typename MyThreadingModel::Lock lock;
- (void)lock; // get rid of warning
- return MyAllocatorSingleton::Instance().Allocate( size, false );
- }
-
- /// Placement single-object new merely calls global placement new.
- inline static void * operator new ( std::size_t size, void * place )
- {
- return ::operator new( size, place );
- }
-
- /// Single-object delete.
- static void operator delete ( void * p, std::size_t size ) throw ()
- {
- typename MyThreadingModel::Lock lock;
- (void)lock; // get rid of warning
- MyAllocatorSingleton::Instance().Deallocate( p, size );
- }
-
- /** Non-throwing single-object delete is only called when nothrow
- new operator is used, and the constructor throws an exception.
- */
- static void operator delete ( void * p, const std::nothrow_t & ) throw()
- {
- typename MyThreadingModel::Lock lock;
- (void)lock; // get rid of warning
- MyAllocatorSingleton::Instance().Deallocate( p );
- }
-
- /// Placement single-object delete merely calls global placement delete.
- inline static void operator delete ( void * p, void * place )
- {
- ::operator delete ( p, place );
- }
+ {
+ typename MyThreadingModel::Lock lock;
+ (void)lock; // get rid of warning
+ return MyAllocatorSingleton::Instance().Allocate( size, true );
+ }
-#ifdef LOKI_SMALL_OBJECT_USE_NEW_ARRAY
+ /// Non-throwing array-object new returns NULL if allocation fails.
+ static void* operator new [] ( std::size_t size,
+ const std::nothrow_t& ) throw ()
+ {
+ typename MyThreadingModel::Lock lock;
+ (void)lock; // get rid of warning
+ return MyAllocatorSingleton::Instance().Allocate( size, false );
+ }
- /// Throwing array-object new throws bad_alloc when allocation fails.
-#ifdef _MSC_VER
- /// @note MSVC complains about non-empty exception specification lists.
- static void * operator new [] ( std::size_t size )
-#else
- static void * operator new [] ( std::size_t size )
- throw ( std::bad_alloc )
-#endif
- {
- typename MyThreadingModel::Lock lock;
- (void)lock; // get rid of warning
- return MyAllocatorSingleton::Instance().Allocate( size, true );
- }
-
- /// Non-throwing array-object new returns NULL if allocation fails.
- static void * operator new [] ( std::size_t size,
- const std::nothrow_t & ) throw ()
- {
- typename MyThreadingModel::Lock lock;
- (void)lock; // get rid of warning
- return MyAllocatorSingleton::Instance().Allocate( size, false );
- }
-
- /// Placement array-object new merely calls global placement new.
- inline static void * operator new [] ( std::size_t size, void * place )
- {
- return ::operator new( size, place );
- }
-
- /// Array-object delete.
- static void operator delete [] ( void * p, std::size_t size ) throw ()
- {
- typename MyThreadingModel::Lock lock;
- (void)lock; // get rid of warning
- MyAllocatorSingleton::Instance().Deallocate( p, size );
- }
-
- /** Non-throwing array-object delete is only called when nothrow
- new operator is used, and the constructor throws an exception.
- */
- static void operator delete [] ( void * p,
- const std::nothrow_t & ) throw()
- {
- typename MyThreadingModel::Lock lock;
- (void)lock; // get rid of warning
- MyAllocatorSingleton::Instance().Deallocate( p );
- }
-
- /// Placement array-object delete merely calls global placement delete.
- inline static void operator delete [] ( void * p, void * place )
- {
- ::operator delete ( p, place );
- }
-#endif // #if use new array functions.
+ /// Placement array-object new merely calls global placement new.
+ inline static void* operator new [] ( std::size_t size, void* place )
+ {
+ return ::operator new( size, place );
+ }
-#endif // #if default template parameters are not zero
+ /// Array-object delete.
+ static void operator delete [] ( void* p, std::size_t size ) throw ()
+ {
+ typename MyThreadingModel::Lock lock;
+ (void)lock; // get rid of warning
+ MyAllocatorSingleton::Instance().Deallocate( p, size );
+ }
- protected:
- inline SmallObjectBase( void ) {}
- inline SmallObjectBase( const SmallObjectBase & ) {}
- inline SmallObjectBase & operator = ( const SmallObjectBase & )
- { return *this; }
- inline ~SmallObjectBase() {}
- }; // end class SmallObjectBase
-
-
- /** @class SmallObject
- @ingroup SmallObjectGroup
- SmallObject Base class for polymorphic small objects, offers fast
- allocations & deallocations. Destructor is virtual and public. Default
- constructor is trivial. Copy-constructor and copy-assignment operator are
- not implemented since polymorphic classes almost always disable those
- operations. Class has no data members so compilers can use
- Empty-Base-Optimization.
+ /** Non-throwing array-object delete is only called when nothrow
+ new operator is used, and the constructor throws an exception.
*/
- template
- <
- template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL,
- std::size_t chunkSize = LOKI_DEFAULT_CHUNK_SIZE,
- std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE,
- std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT,
- template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME,
- class MutexPolicy = LOKI_DEFAULT_MUTEX
- >
- class SmallObject : public SmallObjectBase< ThreadingModel, chunkSize,
- maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
+ static void operator delete [] ( void* p,
+ const std::nothrow_t& ) throw()
{
+ typename MyThreadingModel::Lock lock;
+ (void)lock; // get rid of warning
+ MyAllocatorSingleton::Instance().Deallocate( p );
+ }
- public:
- virtual ~SmallObject() {}
- protected:
- inline SmallObject( void ) {}
-
- private:
- /// Copy-constructor is not implemented.
- SmallObject( const SmallObject & );
- /// Copy-assignment operator is not implemented.
- SmallObject & operator = ( const SmallObject & );
- }; // end class SmallObject
-
-
- /** @class SmallValueObject
- @ingroup SmallObjectGroup
- SmallValueObject Base class for small objects with value-type
- semantics - offers fast allocations & deallocations. Destructor is
- non-virtual, inline, and protected to prevent unintentional destruction
- through base class. Default constructor is trivial. Copy-constructor
- and copy-assignment operator are trivial since value-types almost always
- need those operations. Class has no data members so compilers can use
- Empty-Base-Optimization.
- */
- template
- <
- template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL,
- std::size_t chunkSize = LOKI_DEFAULT_CHUNK_SIZE,
- std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE,
- std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT,
- template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME,
- class MutexPolicy = LOKI_DEFAULT_MUTEX
- >
- class SmallValueObject : public SmallObjectBase< ThreadingModel, chunkSize,
- maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
+ /// Placement array-object delete merely calls global placement delete.
+ inline static void operator delete [] ( void* p, void* place )
{
- protected:
- inline SmallValueObject( void ) {}
- inline SmallValueObject( const SmallValueObject & ) {}
- inline SmallValueObject & operator = ( const SmallValueObject & )
- { return *this; }
- inline ~SmallValueObject() {}
- }; // end class SmallValueObject
+ ::operator delete ( p, place );
+ }
+#endif // #if use new array functions.
+
+#endif // #if default template parameters are not zero
+
+protected:
+ inline SmallObjectBase( void ) {}
+ inline SmallObjectBase( const SmallObjectBase& ) {}
+ inline SmallObjectBase& operator = ( const SmallObjectBase& )
+ { return *this; }
+ inline ~SmallObjectBase() {}
+}; // end class SmallObjectBase
+
+
+/** @class SmallObject
+ @ingroup SmallObjectGroup
+ SmallObject Base class for polymorphic small objects, offers fast
+ allocations & deallocations. Destructor is virtual and public. Default
+ constructor is trivial. Copy-constructor and copy-assignment operator are
+ not implemented since polymorphic classes almost always disable those
+ operations. Class has no data members so compilers can use
+ Empty-Base-Optimization.
+ */
+template
+<
+template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL,
+ std::size_t chunkSize = LOKI_DEFAULT_CHUNK_SIZE,
+ std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE,
+ std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT,
+ template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME,
+ class MutexPolicy = LOKI_DEFAULT_MUTEX
+ >
+class SmallObject : public SmallObjectBase< ThreadingModel, chunkSize,
+ maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
+{
+
+public:
+ virtual ~SmallObject() {}
+protected:
+ inline SmallObject( void ) {}
+
+private:
+ /// Copy-constructor is not implemented.
+ SmallObject( const SmallObject& );
+ /// Copy-assignment operator is not implemented.
+ SmallObject& operator = ( const SmallObject& );
+}; // end class SmallObject
+
+
+/** @class SmallValueObject
+ @ingroup SmallObjectGroup
+ SmallValueObject Base class for small objects with value-type
+ semantics - offers fast allocations & deallocations. Destructor is
+ non-virtual, inline, and protected to prevent unintentional destruction
+ through base class. Default constructor is trivial. Copy-constructor
+ and copy-assignment operator are trivial since value-types almost always
+ need those operations. Class has no data members so compilers can use
+ Empty-Base-Optimization.
+ */
+template
+<
+template <class, class> class ThreadingModel = LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL,
+ std::size_t chunkSize = LOKI_DEFAULT_CHUNK_SIZE,
+ std::size_t maxSmallObjectSize = LOKI_MAX_SMALL_OBJECT_SIZE,
+ std::size_t objectAlignSize = LOKI_DEFAULT_OBJECT_ALIGNMENT,
+ template <class> class LifetimePolicy = LOKI_DEFAULT_SMALLOBJ_LIFETIME,
+ class MutexPolicy = LOKI_DEFAULT_MUTEX
+ >
+class SmallValueObject : public SmallObjectBase< ThreadingModel, chunkSize,
+ maxSmallObjectSize, objectAlignSize, LifetimePolicy, MutexPolicy >
+{
+protected:
+ inline SmallValueObject( void ) {}
+ inline SmallValueObject( const SmallValueObject& ) {}
+ inline SmallValueObject& operator = ( const SmallValueObject& )
+ { return *this; }
+ inline ~SmallValueObject() {}
+}; // end class SmallValueObject
} // namespace Loki
diff --git a/shared/loki/SmartPtr.h b/shared/loki/SmartPtr.h
index df548553..fb14258e 100644
--- a/shared/loki/SmartPtr.h
+++ b/shared/loki/SmartPtr.h
@@ -67,78 +67,78 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
- template <class T>
- class HeapStorage
- {
- public:
- typedef T* StoredType; /// the type of the pointee_ object
- typedef T* InitPointerType; /// type used to declare OwnershipPolicy type.
- typedef T* PointerType; /// type returned by operator->
- typedef T& ReferenceType; /// type returned by operator*
+template <class T>
+class HeapStorage
+{
+public:
+ typedef T* StoredType; /// the type of the pointee_ object
+ typedef T* InitPointerType; /// type used to declare OwnershipPolicy type.
+ typedef T* PointerType; /// type returned by operator->
+ typedef T& ReferenceType; /// type returned by operator*
- HeapStorage() : pointee_(Default())
- {}
+ HeapStorage() : pointee_(Default())
+ {}
- // The storage policy doesn't initialize the stored pointer
- // which will be initialized by the OwnershipPolicy's Clone fn
- HeapStorage(const HeapStorage&) : pointee_(0)
- {}
+ // The storage policy doesn't initialize the stored pointer
+ // which will be initialized by the OwnershipPolicy's Clone fn
+ HeapStorage(const HeapStorage&) : pointee_(0)
+ {}
- template <class U>
- HeapStorage(const HeapStorage<U>&) : pointee_(0)
- {}
+ template <class U>
+ HeapStorage(const HeapStorage<U>&) : pointee_(0)
+ {}
- HeapStorage(const StoredType& p) : pointee_(p) {}
+ HeapStorage(const StoredType& p) : pointee_(p) {}
- PointerType operator->() const { return pointee_; }
+ PointerType operator->() const { return pointee_; }
- ReferenceType operator*() const { return *pointee_; }
+ ReferenceType operator*() const { return *pointee_; }
- void Swap(HeapStorage& rhs)
- { std::swap(pointee_, rhs.pointee_); }
+ void Swap(HeapStorage& rhs)
+ { std::swap(pointee_, rhs.pointee_); }
- // Accessors
- template <class F>
- friend typename HeapStorage<F>::PointerType GetImpl(const HeapStorage<F>& sp);
+ // Accessors
+ template <class F>
+ friend typename HeapStorage<F>::PointerType GetImpl(const HeapStorage<F>& sp);
- template <class F>
- friend const typename HeapStorage<F>::StoredType& GetImplRef(const HeapStorage<F>& sp);
+ template <class F>
+ friend const typename HeapStorage<F>::StoredType& GetImplRef(const HeapStorage<F>& sp);
- template <class F>
- friend typename HeapStorage<F>::StoredType& GetImplRef(HeapStorage<F>& sp);
+ template <class F>
+ friend typename HeapStorage<F>::StoredType& GetImplRef(HeapStorage<F>& sp);
- protected:
- // Destroys the data stored
- // (Destruction might be taken over by the OwnershipPolicy)
- void Destroy()
+protected:
+ // Destroys the data stored
+ // (Destruction might be taken over by the OwnershipPolicy)
+ void Destroy()
+ {
+ if ( 0 != pointee_ )
{
- if ( 0 != pointee_ )
- {
- pointee_->~T();
- ::free( pointee_ );
- }
+ pointee_->~T();
+ ::free( pointee_ );
}
+ }
- // Default value to initialize the pointer
- static StoredType Default()
- { return 0; }
+ // Default value to initialize the pointer
+ static StoredType Default()
+ { return 0; }
- private:
- // Data
- StoredType pointee_;
- };
+private:
+ // Data
+ StoredType pointee_;
+};
- template <class T>
- inline typename HeapStorage<T>::PointerType GetImpl(const HeapStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline typename HeapStorage<T>::PointerType GetImpl(const HeapStorage<T>& sp)
+{ return sp.pointee_; }
- template <class T>
- inline const typename HeapStorage<T>::StoredType& GetImplRef(const HeapStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline const typename HeapStorage<T>::StoredType& GetImplRef(const HeapStorage<T>& sp)
+{ return sp.pointee_; }
- template <class T>
- inline typename HeapStorage<T>::StoredType& GetImplRef(HeapStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline typename HeapStorage<T>::StoredType& GetImplRef(HeapStorage<T>& sp)
+{ return sp.pointee_; }
////////////////////////////////////////////////////////////////////////////////
@@ -149,77 +149,77 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
- template <class T>
- class DefaultSPStorage
- {
- public:
- typedef T* StoredType; // the type of the pointee_ object
- typedef T* InitPointerType; /// type used to declare OwnershipPolicy type.
- typedef T* PointerType; // type returned by operator->
- typedef T& ReferenceType; // type returned by operator*
+template <class T>
+class DefaultSPStorage
+{
+public:
+ typedef T* StoredType; // the type of the pointee_ object
+ typedef T* InitPointerType; /// type used to declare OwnershipPolicy type.
+ typedef T* PointerType; // type returned by operator->
+ typedef T& ReferenceType; // type returned by operator*
- DefaultSPStorage() : pointee_(Default())
- {}
+ DefaultSPStorage() : pointee_(Default())
+ {}
- // The storage policy doesn't initialize the stored pointer
- // which will be initialized by the OwnershipPolicy's Clone fn
- DefaultSPStorage(const DefaultSPStorage&) : pointee_(0)
- {}
+ // The storage policy doesn't initialize the stored pointer
+ // which will be initialized by the OwnershipPolicy's Clone fn
+ DefaultSPStorage(const DefaultSPStorage&) : pointee_(0)
+ {}
- template <class U>
- DefaultSPStorage(const DefaultSPStorage<U>&) : pointee_(0)
- {}
+ template <class U>
+ DefaultSPStorage(const DefaultSPStorage<U>&) : pointee_(0)
+ {}
- DefaultSPStorage(const StoredType& p) : pointee_(p) {}
+ DefaultSPStorage(const StoredType& p) : pointee_(p) {}
- PointerType operator->() const { return pointee_; }
+ PointerType operator->() const { return pointee_; }
- ReferenceType operator*() const { return *pointee_; }
+ ReferenceType operator*() const { return *pointee_; }
- void Swap(DefaultSPStorage& rhs)
- { std::swap(pointee_, rhs.pointee_); }
+ void Swap(DefaultSPStorage& rhs)
+ { std::swap(pointee_, rhs.pointee_); }
- // Accessors
- template <class F>
- friend typename DefaultSPStorage<F>::PointerType GetImpl(const DefaultSPStorage<F>& sp);
+ // Accessors
+ template <class F>
+ friend typename DefaultSPStorage<F>::PointerType GetImpl(const DefaultSPStorage<F>& sp);
- template <class F>
- friend const typename DefaultSPStorage<F>::StoredType& GetImplRef(const DefaultSPStorage<F>& sp);
+ template <class F>
+ friend const typename DefaultSPStorage<F>::StoredType& GetImplRef(const DefaultSPStorage<F>& sp);
- template <class F>
- friend typename DefaultSPStorage<F>::StoredType& GetImplRef(DefaultSPStorage<F>& sp);
+ template <class F>
+ friend typename DefaultSPStorage<F>::StoredType& GetImplRef(DefaultSPStorage<F>& sp);
- protected:
- // Destroys the data stored
- // (Destruction might be taken over by the OwnershipPolicy)
- //
- // If your compiler gives you a warning in this area while
- // compiling the tests, it is on purpose, please ignore it.
- void Destroy()
- {
- delete pointee_;
- }
+protected:
+ // Destroys the data stored
+ // (Destruction might be taken over by the OwnershipPolicy)
+ //
+ // If your compiler gives you a warning in this area while
+ // compiling the tests, it is on purpose, please ignore it.
+ void Destroy()
+ {
+ delete pointee_;
+ }
- // Default value to initialize the pointer
- static StoredType Default()
- { return 0; }
+ // Default value to initialize the pointer
+ static StoredType Default()
+ { return 0; }
- private:
- // Data
- StoredType pointee_;
- };
+private:
+ // Data
+ StoredType pointee_;
+};
- template <class T>
- inline typename DefaultSPStorage<T>::PointerType GetImpl(const DefaultSPStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline typename DefaultSPStorage<T>::PointerType GetImpl(const DefaultSPStorage<T>& sp)
+{ return sp.pointee_; }
- template <class T>
- inline const typename DefaultSPStorage<T>::StoredType& GetImplRef(const DefaultSPStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline const typename DefaultSPStorage<T>::StoredType& GetImplRef(const DefaultSPStorage<T>& sp)
+{ return sp.pointee_; }
- template <class T>
- inline typename DefaultSPStorage<T>::StoredType& GetImplRef(DefaultSPStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline typename DefaultSPStorage<T>::StoredType& GetImplRef(DefaultSPStorage<T>& sp)
+{ return sp.pointee_; }
////////////////////////////////////////////////////////////////////////////////
@@ -245,107 +245,107 @@ namespace Loki
/// LockedStorage which calls other functions to lock the object.
////////////////////////////////////////////////////////////////////////////////
- template <class T>
- class Locker
+template <class T>
+class Locker
+{
+public:
+ Locker( const T* p ) : pointee_( const_cast< T* >( p ) )
{
- public:
- Locker( const T * p ) : pointee_( const_cast< T * >( p ) )
- {
- if ( pointee_ != 0 )
- pointee_->Lock();
- }
+ if ( pointee_ != 0 )
+ pointee_->Lock();
+ }
- ~Locker( void )
- {
- if ( pointee_ != 0 )
- pointee_->Unlock();
- }
+ ~Locker( void )
+ {
+ if ( pointee_ != 0 )
+ pointee_->Unlock();
+ }
- operator T * ()
- {
- return pointee_;
- }
+ operator T* ()
+ {
+ return pointee_;
+ }
- T * operator->()
- {
- return pointee_;
- }
+ T* operator->()
+ {
+ return pointee_;
+ }
- private:
- Locker( void );
- Locker & operator = ( const Locker & );
- T * pointee_;
- };
+private:
+ Locker( void );
+ Locker& operator = ( const Locker& );
+ T* pointee_;
+};
- template <class T>
- class LockedStorage
- {
- public:
+template <class T>
+class LockedStorage
+{
+public:
- typedef T* StoredType; /// the type of the pointee_ object
- typedef T* InitPointerType; /// type used to declare OwnershipPolicy type.
- typedef Locker< T > PointerType; /// type returned by operator->
- typedef T& ReferenceType; /// type returned by operator*
+ typedef T* StoredType; /// the type of the pointee_ object
+ typedef T* InitPointerType; /// type used to declare OwnershipPolicy type.
+ typedef Locker< T > PointerType; /// type returned by operator->
+ typedef T& ReferenceType; /// type returned by operator*
- LockedStorage() : pointee_( Default() ) {}
+ LockedStorage() : pointee_( Default() ) {}
- ~LockedStorage( void ) {}
+ ~LockedStorage( void ) {}
- LockedStorage( const LockedStorage&) : pointee_( 0 ) {}
+ LockedStorage( const LockedStorage&) : pointee_( 0 ) {}
- LockedStorage( const StoredType & p ) : pointee_( p ) {}
+ LockedStorage( const StoredType& p ) : pointee_( p ) {}
- PointerType operator->()
- {
- return Locker< T >( pointee_ );
- }
+ PointerType operator->()
+ {
+ return Locker< T >( pointee_ );
+ }
- void Swap(LockedStorage& rhs)
- {
- std::swap( pointee_, rhs.pointee_ );
- }
+ void Swap(LockedStorage& rhs)
+ {
+ std::swap( pointee_, rhs.pointee_ );
+ }
- // Accessors
- template <class F>
- friend typename LockedStorage<F>::InitPointerType GetImpl(const LockedStorage<F>& sp);
+ // Accessors
+ template <class F>
+ friend typename LockedStorage<F>::InitPointerType GetImpl(const LockedStorage<F>& sp);
- template <class F>
- friend const typename LockedStorage<F>::StoredType& GetImplRef(const LockedStorage<F>& sp);
+ template <class F>
+ friend const typename LockedStorage<F>::StoredType& GetImplRef(const LockedStorage<F>& sp);
- template <class F>
- friend typename LockedStorage<F>::StoredType& GetImplRef(LockedStorage<F>& sp);
+ template <class F>
+ friend typename LockedStorage<F>::StoredType& GetImplRef(LockedStorage<F>& sp);
- protected:
- // Destroys the data stored
- // (Destruction might be taken over by the OwnershipPolicy)
- void Destroy()
- {
- delete pointee_;
- }
+protected:
+ // Destroys the data stored
+ // (Destruction might be taken over by the OwnershipPolicy)
+ void Destroy()
+ {
+ delete pointee_;
+ }
- // Default value to initialize the pointer
- static StoredType Default()
- { return 0; }
+ // Default value to initialize the pointer
+ static StoredType Default()
+ { return 0; }
- private:
- /// Dereference operator is not implemented.
- ReferenceType operator*();
+private:
+ /// Dereference operator is not implemented.
+ ReferenceType operator*();
- // Data
- StoredType pointee_;
- };
+ // Data
+ StoredType pointee_;
+};
- template <class T>
- inline typename LockedStorage<T>::InitPointerType GetImpl(const LockedStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline typename LockedStorage<T>::InitPointerType GetImpl(const LockedStorage<T>& sp)
+{ return sp.pointee_; }
- template <class T>
- inline const typename LockedStorage<T>::StoredType& GetImplRef(const LockedStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline const typename LockedStorage<T>::StoredType& GetImplRef(const LockedStorage<T>& sp)
+{ return sp.pointee_; }
- template <class T>
- inline typename LockedStorage<T>::StoredType& GetImplRef(LockedStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline typename LockedStorage<T>::StoredType& GetImplRef(LockedStorage<T>& sp)
+{ return sp.pointee_; }
////////////////////////////////////////////////////////////////////////////////
@@ -356,72 +356,72 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
- template <class T>
- class ArrayStorage
- {
- public:
- typedef T* StoredType; // the type of the pointee_ object
- typedef T* InitPointerType; /// type used to declare OwnershipPolicy type.
- typedef T* PointerType; // type returned by operator->
- typedef T& ReferenceType; // type returned by operator*
+template <class T>
+class ArrayStorage
+{
+public:
+ typedef T* StoredType; // the type of the pointee_ object
+ typedef T* InitPointerType; /// type used to declare OwnershipPolicy type.
+ typedef T* PointerType; // type returned by operator->
+ typedef T& ReferenceType; // type returned by operator*
- ArrayStorage() : pointee_(Default())
- {}
+ ArrayStorage() : pointee_(Default())
+ {}
- // The storage policy doesn't initialize the stored pointer
- // which will be initialized by the OwnershipPolicy's Clone fn
- ArrayStorage(const ArrayStorage&) : pointee_(0)
- {}
+ // The storage policy doesn't initialize the stored pointer
+ // which will be initialized by the OwnershipPolicy's Clone fn
+ ArrayStorage(const ArrayStorage&) : pointee_(0)
+ {}
- template <class U>
- ArrayStorage(const ArrayStorage<U>&) : pointee_(0)
- {}
+ template <class U>
+ ArrayStorage(const ArrayStorage<U>&) : pointee_(0)
+ {}
- ArrayStorage(const StoredType& p) : pointee_(p) {}
+ ArrayStorage(const StoredType& p) : pointee_(p) {}
- PointerType operator->() const { return pointee_; }
+ PointerType operator->() const { return pointee_; }
- ReferenceType operator*() const { return *pointee_; }
+ ReferenceType operator*() const { return *pointee_; }
- void Swap(ArrayStorage& rhs)
- { std::swap(pointee_, rhs.pointee_); }
+ void Swap(ArrayStorage& rhs)
+ { std::swap(pointee_, rhs.pointee_); }
- // Accessors
- template <class F>
- friend typename ArrayStorage<F>::PointerType GetImpl(const ArrayStorage<F>& sp);
+ // Accessors
+ template <class F>
+ friend typename ArrayStorage<F>::PointerType GetImpl(const ArrayStorage<F>& sp);
- template <class F>
- friend const typename ArrayStorage<F>::StoredType& GetImplRef(const ArrayStorage<F>& sp);
+ template <class F>
+ friend const typename ArrayStorage<F>::StoredType& GetImplRef(const ArrayStorage<F>& sp);
- template <class F>
- friend typename ArrayStorage<F>::StoredType& GetImplRef(ArrayStorage<F>& sp);
+ template <class F>
+ friend typename ArrayStorage<F>::StoredType& GetImplRef(ArrayStorage<F>& sp);
- protected:
- // Destroys the data stored
- // (Destruction might be taken over by the OwnershipPolicy)
- void Destroy()
- { delete [] pointee_; }
+protected:
+ // Destroys the data stored
+ // (Destruction might be taken over by the OwnershipPolicy)
+ void Destroy()
+ { delete [] pointee_; }
- // Default value to initialize the pointer
- static StoredType Default()
- { return 0; }
+ // Default value to initialize the pointer
+ static StoredType Default()
+ { return 0; }
- private:
- // Data
- StoredType pointee_;
- };
+private:
+ // Data
+ StoredType pointee_;
+};
- template <class T>
- inline typename ArrayStorage<T>::PointerType GetImpl(const ArrayStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline typename ArrayStorage<T>::PointerType GetImpl(const ArrayStorage<T>& sp)
+{ return sp.pointee_; }
- template <class T>
- inline const typename ArrayStorage<T>::StoredType& GetImplRef(const ArrayStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline const typename ArrayStorage<T>::StoredType& GetImplRef(const ArrayStorage<T>& sp)
+{ return sp.pointee_; }
- template <class T>
- inline typename ArrayStorage<T>::StoredType& GetImplRef(ArrayStorage<T>& sp)
- { return sp.pointee_; }
+template <class T>
+inline typename ArrayStorage<T>::StoredType& GetImplRef(ArrayStorage<T>& sp)
+{ return sp.pointee_; }
////////////////////////////////////////////////////////////////////////////////
@@ -432,54 +432,54 @@ namespace Loki
/// Provides a classic external reference counting implementation
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- class RefCounted
+template <class P>
+class RefCounted
+{
+public:
+ RefCounted()
+ : pCount_(static_cast<uintptr_t*>(
+ SmallObject<>::operator new(sizeof(uintptr_t))))
{
- public:
- RefCounted()
- : pCount_(static_cast<uintptr_t*>(
- SmallObject<>::operator new(sizeof(uintptr_t))))
- {
- assert(pCount_!=0);
- *pCount_ = 1;
- }
+ assert(pCount_!=0);
+ *pCount_ = 1;
+ }
- RefCounted(const RefCounted& rhs)
+ RefCounted(const RefCounted& rhs)
: pCount_(rhs.pCount_)
- {}
+ {}
- // MWCW lacks template friends, hence the following kludge
- template <typename P1>
- RefCounted(const RefCounted<P1>& rhs)
+ // MWCW lacks template friends, hence the following kludge
+ template <typename P1>
+ RefCounted(const RefCounted<P1>& rhs)
: pCount_(reinterpret_cast<const RefCounted&>(rhs).pCount_)
- {}
+ {}
- P Clone(const P& val)
- {
- ++*pCount_;
- return val;
- }
+ P Clone(const P& val)
+ {
+ ++*pCount_;
+ return val;
+ }
- bool Release(const P&)
+ bool Release(const P&)
+ {
+ if (!--*pCount_)
{
- if (!--*pCount_)
- {
- SmallObject<>::operator delete(pCount_, sizeof(uintptr_t));
- pCount_ = NULL;
- return true;
- }
- return false;
+ SmallObject<>::operator delete(pCount_, sizeof(uintptr_t));
+ pCount_ = NULL;
+ return true;
}
+ return false;
+ }
- void Swap(RefCounted& rhs)
- { std::swap(pCount_, rhs.pCount_); }
+ void Swap(RefCounted& rhs)
+ { std::swap(pCount_, rhs.pCount_); }
- enum { destructiveCopy = false };
+ enum { destructiveCopy = false };
- private:
- // Data
- uintptr_t* pCount_;
- };
+private:
+ // Data
+ uintptr_t* pCount_;
+};
////////////////////////////////////////////////////////////////////////////////
/// \struct RefCountedMT
@@ -500,68 +500,68 @@ namespace Loki
/// fixed at a higher design level, and no change to this class could fix it.
////////////////////////////////////////////////////////////////////////////////
- template <template <class, class> class ThreadingModel,
- class MX = LOKI_DEFAULT_MUTEX >
- struct RefCountedMTAdj
+template <template <class, class> class ThreadingModel,
+ class MX = LOKI_DEFAULT_MUTEX >
+struct RefCountedMTAdj
+{
+ template <class P>
+ class RefCountedMT : public ThreadingModel< RefCountedMT<P>, MX >
{
- template <class P>
- class RefCountedMT : public ThreadingModel< RefCountedMT<P>, MX >
- {
- typedef ThreadingModel< RefCountedMT<P>, MX > base_type;
- typedef typename base_type::IntType CountType;
- typedef volatile CountType *CountPtrType;
+ typedef ThreadingModel< RefCountedMT<P>, MX > base_type;
+ typedef typename base_type::IntType CountType;
+ typedef volatile CountType* CountPtrType;
- public:
- RefCountedMT()
- {
- pCount_ = static_cast<CountPtrType>(
- SmallObject<LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>::operator new(
- sizeof(*pCount_)));
- assert(pCount_);
- //*pCount_ = 1;
- ThreadingModel<RefCountedMT, MX>::AtomicAssign(*pCount_, 1);
- }
+ public:
+ RefCountedMT()
+ {
+ pCount_ = static_cast<CountPtrType>(
+ SmallObject<LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>::operator new(
+ sizeof(*pCount_)));
+ assert(pCount_);
+ //*pCount_ = 1;
+ ThreadingModel<RefCountedMT, MX>::AtomicAssign(*pCount_, 1);
+ }
- RefCountedMT(const RefCountedMT& rhs)
+ RefCountedMT(const RefCountedMT& rhs)
: pCount_(rhs.pCount_)
- {}
+ {}
- //MWCW lacks template friends, hence the following kludge
- template <typename P1>
- RefCountedMT(const RefCountedMT<P1>& rhs)
+ //MWCW lacks template friends, hence the following kludge
+ template <typename P1>
+ RefCountedMT(const RefCountedMT<P1>& rhs)
: pCount_(reinterpret_cast<const RefCountedMT<P>&>(rhs).pCount_)
- {}
+ {}
- P Clone(const P& val)
- {
- ThreadingModel<RefCountedMT, MX>::AtomicIncrement(*pCount_);
- return val;
- }
+ P Clone(const P& val)
+ {
+ ThreadingModel<RefCountedMT, MX>::AtomicIncrement(*pCount_);
+ return val;
+ }
- bool Release(const P&)
+ bool Release(const P&)
+ {
+ bool isZero = false;
+ ThreadingModel< RefCountedMT, MX >::AtomicDecrement( *pCount_, 0, isZero );
+ if ( isZero )
{
- bool isZero = false;
- ThreadingModel< RefCountedMT, MX >::AtomicDecrement( *pCount_, 0, isZero );
- if ( isZero )
- {
- SmallObject<LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>::operator delete(
- const_cast<CountType *>(pCount_),
- sizeof(*pCount_));
- return true;
- }
- return false;
+ SmallObject<LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL>::operator delete(
+ const_cast<CountType*>(pCount_),
+ sizeof(*pCount_));
+ return true;
}
+ return false;
+ }
- void Swap(RefCountedMT& rhs)
- { std::swap(pCount_, rhs.pCount_); }
+ void Swap(RefCountedMT& rhs)
+ { std::swap(pCount_, rhs.pCount_); }
- enum { destructiveCopy = false };
+ enum { destructiveCopy = false };
- private:
- // Data
- CountPtrType pCount_;
- };
+ private:
+ // Data
+ CountPtrType pCount_;
};
+};
////////////////////////////////////////////////////////////////////////////////
/// \class COMRefCounted
@@ -571,36 +571,36 @@ namespace Loki
/// Adapts COM intrusive reference counting to OwnershipPolicy-specific syntax
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- class COMRefCounted
- {
- public:
- COMRefCounted()
- {}
+template <class P>
+class COMRefCounted
+{
+public:
+ COMRefCounted()
+ {}
- template <class U>
- COMRefCounted(const COMRefCounted<U>&)
- {}
+ template <class U>
+ COMRefCounted(const COMRefCounted<U>&)
+ {}
- static P Clone(const P& val)
- {
- if(val!=0)
- val->AddRef();
- return val;
- }
+ static P Clone(const P& val)
+ {
+ if(val!=0)
+ val->AddRef();
+ return val;
+ }
- static bool Release(const P& val)
- {
- if(val!=0)
- val->Release();
- return false;
- }
+ static bool Release(const P& val)
+ {
+ if(val!=0)
+ val->Release();
+ return false;
+ }
- enum { destructiveCopy = false };
+ enum { destructiveCopy = false };
- static void Swap(COMRefCounted&)
- {}
- };
+ static void Swap(COMRefCounted&)
+ {}
+};
////////////////////////////////////////////////////////////////////////////////
/// \struct DeepCopy
@@ -611,27 +611,27 @@ namespace Loki
/// function of the pointee type
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- struct DeepCopy
- {
- DeepCopy()
- {}
+template <class P>
+struct DeepCopy
+{
+ DeepCopy()
+ {}
- template <class P1>
- DeepCopy(const DeepCopy<P1>&)
- {}
+ template <class P1>
+ DeepCopy(const DeepCopy<P1>&)
+ {}
- static P Clone(const P& val)
- { return val->Clone(); }
+ static P Clone(const P& val)
+ { return val->Clone(); }
- static bool Release(const P&)
- { return true; }
+ static bool Release(const P&)
+ { return true; }
- static void Swap(DeepCopy&)
- {}
+ static void Swap(DeepCopy&)
+ {}
- enum { destructiveCopy = false };
- };
+ enum { destructiveCopy = false };
+};
////////////////////////////////////////////////////////////////////////////////
/// \class RefLinked
@@ -641,59 +641,59 @@ namespace Loki
/// Implements reference linking
////////////////////////////////////////////////////////////////////////////////
- namespace Private
- {
- class LOKI_EXPORT RefLinkedBase
- {
- public:
- RefLinkedBase()
- { prev_ = next_ = this; }
+namespace Private
+{
+class LOKI_EXPORT RefLinkedBase
+{
+public:
+ RefLinkedBase()
+ { prev_ = next_ = this; }
- RefLinkedBase(const RefLinkedBase& rhs);
+ RefLinkedBase(const RefLinkedBase& rhs);
- bool Release();
+ bool Release();
- void Swap(RefLinkedBase& rhs);
+ void Swap(RefLinkedBase& rhs);
- bool Merge( RefLinkedBase & rhs );
+ bool Merge( RefLinkedBase& rhs );
- enum { destructiveCopy = false };
+ enum { destructiveCopy = false };
- private:
- static unsigned int CountPrevCycle( const RefLinkedBase * pThis );
- static unsigned int CountNextCycle( const RefLinkedBase * pThis );
- bool HasPrevNode( const RefLinkedBase * p ) const;
- bool HasNextNode( const RefLinkedBase * p ) const;
+private:
+ static unsigned int CountPrevCycle( const RefLinkedBase* pThis );
+ static unsigned int CountNextCycle( const RefLinkedBase* pThis );
+ bool HasPrevNode( const RefLinkedBase* p ) const;
+ bool HasNextNode( const RefLinkedBase* p ) const;
- mutable const RefLinkedBase* prev_;
- mutable const RefLinkedBase* next_;
- };
- }
+ mutable const RefLinkedBase* prev_;
+ mutable const RefLinkedBase* next_;
+};
+}
- template <class P>
- class RefLinked : public Private::RefLinkedBase
- {
- public:
- RefLinked()
- {}
+template <class P>
+class RefLinked : public Private::RefLinkedBase
+{
+public:
+ RefLinked()
+ {}
- template <class P1>
- RefLinked(const RefLinked<P1>& rhs)
+ template <class P1>
+ RefLinked(const RefLinked<P1>& rhs)
: Private::RefLinkedBase(rhs)
- {}
+ {}
- static P Clone(const P& val)
- { return val; }
+ static P Clone(const P& val)
+ { return val; }
- bool Release(const P&)
- { return Private::RefLinkedBase::Release(); }
+ bool Release(const P&)
+ { return Private::RefLinkedBase::Release(); }
- template < class P1 >
- bool Merge( RefLinked< P1 > & rhs )
- {
- return Private::RefLinkedBase::Merge( rhs );
- }
- };
+ template < class P1 >
+ bool Merge( RefLinked< P1 > & rhs )
+ {
+ return Private::RefLinkedBase::Merge( rhs );
+ }
+};
////////////////////////////////////////////////////////////////////////////////
/// \class DestructiveCopy
@@ -703,33 +703,33 @@ namespace Loki
/// Implements destructive copy semantics (a la std::auto_ptr)
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- class DestructiveCopy
- {
- public:
- DestructiveCopy()
- {}
+template <class P>
+class DestructiveCopy
+{
+public:
+ DestructiveCopy()
+ {}
- template <class P1>
- DestructiveCopy(const DestructiveCopy<P1>&)
- {}
+ template <class P1>
+ DestructiveCopy(const DestructiveCopy<P1>&)
+ {}
- template <class P1>
- static P Clone(P1& val)
- {
- P result(val);
- val = P1();
- return result;
- }
+ template <class P1>
+ static P Clone(P1& val)
+ {
+ P result(val);
+ val = P1();
+ return result;
+ }
- static bool Release(const P&)
- { return true; }
+ static bool Release(const P&)
+ { return true; }
- static void Swap(DestructiveCopy&)
- {}
+ static void Swap(DestructiveCopy&)
+ {}
- enum { destructiveCopy = true };
- };
+ enum { destructiveCopy = true };
+};
////////////////////////////////////////////////////////////////////////////////
/// \class NoCopy
@@ -739,33 +739,33 @@ namespace Loki
/// Implements a policy that doesn't allow copying objects
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- class NoCopy
- {
- public:
- NoCopy()
- {}
+template <class P>
+class NoCopy
+{
+public:
+ NoCopy()
+ {}
- template <class P1>
- NoCopy(const NoCopy<P1>&)
- {}
+ template <class P1>
+ NoCopy(const NoCopy<P1>&)
+ {}
- static P Clone(const P&)
- {
- // Make it depended on template parameter
- static const bool DependedFalse = sizeof(P*) == 0;
+ static P Clone(const P&)
+ {
+ // Make it depended on template parameter
+ static const bool DependedFalse = sizeof(P*) == 0;
- LOKI_STATIC_CHECK(DependedFalse, This_Policy_Disallows_Value_Copying);
- }
+ LOKI_STATIC_CHECK(DependedFalse, This_Policy_Disallows_Value_Copying);
+ }
- static bool Release(const P&)
- { return true; }
+ static bool Release(const P&)
+ { return true; }
- static void Swap(NoCopy&)
- {}
+ static void Swap(NoCopy&)
+ {}
- enum { destructiveCopy = false };
- };
+ enum { destructiveCopy = false };
+};
////////////////////////////////////////////////////////////////////////////////
/// \struct AllowConversion
@@ -775,13 +775,13 @@ namespace Loki
/// Allows implicit conversion from SmartPtr to the pointee type
////////////////////////////////////////////////////////////////////////////////
- struct AllowConversion
- {
- enum { allow = true };
+struct AllowConversion
+{
+ enum { allow = true };
- void Swap(AllowConversion&)
- {}
- };
+ void Swap(AllowConversion&)
+ {}
+};
////////////////////////////////////////////////////////////////////////////////
/// \struct DisallowConversion
@@ -792,19 +792,19 @@ namespace Loki
/// You can initialize a DisallowConversion with an AllowConversion
////////////////////////////////////////////////////////////////////////////////
- struct DisallowConversion
- {
- DisallowConversion()
- {}
+struct DisallowConversion
+{
+ DisallowConversion()
+ {}
- DisallowConversion(const AllowConversion&)
- {}
+ DisallowConversion(const AllowConversion&)
+ {}
- enum { allow = false };
+ enum { allow = false };
- void Swap(DisallowConversion&)
- {}
- };
+ void Swap(DisallowConversion&)
+ {}
+};
////////////////////////////////////////////////////////////////////////////////
/// \struct NoCheck
@@ -814,28 +814,28 @@ namespace Loki
/// Well, it's clear what it does :o)
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- struct NoCheck
- {
- NoCheck()
- {}
+template <class P>
+struct NoCheck
+{
+ NoCheck()
+ {}
- template <class P1>
- NoCheck(const NoCheck<P1>&)
- {}
+ template <class P1>
+ NoCheck(const NoCheck<P1>&)
+ {}
- static void OnDefault(const P&)
- {}
+ static void OnDefault(const P&)
+ {}
- static void OnInit(const P&)
- {}
+ static void OnInit(const P&)
+ {}
- static void OnDereference(const P&)
- {}
+ static void OnDereference(const P&)
+ {}
- static void Swap(NoCheck&)
- {}
- };
+ static void Swap(NoCheck&)
+ {}
+};
////////////////////////////////////////////////////////////////////////////////
@@ -846,32 +846,32 @@ namespace Loki
/// Checks the pointer before dereference
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- struct AssertCheck
- {
- AssertCheck()
- {}
+template <class P>
+struct AssertCheck
+{
+ AssertCheck()
+ {}
- template <class P1>
- AssertCheck(const AssertCheck<P1>&)
- {}
+ template <class P1>
+ AssertCheck(const AssertCheck<P1>&)
+ {}
- template <class P1>
- AssertCheck(const NoCheck<P1>&)
- {}
+ template <class P1>
+ AssertCheck(const NoCheck<P1>&)
+ {}
- static void OnDefault(const P&)
- {}
+ static void OnDefault(const P&)
+ {}
- static void OnInit(const P&)
- {}
+ static void OnInit(const P&)
+ {}
- static void OnDereference(P val)
- { assert(val); (void)val; }
+ static void OnDereference(P val)
+ { assert(val); (void)val; }
- static void Swap(AssertCheck&)
- {}
- };
+ static void Swap(AssertCheck&)
+ {}
+};
////////////////////////////////////////////////////////////////////////////////
/// \struct AssertCheckStrict
@@ -882,36 +882,36 @@ namespace Loki
/// You can initialize an AssertCheckStrict with an AssertCheck
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- struct AssertCheckStrict
- {
- AssertCheckStrict()
- {}
+template <class P>
+struct AssertCheckStrict
+{
+ AssertCheckStrict()
+ {}
- template <class U>
- AssertCheckStrict(const AssertCheckStrict<U>&)
- {}
+ template <class U>
+ AssertCheckStrict(const AssertCheckStrict<U>&)
+ {}
- template <class U>
- AssertCheckStrict(const AssertCheck<U>&)
- {}
+ template <class U>
+ AssertCheckStrict(const AssertCheck<U>&)
+ {}
- template <class P1>
- AssertCheckStrict(const NoCheck<P1>&)
- {}
+ template <class P1>
+ AssertCheckStrict(const NoCheck<P1>&)
+ {}
- static void OnDefault(P val)
- { assert(val); }
+ static void OnDefault(P val)
+ { assert(val); }
- static void OnInit(P val)
- { assert(val); }
+ static void OnInit(P val)
+ { assert(val); }
- static void OnDereference(P val)
- { assert(val); }
+ static void OnDereference(P val)
+ { assert(val); }
- static void Swap(AssertCheckStrict&)
- {}
- };
+ static void Swap(AssertCheckStrict&)
+ {}
+};
////////////////////////////////////////////////////////////////////////////////
/// \struct NullPointerException
@@ -920,13 +920,13 @@ namespace Loki
/// Used by some implementations of the CheckingPolicy used by SmartPtr
////////////////////////////////////////////////////////////////////////////////
- struct NullPointerException : public std::runtime_error
- {
- NullPointerException() : std::runtime_error(std::string(""))
- { }
- const char* what() const throw()
- { return "Null Pointer Exception"; }
- };
+struct NullPointerException : public std::runtime_error
+{
+ NullPointerException() : std::runtime_error(std::string(""))
+ { }
+ const char* what() const throw()
+ { return "Null Pointer Exception"; }
+};
////////////////////////////////////////////////////////////////////////////////
/// \struct RejectNullStatic
@@ -936,45 +936,45 @@ namespace Loki
/// Checks the pointer upon initialization and before dereference
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- struct RejectNullStatic
- {
- RejectNullStatic()
- {}
+template <class P>
+struct RejectNullStatic
+{
+ RejectNullStatic()
+ {}
- template <class P1>
- RejectNullStatic(const RejectNullStatic<P1>&)
- {}
+ template <class P1>
+ RejectNullStatic(const RejectNullStatic<P1>&)
+ {}
- template <class P1>
- RejectNullStatic(const NoCheck<P1>&)
- {}
+ template <class P1>
+ RejectNullStatic(const NoCheck<P1>&)
+ {}
- template <class P1>
- RejectNullStatic(const AssertCheck<P1>&)
- {}
+ template <class P1>
+ RejectNullStatic(const AssertCheck<P1>&)
+ {}
- template <class P1>
- RejectNullStatic(const AssertCheckStrict<P1>&)
- {}
+ template <class P1>
+ RejectNullStatic(const AssertCheckStrict<P1>&)
+ {}
- static void OnDefault(const P&)
- {
- // Make it depended on template parameter
- static const bool DependedFalse = sizeof(P*) == 0;
+ static void OnDefault(const P&)
+ {
+ // Make it depended on template parameter
+ static const bool DependedFalse = sizeof(P*) == 0;
- LOKI_STATIC_CHECK(DependedFalse, ERROR_This_Policy_Does_Not_Allow_Default_Initialization);
- }
+ LOKI_STATIC_CHECK(DependedFalse, ERROR_This_Policy_Does_Not_Allow_Default_Initialization);
+ }
- static void OnInit(const P& val)
- { if (!val) throw NullPointerException(); }
+ static void OnInit(const P& val)
+ { if (!val) throw NullPointerException(); }
- static void OnDereference(const P& val)
- { if (!val) throw NullPointerException(); }
+ static void OnDereference(const P& val)
+ { if (!val) throw NullPointerException(); }
- static void Swap(RejectNullStatic&)
- {}
- };
+ static void Swap(RejectNullStatic&)
+ {}
+};
////////////////////////////////////////////////////////////////////////////////
/// \struct RejectNull
@@ -984,31 +984,31 @@ namespace Loki
/// Checks the pointer before dereference
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- struct RejectNull
- {
- RejectNull()
- {}
+template <class P>
+struct RejectNull
+{
+ RejectNull()
+ {}
- template <class P1>
- RejectNull(const RejectNull<P1>&)
- {}
+ template <class P1>
+ RejectNull(const RejectNull<P1>&)
+ {}
- static void OnInit(P)
- {}
+ static void OnInit(P)
+ {}
- static void OnDefault(P)
- {}
+ static void OnDefault(P)
+ {}
- void OnDereference(P val)
- { if (!val) throw NullPointerException(); }
+ void OnDereference(P val)
+ { if (!val) throw NullPointerException(); }
- void OnDereference(P val) const
- { if (!val) throw NullPointerException(); }
+ void OnDereference(P val) const
+ { if (!val) throw NullPointerException(); }
- void Swap(RejectNull&)
- {}
- };
+ void Swap(RejectNull&)
+ {}
+};
////////////////////////////////////////////////////////////////////////////////
/// \struct RejectNullStrict
@@ -1018,32 +1018,32 @@ namespace Loki
/// Checks the pointer upon initialization and before dereference
////////////////////////////////////////////////////////////////////////////////
- template <class P>
- struct RejectNullStrict
- {
- RejectNullStrict()
- {}
+template <class P>
+struct RejectNullStrict
+{
+ RejectNullStrict()
+ {}
- template <class P1>
- RejectNullStrict(const RejectNullStrict<P1>&)
- {}
+ template <class P1>
+ RejectNullStrict(const RejectNullStrict<P1>&)
+ {}
- template <class P1>
- RejectNullStrict(const RejectNull<P1>&)
- {}
+ template <class P1>
+ RejectNullStrict(const RejectNull<P1>&)
+ {}
- static void OnInit(P val)
- { if (!val) throw NullPointerException(); }
+ static void OnInit(P val)
+ { if (!val) throw NullPointerException(); }
- void OnDereference(P val)
- { OnInit(val); }
+ void OnDereference(P val)
+ { OnInit(val); }
- void OnDereference(P val) const
- { OnInit(val); }
+ void OnDereference(P val) const
+ { OnInit(val); }
- void Swap(RejectNullStrict&)
- {}
- };
+ void Swap(RejectNullStrict&)
+ {}
+};
////////////////////////////////////////////////////////////////////////////////
@@ -1051,16 +1051,16 @@ namespace Loki
// The reason for all the fuss above
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OwnershipPolicy = RefCounted,
- class ConversionPolicy = DisallowConversion,
- template <class> class CheckingPolicy = AssertCheck,
- template <class> class StoragePolicy = DefaultSPStorage,
- template<class> class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
- >
- class SmartPtr;
+template
+<
+typename T,
+ template <class> class OwnershipPolicy = RefCounted,
+ class ConversionPolicy = DisallowConversion,
+ template <class> class CheckingPolicy = AssertCheck,
+ template <class> class StoragePolicy = DefaultSPStorage,
+ template<class> class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
+ >
+class SmartPtr;
////////////////////////////////////////////////////////////////////////////////
// class template SmartPtrDef (definition)
@@ -1068,28 +1068,28 @@ namespace Loki
// instead of writing SmartPtr<T,OP,CP,KP,SP> write SmartPtrDef<T,OP,CP,KP,SP>::type
////////////////////////////////////////////////////////////////////////////////
- template
+template
+<
+typename T,
+ template <class> class OwnershipPolicy = RefCounted,
+ class ConversionPolicy = DisallowConversion,
+ template <class> class CheckingPolicy = AssertCheck,
+ template <class> class StoragePolicy = DefaultSPStorage,
+ template<class> class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
+ >
+struct SmartPtrDef
+{
+ typedef SmartPtr
<
- typename T,
- template <class> class OwnershipPolicy = RefCounted,
- class ConversionPolicy = DisallowConversion,
- template <class> class CheckingPolicy = AssertCheck,
- template <class> class StoragePolicy = DefaultSPStorage,
- template<class> class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
+ T,
+ OwnershipPolicy,
+ ConversionPolicy,
+ CheckingPolicy,
+ StoragePolicy,
+ ConstnessPolicy
>
- struct SmartPtrDef
- {
- typedef SmartPtr
- <
- T,
- OwnershipPolicy,
- ConversionPolicy,
- CheckingPolicy,
- StoragePolicy,
- ConstnessPolicy
- >
- type;
- };
+ type;
+};
////////////////////////////////////////////////////////////////////////////////
/// \class SmartPtr
@@ -1110,368 +1110,368 @@ namespace Loki
/// - IsUnique() was removed
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OwnershipPolicy,
- class ConversionPolicy,
- template <class> class CheckingPolicy,
- template <class> class StoragePolicy,
- template <class> class ConstnessPolicy
- >
- class SmartPtr
- : public StoragePolicy<T>
- , public OwnershipPolicy<typename StoragePolicy<T>::InitPointerType>
- , public CheckingPolicy<typename StoragePolicy<T>::StoredType>
- , public ConversionPolicy
- {
- typedef StoragePolicy<T> SP;
- typedef OwnershipPolicy<typename StoragePolicy<T>::InitPointerType> OP;
- typedef CheckingPolicy<typename StoragePolicy<T>::StoredType> KP;
- typedef ConversionPolicy CP;
+template
+<
+typename T,
+ template <class> class OwnershipPolicy,
+ class ConversionPolicy,
+ template <class> class CheckingPolicy,
+ template <class> class StoragePolicy,
+ template <class> class ConstnessPolicy
+ >
+class SmartPtr
+ : public StoragePolicy<T>
+ , public OwnershipPolicy<typename StoragePolicy<T>::InitPointerType>
+ , public CheckingPolicy<typename StoragePolicy<T>::StoredType>
+ , public ConversionPolicy
+{
+ typedef StoragePolicy<T> SP;
+ typedef OwnershipPolicy<typename StoragePolicy<T>::InitPointerType> OP;
+ typedef CheckingPolicy<typename StoragePolicy<T>::StoredType> KP;
+ typedef ConversionPolicy CP;
- public:
- typedef typename ConstnessPolicy<T>::Type* ConstPointerType;
- typedef typename ConstnessPolicy<T>::Type& ConstReferenceType;
+public:
+ typedef typename ConstnessPolicy<T>::Type* ConstPointerType;
+ typedef typename ConstnessPolicy<T>::Type& ConstReferenceType;
- typedef typename SP::PointerType PointerType;
- typedef typename SP::StoredType StoredType;
- typedef typename SP::ReferenceType ReferenceType;
+ typedef typename SP::PointerType PointerType;
+ typedef typename SP::StoredType StoredType;
+ typedef typename SP::ReferenceType ReferenceType;
- typedef typename Select<OP::destructiveCopy,SmartPtr, const SmartPtr>::Result
- CopyArg;
+ typedef typename Select<OP::destructiveCopy,SmartPtr, const SmartPtr>::Result
+ CopyArg;
- private:
- struct NeverMatched {};
+private:
+ struct NeverMatched {};
#ifdef LOKI_SMARTPTR_CONVERSION_CONSTRUCTOR_POLICY
- typedef typename Select< CP::allow, const StoredType&, NeverMatched>::Result ImplicitArg;
- typedef typename Select<!CP::allow, const StoredType&, NeverMatched>::Result ExplicitArg;
+ typedef typename Select< CP::allow, const StoredType&, NeverMatched>::Result ImplicitArg;
+ typedef typename Select<!CP::allow, const StoredType&, NeverMatched>::Result ExplicitArg;
#else
- typedef const StoredType& ImplicitArg;
- typedef typename Select<false, const StoredType&, NeverMatched>::Result ExplicitArg;
+ typedef const StoredType& ImplicitArg;
+ typedef typename Select<false, const StoredType&, NeverMatched>::Result ExplicitArg;
#endif
- public:
+public:
- SmartPtr()
- {
- KP::OnDefault(GetImpl(*this));
- }
+ SmartPtr()
+ {
+ KP::OnDefault(GetImpl(*this));
+ }
- explicit
- SmartPtr(ExplicitArg p) : SP(p)
- {
- KP::OnInit(GetImpl(*this));
- }
+ explicit
+ SmartPtr(ExplicitArg p) : SP(p)
+ {
+ KP::OnInit(GetImpl(*this));
+ }
- SmartPtr(ImplicitArg p) : SP(p)
- {
- KP::OnInit(GetImpl(*this));
- }
+ SmartPtr(ImplicitArg p) : SP(p)
+ {
+ KP::OnInit(GetImpl(*this));
+ }
- SmartPtr(CopyArg& rhs) : SP(rhs), OP(rhs), KP(rhs), CP(rhs)
- {
- GetImplRef(*this) = OP::Clone(GetImplRef(rhs));
- }
+ SmartPtr(CopyArg& rhs) : SP(rhs), OP(rhs), KP(rhs), CP(rhs)
+ {
+ GetImplRef(*this) = OP::Clone(GetImplRef(rhs));
+ }
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- SmartPtr(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs)
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ SmartPtr(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs)
: SP(rhs), OP(rhs), KP(rhs), CP(rhs)
- { GetImplRef(*this) = OP::Clone(GetImplRef(rhs)); }
-
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- SmartPtr(SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs)
+ { GetImplRef(*this) = OP::Clone(GetImplRef(rhs)); }
+
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ SmartPtr(SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs)
: SP(rhs), OP(rhs), KP(rhs), CP(rhs)
- {
- GetImplRef(*this) = OP::Clone(GetImplRef(rhs));
- }
+ {
+ GetImplRef(*this) = OP::Clone(GetImplRef(rhs));
+ }
- SmartPtr(RefToValue<SmartPtr> rhs)
+ SmartPtr(RefToValue<SmartPtr> rhs)
: SP(rhs), OP(rhs), KP(rhs), CP(rhs)
- {}
+ {}
- operator RefToValue<SmartPtr>()
- { return RefToValue<SmartPtr>(*this); }
+ operator RefToValue<SmartPtr>()
+ { return RefToValue<SmartPtr>(*this); }
- SmartPtr& operator=(CopyArg& rhs)
- {
- SmartPtr temp(rhs);
- temp.Swap(*this);
- return *this;
- }
+ SmartPtr& operator=(CopyArg& rhs)
+ {
+ SmartPtr temp(rhs);
+ temp.Swap(*this);
+ return *this;
+ }
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- SmartPtr& operator=(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs)
- {
- SmartPtr temp(rhs);
- temp.Swap(*this);
- return *this;
- }
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ SmartPtr& operator=(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs)
+ {
+ SmartPtr temp(rhs);
+ temp.Swap(*this);
+ return *this;
+ }
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- SmartPtr& operator=(SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs)
- {
- SmartPtr temp(rhs);
- temp.Swap(*this);
- return *this;
- }
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ SmartPtr& operator=(SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs)
+ {
+ SmartPtr temp(rhs);
+ temp.Swap(*this);
+ return *this;
+ }
- void Swap(SmartPtr& rhs)
- {
- OP::Swap(rhs);
- CP::Swap(rhs);
- KP::Swap(rhs);
- SP::Swap(rhs);
- }
+ void Swap(SmartPtr& rhs)
+ {
+ OP::Swap(rhs);
+ CP::Swap(rhs);
+ KP::Swap(rhs);
+ SP::Swap(rhs);
+ }
- ~SmartPtr()
+ ~SmartPtr()
+ {
+ if (OP::Release(GetImpl(*static_cast<SP*>(this))))
{
- if (OP::Release(GetImpl(*static_cast<SP*>(this))))
- {
- SP::Destroy();
- }
+ SP::Destroy();
}
+ }
#ifdef LOKI_ENABLE_FRIEND_TEMPLATE_TEMPLATE_PARAMETER_WORKAROUND
- // old non standard in class definition of friends
- friend inline void Release(SmartPtr& sp, typename SP::StoredType& p)
- {
- p = GetImplRef(sp);
- GetImplRef(sp) = SP::Default();
- }
+ // old non standard in class definition of friends
+ friend inline void Release(SmartPtr& sp, typename SP::StoredType& p)
+ {
+ p = GetImplRef(sp);
+ GetImplRef(sp) = SP::Default();
+ }
- friend inline void Reset(SmartPtr& sp, typename SP::StoredType p)
- { SmartPtr(p).Swap(sp); }
+ friend inline void Reset(SmartPtr& sp, typename SP::StoredType p)
+ { SmartPtr(p).Swap(sp); }
#else
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- friend void Release(SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1>& sp,
- typename SP1<T1>::StoredType& p);
-
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- friend void Reset(SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1>& sp,
- typename SP1<T1>::StoredType p);
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ friend void Release(SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1>& sp,
+ typename SP1<T1>::StoredType& p);
+
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ friend void Reset(SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1>& sp,
+ typename SP1<T1>::StoredType p);
#endif
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- bool Merge( SmartPtr< T1, OP1, CP1, KP1, SP1, CNP1 > & rhs )
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ bool Merge( SmartPtr< T1, OP1, CP1, KP1, SP1, CNP1 > & rhs )
+ {
+ if ( GetImpl( *this ) != GetImpl( rhs ) )
{
- if ( GetImpl( *this ) != GetImpl( rhs ) )
- {
- return false;
- }
- return OP::template Merge( rhs );
+ return false;
}
+ return OP::template Merge( rhs );
+ }
- PointerType operator->()
- {
- KP::OnDereference(GetImplRef(*this));
- return SP::operator->();
- }
+ PointerType operator->()
+ {
+ KP::OnDereference(GetImplRef(*this));
+ return SP::operator->();
+ }
- ConstPointerType operator->() const
- {
- KP::OnDereference(GetImplRef(*this));
- return SP::operator->();
- }
+ ConstPointerType operator->() const
+ {
+ KP::OnDereference(GetImplRef(*this));
+ return SP::operator->();
+ }
- ReferenceType operator*()
- {
- KP::OnDereference(GetImplRef(*this));
- return SP::operator*();
- }
+ ReferenceType operator*()
+ {
+ KP::OnDereference(GetImplRef(*this));
+ return SP::operator*();
+ }
- ConstReferenceType operator*() const
- {
- KP::OnDereference(GetImplRef(*this));
- return SP::operator*();
- }
+ ConstReferenceType operator*() const
+ {
+ KP::OnDereference(GetImplRef(*this));
+ return SP::operator*();
+ }
- bool operator!() const // Enables "if (!sp) ..."
- { return GetImpl(*this) == 0; }
-
- static inline T * GetPointer( const SmartPtr & sp )
- { return GetImpl( sp ); }
-
- // Ambiguity buster
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- bool operator==(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs) const
- { return GetImpl(*this) == GetImpl(rhs); }
-
- // Ambiguity buster
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- bool operator!=(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs) const
- { return !(*this == rhs); }
-
- // Ambiguity buster
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- bool operator<(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs) const
- { return GetImpl(*this) < GetImpl(rhs); }
-
- // Ambiguity buster
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- inline bool operator > ( const SmartPtr< T1, OP1, CP1, KP1, SP1, CNP1 > & rhs )
- {
- return ( GetImpl( rhs ) < GetImpl( *this ) );
- }
+ bool operator!() const // Enables "if (!sp) ..."
+ { return GetImpl(*this) == 0; }
- // Ambiguity buster
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- inline bool operator <= ( const SmartPtr< T1, OP1, CP1, KP1, SP1, CNP1 > & rhs )
- {
- return !( GetImpl( rhs ) < GetImpl( *this ) );
- }
+ static inline T* GetPointer( const SmartPtr& sp )
+ { return GetImpl( sp ); }
- // Ambiguity buster
- template
- <
- typename T1,
- template <class> class OP1,
- class CP1,
- template <class> class KP1,
- template <class> class SP1,
- template <class> class CNP1
- >
- inline bool operator >= ( const SmartPtr< T1, OP1, CP1, KP1, SP1, CNP1 > & rhs )
- {
- return !( GetImpl( *this ) < GetImpl( rhs ) );
- }
+ // Ambiguity buster
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ bool operator==(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs) const
+ { return GetImpl(*this) == GetImpl(rhs); }
+
+ // Ambiguity buster
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ bool operator!=(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs) const
+ { return !(*this == rhs); }
+
+ // Ambiguity buster
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ bool operator<(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1 >& rhs) const
+ { return GetImpl(*this) < GetImpl(rhs); }
+
+ // Ambiguity buster
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ inline bool operator > ( const SmartPtr< T1, OP1, CP1, KP1, SP1, CNP1 > & rhs )
+ {
+ return ( GetImpl( rhs ) < GetImpl( *this ) );
+ }
- private:
- // Helper for enabling 'if (sp)'
- struct Tester
- {
- Tester(int) {}
- void dummy() {}
- };
+ // Ambiguity buster
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ inline bool operator <= ( const SmartPtr< T1, OP1, CP1, KP1, SP1, CNP1 > & rhs )
+ {
+ return !( GetImpl( rhs ) < GetImpl( *this ) );
+ }
- typedef void (Tester::*unspecified_boolean_type_)();
+ // Ambiguity buster
+ template
+ <
+ typename T1,
+ template <class> class OP1,
+ class CP1,
+ template <class> class KP1,
+ template <class> class SP1,
+ template <class> class CNP1
+ >
+ inline bool operator >= ( const SmartPtr< T1, OP1, CP1, KP1, SP1, CNP1 > & rhs )
+ {
+ return !( GetImpl( *this ) < GetImpl( rhs ) );
+ }
- typedef typename Select<CP::allow, Tester, unspecified_boolean_type_>::Result
- unspecified_boolean_type;
+private:
+ // Helper for enabling 'if (sp)'
+ struct Tester
+ {
+ Tester(int) {}
+ void dummy() {}
+ };
- public:
- // enable 'if (sp)'
- operator unspecified_boolean_type() const
- {
- return !*this ? 0 : &Tester::dummy;
- }
+ typedef void (Tester::*unspecified_boolean_type_)();
- private:
- // Helper for disallowing automatic conversion
- struct Insipid
- {
- Insipid(PointerType) {}
- };
+ typedef typename Select<CP::allow, Tester, unspecified_boolean_type_>::Result
+ unspecified_boolean_type;
- typedef typename Select<CP::allow, PointerType, Insipid>::Result
- AutomaticConversionResult;
+public:
+ // enable 'if (sp)'
+ operator unspecified_boolean_type() const
+ {
+ return !*this ? 0 : &Tester::dummy;
+ }
- public:
- operator AutomaticConversionResult() const
- { return GetImpl(*this); }
+private:
+ // Helper for disallowing automatic conversion
+ struct Insipid
+ {
+ Insipid(PointerType) {}
};
+ typedef typename Select<CP::allow, PointerType, Insipid>::Result
+ AutomaticConversionResult;
+
+public:
+ operator AutomaticConversionResult() const
+ { return GetImpl(*this); }
+};
+
////////////////////////////////////////////////////////////////////////////////
// friends
@@ -1479,34 +1479,34 @@ namespace Loki
#ifndef LOKI_ENABLE_FRIEND_TEMPLATE_TEMPLATE_PARAMETER_WORKAROUND
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP
- >
- inline void Release(SmartPtr<T, OP, CP, KP, SP, CNP>& sp,
- typename SP<T>::StoredType& p)
- {
- p = GetImplRef(sp);
- GetImplRef(sp) = SP<T>::Default();
- }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP
+ >
+inline void Release(SmartPtr<T, OP, CP, KP, SP, CNP>& sp,
+ typename SP<T>::StoredType& p)
+{
+ p = GetImplRef(sp);
+ GetImplRef(sp) = SP<T>::Default();
+}
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP
- >
- inline void Reset(SmartPtr<T, OP, CP, KP, SP, CNP>& sp,
- typename SP<T>::StoredType p)
- { SmartPtr<T, OP, CP, KP, SP, CNP>(p).Swap(sp); }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP
+ >
+inline void Reset(SmartPtr<T, OP, CP, KP, SP, CNP>& sp,
+ typename SP<T>::StoredType p)
+{ SmartPtr<T, OP, CP, KP, SP, CNP>(p).Swap(sp); }
#endif
@@ -1519,232 +1519,232 @@ namespace Loki
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP1,
- typename U
- >
- inline bool operator==(const SmartPtr<T, OP, CP, KP, SP, CNP1 >& lhs,
- U* rhs)
- { return GetImpl(lhs) == rhs; }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP1,
+ typename U
+ >
+inline bool operator==(const SmartPtr<T, OP, CP, KP, SP, CNP1 >& lhs,
+ U* rhs)
+{ return GetImpl(lhs) == rhs; }
////////////////////////////////////////////////////////////////////////////////
/// operator== for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP1,
- typename U
- >
- inline bool operator==(U* lhs,
- const SmartPtr<T, OP, CP, KP, SP, CNP1 >& rhs)
- { return rhs == lhs; }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP1,
+ typename U
+ >
+inline bool operator==(U* lhs,
+ const SmartPtr<T, OP, CP, KP, SP, CNP1 >& rhs)
+{ return rhs == lhs; }
////////////////////////////////////////////////////////////////////////////////
/// operator!= for lhs = SmartPtr, rhs = raw pointer
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP,
- typename U
- >
- inline bool operator!=(const SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
- U* rhs)
- { return !(lhs == rhs); }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP,
+ typename U
+ >
+inline bool operator!=(const SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
+ U* rhs)
+{ return !(lhs == rhs); }
////////////////////////////////////////////////////////////////////////////////
/// operator!= for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP,
- typename U
- >
- inline bool operator!=(U* lhs,
- const SmartPtr<T, OP, CP, KP, SP, CNP >& rhs)
- { return rhs != lhs; }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP,
+ typename U
+ >
+inline bool operator!=(U* lhs,
+ const SmartPtr<T, OP, CP, KP, SP, CNP >& rhs)
+{ return rhs != lhs; }
////////////////////////////////////////////////////////////////////////////////
/// operator< for lhs = SmartPtr, rhs = raw pointer
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP,
- typename U
- >
- inline bool operator<(const SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
- U* rhs)
- {
- return ( GetImpl( lhs ) < rhs );
- }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP,
+ typename U
+ >
+inline bool operator<(const SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
+ U* rhs)
+{
+ return ( GetImpl( lhs ) < rhs );
+}
////////////////////////////////////////////////////////////////////////////////
/// operator< for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP,
- typename U
- >
- inline bool operator<(U* lhs,
- const SmartPtr<T, OP, CP, KP, SP, CNP >& rhs)
- {
- return ( GetImpl( rhs ) < lhs );
- }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP,
+ typename U
+ >
+inline bool operator<(U* lhs,
+ const SmartPtr<T, OP, CP, KP, SP, CNP >& rhs)
+{
+ return ( GetImpl( rhs ) < lhs );
+}
////////////////////////////////////////////////////////////////////////////////
// operator> for lhs = SmartPtr, rhs = raw pointer
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP,
- typename U
- >
- inline bool operator>(const SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
- U* rhs)
- { return rhs < lhs; }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP,
+ typename U
+ >
+inline bool operator>(const SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
+ U* rhs)
+{ return rhs < lhs; }
////////////////////////////////////////////////////////////////////////////////
/// operator> for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP,
- typename U
- >
- inline bool operator>(U* lhs,
- const SmartPtr<T, OP, CP, KP, SP, CNP >& rhs)
- { return rhs < lhs; }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP,
+ typename U
+ >
+inline bool operator>(U* lhs,
+ const SmartPtr<T, OP, CP, KP, SP, CNP >& rhs)
+{ return rhs < lhs; }
////////////////////////////////////////////////////////////////////////////////
/// operator<= for lhs = SmartPtr, rhs = raw pointer
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP,
- typename U
- >
- inline bool operator<=(const SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
- U* rhs)
- { return !(rhs < lhs); }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP,
+ typename U
+ >
+inline bool operator<=(const SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
+ U* rhs)
+{ return !(rhs < lhs); }
////////////////////////////////////////////////////////////////////////////////
/// operator<= for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP,
- typename U
- >
- inline bool operator<=(U* lhs,
- const SmartPtr<T, OP, CP, KP, SP, CNP >& rhs)
- { return !(rhs < lhs); }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP,
+ typename U
+ >
+inline bool operator<=(U* lhs,
+ const SmartPtr<T, OP, CP, KP, SP, CNP >& rhs)
+{ return !(rhs < lhs); }
////////////////////////////////////////////////////////////////////////////////
/// operator>= for lhs = SmartPtr, rhs = raw pointer
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP,
- typename U
- >
- inline bool operator>=(const SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
- U* rhs)
- { return !(lhs < rhs); }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP,
+ typename U
+ >
+inline bool operator>=(const SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
+ U* rhs)
+{ return !(lhs < rhs); }
////////////////////////////////////////////////////////////////////////////////
/// operator>= for lhs = raw pointer, rhs = SmartPtr
/// \ingroup SmartPointerGroup
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP,
- typename U
- >
- inline bool operator>=(U* lhs,
- const SmartPtr<T, OP, CP, KP, SP, CNP >& rhs)
- { return !(lhs < rhs); }
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP,
+ typename U
+ >
+inline bool operator>=(U* lhs,
+ const SmartPtr<T, OP, CP, KP, SP, CNP >& rhs)
+{ return !(lhs < rhs); }
} // namespace Loki
@@ -1755,23 +1755,23 @@ namespace Loki
namespace std
{
- template
- <
- typename T,
- template <class> class OP,
- class CP,
- template <class> class KP,
- template <class> class SP,
- template <class> class CNP
- >
- struct less< Loki::SmartPtr<T, OP, CP, KP, SP, CNP > >
+template
+<
+typename T,
+ template <class> class OP,
+ class CP,
+ template <class> class KP,
+ template <class> class SP,
+ template <class> class CNP
+ >
+struct less< Loki::SmartPtr<T, OP, CP, KP, SP, CNP > >
: public binary_function<Loki::SmartPtr<T, OP, CP, KP, SP, CNP >,
- Loki::SmartPtr<T, OP, CP, KP, SP, CNP >, bool>
- {
- bool operator()(const Loki::SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
- const Loki::SmartPtr<T, OP, CP, KP, SP, CNP >& rhs) const
- { return less<T*>()(GetImpl(lhs), GetImpl(rhs)); }
- };
+ Loki::SmartPtr<T, OP, CP, KP, SP, CNP >, bool>
+{
+ bool operator()(const Loki::SmartPtr<T, OP, CP, KP, SP, CNP >& lhs,
+ const Loki::SmartPtr<T, OP, CP, KP, SP, CNP >& rhs) const
+ { return less<T*>()(GetImpl(lhs), GetImpl(rhs)); }
+};
}
#endif // end file guardian
diff --git a/shared/loki/StrongPtr.h b/shared/loki/StrongPtr.h
index 7ec9766f..23d70415 100644
--- a/shared/loki/StrongPtr.h
+++ b/shared/loki/StrongPtr.h
@@ -19,7 +19,7 @@
#include <loki/SmartPtr.h>
#if defined (LOKI_OBJECT_LEVEL_THREADING) || defined (LOKI_CLASS_LEVEL_THREADING)
- #include <loki/Threads.h>
+#include <loki/Threads.h>
#endif
@@ -127,7 +127,7 @@ template < class P >
class DeleteUsingFree
{
public:
- inline void static Delete( const P * p )
+ inline void static Delete( const P* p )
{
if ( 0 != p )
{
@@ -137,12 +137,12 @@ public:
}
/// Provides default value to initialize the pointer
- inline static P * Default( void )
+ inline static P* Default( void )
{
return 0;
}
- inline void Swap( DeleteUsingFree & ) {}
+ inline void Swap( DeleteUsingFree& ) {}
};
////////////////////////////////////////////////////////////////////////////////
@@ -158,17 +158,17 @@ template < class P >
class DeleteNothing
{
public:
- inline static void Delete( const P * )
+ inline static void Delete( const P* )
{
// Do nothing at all!
}
- inline static P * Default( void )
+ inline static P* Default( void )
{
return 0;
}
- inline void Swap( DeleteNothing & ) {}
+ inline void Swap( DeleteNothing& ) {}
};
////////////////////////////////////////////////////////////////////////////////
@@ -183,7 +183,7 @@ template < class P >
class DeleteSingle
{
public:
- inline static void Delete( const P * p )
+ inline static void Delete( const P* p )
{
/** @note If you see an error message about a negative subscript, that
means your are attempting to use Loki to delete an incomplete type.
@@ -194,12 +194,12 @@ public:
delete p;
}
- inline static P * Default( void )
+ inline static P* Default( void )
{
return 0;
}
- inline void Swap( DeleteSingle & ) {}
+ inline void Swap( DeleteSingle& ) {}
};
////////////////////////////////////////////////////////////////////////////////
@@ -214,7 +214,7 @@ template < class P >
class DeleteArray
{
public:
- inline static void Delete( const P * p )
+ inline static void Delete( const P* p )
{
/** @note If you see an error message about a negative subscript, that
means your are attempting to use Loki to delete an incomplete type.
@@ -225,12 +225,12 @@ public:
delete [] p;
}
- inline static P * Default( void )
+ inline static P* Default( void )
{
return 0;
}
- inline void Swap( DeleteArray & ) {}
+ inline void Swap( DeleteArray& ) {}
};
////////////////////////////////////////////////////////////////////////////////
@@ -326,7 +326,7 @@ public:
{
}
- inline TwoRefCountInfo( void * p, bool strong )
+ inline TwoRefCountInfo( void* p, bool strong )
: m_pointer( p )
, m_strongCount( strong ? 1 : 0 )
, m_weakCount( strong ? 0 : 1 )
@@ -378,28 +378,28 @@ public:
m_pointer = 0;
}
- void SetPointer( void * p )
+ void SetPointer( void* p )
{
m_pointer = p;
}
- inline void * GetPointer( void ) const
+ inline void* GetPointer( void ) const
{
return m_pointer;
}
- inline void * & GetPointerRef( void ) const
+ inline void*& GetPointerRef( void ) const
{
- return const_cast< void * & >( m_pointer );
+ return const_cast< void *& >( m_pointer );
}
private:
/// Copy-constructor not implemented.
- TwoRefCountInfo( const TwoRefCountInfo & );
+ TwoRefCountInfo( const TwoRefCountInfo& );
/// Copy-assignment operator not implemented.
- TwoRefCountInfo & operator = ( const TwoRefCountInfo & );
+ TwoRefCountInfo& operator = ( const TwoRefCountInfo& );
- void * m_pointer;
+ void* m_pointer;
unsigned int m_strongCount;
unsigned int m_weakCount;
};
@@ -435,7 +435,7 @@ public:
{
}
- LockableTwoRefCountInfo( void * p, bool strong )
+ LockableTwoRefCountInfo( void* p, bool strong )
: TwoRefCountInfo( p, strong )
, m_Mutex()
{
@@ -507,19 +507,19 @@ public:
m_Mutex.Unlock();
}
- void SetPointer( void * p )
+ void SetPointer( void* p )
{
m_Mutex.Lock();
TwoRefCountInfo::SetPointer( p );
m_Mutex.Unlock();
}
- inline void * GetPointer( void ) const
+ inline void* GetPointer( void ) const
{
return TwoRefCountInfo::GetPointer();
}
- inline void * & GetPointerRef( void ) const
+ inline void*& GetPointerRef( void ) const
{
return TwoRefCountInfo::GetPointerRef();
}
@@ -528,9 +528,9 @@ private:
/// Default constructor is not available.
LockableTwoRefCountInfo( void );
/// Copy constructor is not available.
- LockableTwoRefCountInfo( const LockableTwoRefCountInfo & );
+ LockableTwoRefCountInfo( const LockableTwoRefCountInfo& );
/// Copy-assignment operator is not available.
- LockableTwoRefCountInfo & operator = ( const LockableTwoRefCountInfo & );
+ LockableTwoRefCountInfo& operator = ( const LockableTwoRefCountInfo& );
mutable LOKI_DEFAULT_MUTEX m_Mutex;
};
@@ -556,9 +556,9 @@ protected:
explicit TwoRefCounts( bool strong );
- TwoRefCounts( const void * p, bool strong );
+ TwoRefCounts( const void* p, bool strong );
- TwoRefCounts( const TwoRefCounts & rhs, bool strong ) :
+ TwoRefCounts( const TwoRefCounts& rhs, bool strong ) :
m_counts( rhs.m_counts )
{
Increment( strong );
@@ -580,35 +580,35 @@ protected:
return m_counts->HasStrongPointer();
}
- void Swap( TwoRefCounts & rhs );
+ void Swap( TwoRefCounts& rhs );
- void SetPointer( void * p )
+ void SetPointer( void* p )
{
m_counts->SetPointer( p );
}
void ZapPointer( void );
- inline void * & GetPointerRef( void ) const
+ inline void*& GetPointerRef( void ) const
{
return m_counts->GetPointerRef();
}
- inline void * GetPointer( void ) const
+ inline void* GetPointer( void ) const
{
return m_counts->GetPointer();
}
private:
TwoRefCounts( void );
- TwoRefCounts & operator = ( const TwoRefCounts & );
+ TwoRefCounts& operator = ( const TwoRefCounts& );
void Increment( bool strong );
bool Decrement( bool strong );
/// Pointer to all shared data.
- Loki::Private::TwoRefCountInfo * m_counts;
+ Loki::Private::TwoRefCountInfo* m_counts;
};
////////////////////////////////////////////////////////////////////////////////
@@ -637,28 +637,28 @@ protected:
explicit LockableTwoRefCounts( bool strong )
: m_counts( NULL )
{
- void * temp = ThreadSafePointerAllocator::operator new(
- sizeof(Loki::Private::LockableTwoRefCountInfo) );
+ void* temp = ThreadSafePointerAllocator::operator new(
+ sizeof(Loki::Private::LockableTwoRefCountInfo) );
#ifdef DO_EXTRA_LOKI_TESTS
assert( temp != 0 );
#endif
m_counts = new ( temp ) Loki::Private::LockableTwoRefCountInfo( strong );
}
- LockableTwoRefCounts( const void * p, bool strong )
+ LockableTwoRefCounts( const void* p, bool strong )
: m_counts( NULL )
{
- void * temp = ThreadSafePointerAllocator::operator new(
- sizeof(Loki::Private::LockableTwoRefCountInfo) );
+ void* temp = ThreadSafePointerAllocator::operator new(
+ sizeof(Loki::Private::LockableTwoRefCountInfo) );
#ifdef DO_EXTRA_LOKI_TESTS
assert( temp != 0 );
#endif
- void * p2 = const_cast< void * >( p );
+ void* p2 = const_cast< void* >( p );
m_counts = new ( temp )
- Loki::Private::LockableTwoRefCountInfo( p2, strong );
+ Loki::Private::LockableTwoRefCountInfo( p2, strong );
}
- LockableTwoRefCounts( const LockableTwoRefCounts & rhs, bool strong ) :
+ LockableTwoRefCounts( const LockableTwoRefCounts& rhs, bool strong ) :
m_counts( rhs.m_counts )
{
Increment( strong );
@@ -717,12 +717,12 @@ protected:
return m_counts->HasStrongPointer();
}
- void Swap( LockableTwoRefCounts & rhs )
+ void Swap( LockableTwoRefCounts& rhs )
{
std::swap( m_counts, rhs.m_counts );
}
- void SetPointer( void * p )
+ void SetPointer( void* p )
{
m_counts->SetPointer( p );
}
@@ -739,27 +739,27 @@ protected:
else
{
ThreadSafePointerAllocator::operator delete ( m_counts,
- sizeof(Loki::Private::LockableTwoRefCountInfo) );
+ sizeof(Loki::Private::LockableTwoRefCountInfo) );
m_counts = NULL;
}
}
- inline void * GetPointer( void ) const
+ inline void* GetPointer( void ) const
{
return m_counts->GetPointer();
}
- inline void * & GetPointerRef( void ) const
+ inline void*& GetPointerRef( void ) const
{
return m_counts->GetPointerRef();
}
private:
LockableTwoRefCounts( void );
- LockableTwoRefCounts & operator = ( const LockableTwoRefCounts & );
+ LockableTwoRefCounts& operator = ( const LockableTwoRefCounts& );
/// Pointer to all shared data.
- Loki::Private::LockableTwoRefCountInfo * m_counts;
+ Loki::Private::LockableTwoRefCountInfo* m_counts;
};
#endif // if object-level-locking or class-level-locking
@@ -785,15 +785,15 @@ protected:
m_prev = m_next = this;
}
- TwoRefLinks( const void * p, bool strong );
+ TwoRefLinks( const void* p, bool strong );
- TwoRefLinks( const TwoRefLinks & rhs, bool strong );
+ TwoRefLinks( const TwoRefLinks& rhs, bool strong );
bool Release( bool strong );
- void Swap( TwoRefLinks & rhs );
+ void Swap( TwoRefLinks& rhs );
- bool Merge( TwoRefLinks & rhs );
+ bool Merge( TwoRefLinks& rhs );
bool HasStrongPointer( void ) const;
@@ -802,35 +802,35 @@ protected:
ZapAllNodes();
}
- void SetPointer( void * p );
+ void SetPointer( void* p );
- inline void * GetPointer( void ) const
+ inline void* GetPointer( void ) const
{
return m_pointer;
}
- inline void * & GetPointerRef( void ) const
+ inline void*& GetPointerRef( void ) const
{
- return const_cast< void * & >( m_pointer );
+ return const_cast< void *& >( m_pointer );
}
private:
- static unsigned int CountPrevCycle( const TwoRefLinks * pThis );
- static unsigned int CountNextCycle( const TwoRefLinks * pThis );
+ static unsigned int CountPrevCycle( const TwoRefLinks* pThis );
+ static unsigned int CountNextCycle( const TwoRefLinks* pThis );
/// Not implemented.
TwoRefLinks( void );
/// Not implemented.
- TwoRefLinks & operator = ( const TwoRefLinks & );
+ TwoRefLinks& operator = ( const TwoRefLinks& );
- bool HasPrevNode( const TwoRefLinks * p ) const;
- bool HasNextNode( const TwoRefLinks * p ) const;
+ bool HasPrevNode( const TwoRefLinks* p ) const;
+ bool HasNextNode( const TwoRefLinks* p ) const;
bool AllNodesHaveSamePointer( void ) const;
void ZapAllNodes( void );
- void * m_pointer;
- mutable TwoRefLinks * m_prev;
- mutable TwoRefLinks * m_next;
+ void* m_pointer;
+ mutable TwoRefLinks* m_prev;
+ mutable TwoRefLinks* m_next;
const bool m_strong;
};
@@ -850,24 +850,24 @@ private:
template
<
- typename T,
- bool Strong = true,
- class OwnershipPolicy = Loki::TwoRefCounts,
- class ConversionPolicy = Loki::DisallowConversion,
- template < class > class CheckingPolicy = Loki::AssertCheck,
- template < class > class ResetPolicy = Loki::CantResetWithStrong,
- template < class > class DeletePolicy = Loki::DeleteSingle,
- template < class > class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
->
+typename T,
+ bool Strong = true,
+ class OwnershipPolicy = Loki::TwoRefCounts,
+ class ConversionPolicy = Loki::DisallowConversion,
+ template < class > class CheckingPolicy = Loki::AssertCheck,
+ template < class > class ResetPolicy = Loki::CantResetWithStrong,
+ template < class > class DeletePolicy = Loki::DeleteSingle,
+ template < class > class ConstnessPolicy = LOKI_DEFAULT_CONSTNESS
+ >
class StrongPtr
: public OwnershipPolicy
, public ConversionPolicy
- , public CheckingPolicy< T * >
+ , public CheckingPolicy< T* >
, public ResetPolicy< T >
, public DeletePolicy< T >
{
typedef ConversionPolicy CP;
- typedef CheckingPolicy< T * > KP;
+ typedef CheckingPolicy< T* > KP;
typedef ResetPolicy< T > RP;
typedef DeletePolicy< T > DP;
@@ -875,12 +875,12 @@ public:
typedef OwnershipPolicy OP;
- typedef T * StoredType; // the type of the pointer
- typedef T * PointerType; // type returned by operator->
- typedef T & ReferenceType; // type returned by operator*
+ typedef T* StoredType; // the type of the pointer
+ typedef T* PointerType; // type returned by operator->
+ typedef T& ReferenceType; // type returned by operator*
- typedef typename ConstnessPolicy< T >::Type * ConstPointerType;
- typedef typename ConstnessPolicy< T >::Type & ConstReferenceType;
+ typedef typename ConstnessPolicy< T >::Type* ConstPointerType;
+ typedef typename ConstnessPolicy< T >::Type& ConstReferenceType;
private:
struct NeverMatched {};
@@ -910,22 +910,22 @@ public:
KP::OnInit( GetPointer() );
}
- StrongPtr( const StrongPtr & rhs )
+ StrongPtr( const StrongPtr& rhs )
: OP( rhs, Strong ), CP( rhs ), KP( rhs ), DP( rhs )
{
}
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
StrongPtr(
const StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & rhs )
: OP( rhs, Strong )
@@ -934,15 +934,15 @@ public:
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
StrongPtr(
StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & rhs )
: OP( rhs, Strong )
@@ -959,7 +959,7 @@ public:
return RefToValue< StrongPtr >( *this );
}
- StrongPtr & operator = ( const StrongPtr & rhs )
+ StrongPtr& operator = ( const StrongPtr& rhs )
{
if ( GetPointer() != rhs.GetPointer() )
{
@@ -969,7 +969,7 @@ public:
return *this;
}
- StrongPtr & operator = ( T * p )
+ StrongPtr& operator = ( T* p )
{
if ( GetPointer() != p )
{
@@ -981,16 +981,16 @@ public:
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
- StrongPtr & operator = (
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
+ StrongPtr& operator = (
const StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & rhs )
{
if ( !rhs.Equals( GetPointer() ) )
@@ -1006,7 +1006,7 @@ public:
return Strong;
}
- void Swap( StrongPtr & rhs )
+ void Swap( StrongPtr& rhs )
{
OP::Swap( rhs );
CP::Swap( rhs );
@@ -1023,7 +1023,7 @@ public:
// to deleting the shared object multiple times, which leads to
// undefined behavior. Therefore, this must get pointer before
// zapping it, and then delete the temp pointer.
- T * p = GetPointer();
+ T* p = GetPointer();
OP::ZapPointer();
if ( p != 0 )
{
@@ -1035,8 +1035,8 @@ public:
#ifdef LOKI_ENABLE_FRIEND_TEMPLATE_TEMPLATE_PARAMETER_WORKAROUND
// old non standard in class definition of friends
- friend bool ReleaseAll( StrongPtr & sp,
- typename StrongPtr::StoredType & p )
+ friend bool ReleaseAll( StrongPtr& sp,
+ typename StrongPtr::StoredType& p )
{
if ( !sp.RP::OnReleaseAll( sp.IsStrong() || sp.OP::HasStrongPointer() ) )
{
@@ -1047,8 +1047,8 @@ public:
return true;
}
- friend bool ResetAll( StrongPtr & sp,
- typename StrongPtr::StoredType p )
+ friend bool ResetAll( StrongPtr& sp,
+ typename StrongPtr::StoredType p )
{
if ( sp.OP::GetPointer() == p )
{
@@ -1067,32 +1067,32 @@ public:
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
friend bool ReleaseAll( StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & sp,
- typename StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 >::StoredType & p );
+ typename StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 >::StoredType& p );
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
friend bool ResetAll( StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & sp,
- typename StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 >::StoredType p );
+ typename StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 >::StoredType p );
#endif
@@ -1103,15 +1103,15 @@ public:
*/
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
bool Merge( StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & rhs )
{
if ( OP::GetPointer() != rhs.OP::GetPointer() )
@@ -1163,21 +1163,21 @@ public:
/// Helper function which can be called to avoid exposing GetPointer function.
template < class T1 >
- bool Equals( const T1 * p ) const
+ bool Equals( const T1* p ) const
{
return ( GetPointer() == p );
}
/// Helper function which can be called to avoid exposing GetPointer function.
template < class T1 >
- bool LessThan( const T1 * p ) const
+ bool LessThan( const T1* p ) const
{
return ( GetPointer() < p );
}
/// Helper function which can be called to avoid exposing GetPointer function.
template < class T1 >
- bool GreaterThan( const T1 * p ) const
+ bool GreaterThan( const T1* p ) const
{
return ( GetPointer() > p );
}
@@ -1185,15 +1185,15 @@ public:
/// Equality comparison operator is templated to handle ambiguity.
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
bool operator == (
const StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & rhs ) const
{
@@ -1203,15 +1203,15 @@ public:
/// Inequality comparison operator is templated to handle ambiguity.
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
bool operator != (
const StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & rhs ) const
{
@@ -1221,15 +1221,15 @@ public:
/// Less-than comparison operator is templated to handle ambiguity.
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
bool operator < (
const StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & rhs ) const
{
@@ -1239,15 +1239,15 @@ public:
/// Greater-than comparison operator is templated to handle ambiguity.
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
inline bool operator > (
const StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & rhs ) const
{
@@ -1257,15 +1257,15 @@ public:
/// Less-than-or-equal-to operator is templated to handle ambiguity.
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
inline bool operator <= (
const StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & rhs ) const
{
@@ -1275,15 +1275,15 @@ public:
/// Greater-than-or-equal-to operator is templated to handle ambiguity.
template
<
- typename T1,
- bool S1,
- class OP1,
- class CP1,
- template < class > class KP1,
- template < class > class RP1,
- template < class > class DP1,
- template < class > class CNP1
- >
+ typename T1,
+ bool S1,
+ class OP1,
+ class CP1,
+ template < class > class KP1,
+ template < class > class RP1,
+ template < class > class DP1,
+ template < class > class CNP1
+ >
inline bool operator >= (
const StrongPtr< T1, S1, OP1, CP1, KP1, RP1, DP1, CNP1 > & rhs ) const
{
@@ -1329,7 +1329,7 @@ private:
typedef void (Tester::*unspecified_boolean_type_)();
typedef typename Select< CP::allow, Tester, unspecified_boolean_type_ >::Result
- unspecified_boolean_type;
+ unspecified_boolean_type;
public:
// enable 'if (sp)'
@@ -1346,7 +1346,7 @@ private:
};
typedef typename Select< CP::allow, PointerType, Insipid >::Result
- AutomaticConversionResult;
+ AutomaticConversionResult;
public:
operator AutomaticConversionResult() const
@@ -1364,54 +1364,54 @@ public:
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
bool ReleaseAll( StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & sp,
- typename StrongPtr< T, S, OP, CP, KP, RP, DP, CNP >::StoredType & p )
+ typename StrongPtr< T, S, OP, CP, KP, RP, DP, CNP >::StoredType& p )
{
- if ( !sp.RP<T>::OnReleaseAll( sp.IsStrong() || sp.OP::HasStrongPointer() ) )
- {
- return false;
- }
- p = sp.GetPointer();
- sp.OP::SetPointer( sp.DP<T>::Default() );
- return true;
+ if ( !sp.RP<T>::OnReleaseAll( sp.IsStrong() || sp.OP::HasStrongPointer() ) )
+ {
+ return false;
+ }
+ p = sp.GetPointer();
+ sp.OP::SetPointer( sp.DP<T>::Default() );
+ return true;
}
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
bool ResetAll( StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & sp,
typename StrongPtr< T, S, OP, CP, KP, RP, DP, CNP >::StoredType p )
{
- if ( sp.OP::GetPointer() == p )
- {
+ if ( sp.OP::GetPointer() == p )
+ {
+ return true;
+ }
+ if ( !sp.RP<T>::OnResetAll( sp.IsStrong() || sp.OP::HasStrongPointer() ) )
+ {
+ return false;
+ }
+ sp.DP<T>::Delete( sp.GetPointer() );
+ sp.OP::SetPointer( p );
return true;
- }
- if ( !sp.RP<T>::OnResetAll( sp.IsStrong() || sp.OP::HasStrongPointer() ) )
- {
- return false;
- }
- sp.DP<T>::Delete( sp.GetPointer() );
- sp.OP::SetPointer( p );
- return true;
}
#endif
@@ -1422,18 +1422,18 @@ bool ResetAll( StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & sp,
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
inline bool operator == (
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U * rhs )
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U* rhs )
{
return ( lhs.Equals( rhs ) );
}
@@ -1442,18 +1442,18 @@ inline bool operator == (
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
-inline bool operator == ( U * lhs,
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
+inline bool operator == ( U* lhs,
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
{
return ( rhs.Equals( lhs ) );
}
@@ -1462,18 +1462,18 @@ inline bool operator == ( U * lhs,
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
inline bool operator != (
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U * rhs )
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U* rhs )
{
return !( lhs.Equals( rhs ) );
}
@@ -1482,18 +1482,18 @@ inline bool operator != (
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
-inline bool operator != ( U * lhs,
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
+inline bool operator != ( U* lhs,
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
{
return !( rhs.Equals( lhs ) );
}
@@ -1502,18 +1502,18 @@ inline bool operator != ( U * lhs,
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
inline bool operator < (
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U * rhs )
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U* rhs )
{
return ( lhs.LessThan( rhs ) );
}
@@ -1522,18 +1522,18 @@ inline bool operator < (
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
-inline bool operator < ( U * lhs,
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
+inline bool operator < ( U* lhs,
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
{
return ( rhs.GreaterThan( lhs ) );
}
@@ -1542,18 +1542,18 @@ inline bool operator < ( U * lhs,
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
inline bool operator > (
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U * rhs )
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U* rhs )
{
return ( lhs.GreaterThan( rhs ) );
}
@@ -1562,18 +1562,18 @@ inline bool operator > (
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
-inline bool operator > ( U * lhs,
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
+inline bool operator > ( U* lhs,
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
{
return ( rhs.LessThan( lhs ) );
}
@@ -1582,18 +1582,18 @@ inline bool operator > ( U * lhs,
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
inline bool operator <= (
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U * rhs )
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U* rhs )
{
return !( lhs.GreaterThan( rhs ) );
}
@@ -1602,18 +1602,18 @@ inline bool operator <= (
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
-inline bool operator <= ( U * lhs,
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
+inline bool operator <= ( U* lhs,
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
{
return !( rhs.LessThan( lhs ) );
}
@@ -1622,18 +1622,18 @@ inline bool operator <= ( U * lhs,
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
inline bool operator >= (
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U * rhs )
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs, U* rhs )
{
return !( lhs.LessThan( rhs ) );
}
@@ -1642,18 +1642,18 @@ inline bool operator >= (
/// \ingroup SmartPointerGroup
template
<
- typename U,
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
->
-inline bool operator >= ( U * lhs,
- const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
+typename U,
+ typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
+inline bool operator >= ( U* lhs,
+ const StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs )
{
return !( rhs.GreaterThan( lhs ) );
}
@@ -1662,33 +1662,33 @@ inline bool operator >= ( U * lhs,
namespace std
{
- ////////////////////////////////////////////////////////////////////////////////
- /// specialization of std::less for StrongPtr
- /// \ingroup SmartPointerGroup
- ////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T,
- bool S,
- class OP,
- class CP,
- template < class > class KP,
- template < class > class RP,
- template < class > class DP,
- template < class > class CNP
- >
- struct less< Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > >
+////////////////////////////////////////////////////////////////////////////////
+/// specialization of std::less for StrongPtr
+/// \ingroup SmartPointerGroup
+////////////////////////////////////////////////////////////////////////////////
+template
+<
+typename T,
+ bool S,
+ class OP,
+ class CP,
+ template < class > class KP,
+ template < class > class RP,
+ template < class > class DP,
+ template < class > class CNP
+ >
+struct less< Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > >
: public binary_function<
- Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP >,
- Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP >, bool >
+ Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP >,
+ Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP >, bool >
+{
+ bool operator () (
+ const Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs,
+ const Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs ) const
{
- bool operator () (
- const Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & lhs,
- const Loki::StrongPtr< T, S, OP, CP, KP, RP, DP, CNP > & rhs ) const
- {
- return ( lhs < rhs );
- }
- };
+ return ( lhs < rhs );
+ }
+};
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/shared/loki/Threads.h b/shared/loki/Threads.h
index cb44f094..8fb5d362 100644
--- a/shared/loki/Threads.h
+++ b/shared/loki/Threads.h
@@ -54,26 +54,26 @@
#if defined(LOKI_CLASS_LEVEL_THREADING) || defined(LOKI_OBJECT_LEVEL_THREADING)
- #define LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL ::Loki::ClassLevelLockable
-
- #if defined(LOKI_CLASS_LEVEL_THREADING) && !defined(LOKI_OBJECT_LEVEL_THREADING)
- #define LOKI_DEFAULT_THREADING ::Loki::ClassLevelLockable
- #else
- #define LOKI_DEFAULT_THREADING ::Loki::ObjectLevelLockable
- #endif
-
- #if defined(_WIN32) || defined(_WIN64)
- #include <windows.h>
- #define LOKI_WINDOWS_H
- #else
- #include <pthread.h>
- #define LOKI_PTHREAD_H
- #endif
+#define LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL ::Loki::ClassLevelLockable
+
+#if defined(LOKI_CLASS_LEVEL_THREADING) && !defined(LOKI_OBJECT_LEVEL_THREADING)
+#define LOKI_DEFAULT_THREADING ::Loki::ClassLevelLockable
+#else
+#define LOKI_DEFAULT_THREADING ::Loki::ObjectLevelLockable
+#endif
+
+#if defined(_WIN32) || defined(_WIN64)
+#include <windows.h>
+#define LOKI_WINDOWS_H
+#else
+#include <pthread.h>
+#define LOKI_PTHREAD_H
+#endif
#else
- #define LOKI_DEFAULT_THREADING ::Loki::SingleThreaded
- #define LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL ::Loki::SingleThreaded
+#define LOKI_DEFAULT_THREADING ::Loki::SingleThreaded
+#define LOKI_DEFAULT_THREADING_NO_OBJ_LEVEL ::Loki::SingleThreaded
#endif
@@ -314,291 +314,291 @@
namespace Loki
{
- ////////////////////////////////////////////////////////////////////////////////
- /// \class Mutex
- //
- /// \ingroup ThreadingGroup
- /// A simple and portable Mutex. A default policy class for locking objects.
- ////////////////////////////////////////////////////////////////////////////////
+////////////////////////////////////////////////////////////////////////////////
+/// \class Mutex
+//
+/// \ingroup ThreadingGroup
+/// A simple and portable Mutex. A default policy class for locking objects.
+////////////////////////////////////////////////////////////////////////////////
- class Mutex
+class Mutex
+{
+public:
+ Mutex() LOKI_THREADS_MUTEX_CTOR(mtx_)
{
- public:
- Mutex() LOKI_THREADS_MUTEX_CTOR(mtx_)
- {
- LOKI_THREADS_MUTEX_INIT(&mtx_);
- }
- ~Mutex()
- {
- LOKI_THREADS_MUTEX_DELETE(&mtx_);
- }
- void Lock()
- {
- LOKI_THREADS_MUTEX_LOCK(&mtx_);
- }
- void Unlock()
- {
- LOKI_THREADS_MUTEX_UNLOCK(&mtx_);
- }
- private:
- /// Copy-constructor not implemented.
- Mutex(const Mutex &);
- /// Copy-assignement operator not implemented.
- Mutex & operator = (const Mutex &);
- LOKI_THREADS_MUTEX(mtx_)
- };
+ LOKI_THREADS_MUTEX_INIT(&mtx_);
+ }
+ ~Mutex()
+ {
+ LOKI_THREADS_MUTEX_DELETE(&mtx_);
+ }
+ void Lock()
+ {
+ LOKI_THREADS_MUTEX_LOCK(&mtx_);
+ }
+ void Unlock()
+ {
+ LOKI_THREADS_MUTEX_UNLOCK(&mtx_);
+ }
+private:
+ /// Copy-constructor not implemented.
+ Mutex(const Mutex&);
+ /// Copy-assignement operator not implemented.
+ Mutex& operator = (const Mutex&);
+ LOKI_THREADS_MUTEX(mtx_)
+};
- ////////////////////////////////////////////////////////////////////////////////
- /// \class SingleThreaded
- ///
- /// \ingroup ThreadingGroup
- /// Implementation of the ThreadingModel policy used by various classes
- /// Implements a single-threaded model; no synchronization
- ////////////////////////////////////////////////////////////////////////////////
- template <class Host, class MutexPolicy = LOKI_DEFAULT_MUTEX>
- class SingleThreaded
+////////////////////////////////////////////////////////////////////////////////
+/// \class SingleThreaded
+///
+/// \ingroup ThreadingGroup
+/// Implementation of the ThreadingModel policy used by various classes
+/// Implements a single-threaded model; no synchronization
+////////////////////////////////////////////////////////////////////////////////
+template <class Host, class MutexPolicy = LOKI_DEFAULT_MUTEX>
+class SingleThreaded
+{
+public:
+ /// \struct Lock
+ /// Dummy Lock class
+ struct Lock
{
- public:
- /// \struct Lock
- /// Dummy Lock class
- struct Lock
- {
- Lock() {}
- explicit Lock(const SingleThreaded&) {}
- explicit Lock(const SingleThreaded*) {}
- };
+ Lock() {}
+ explicit Lock(const SingleThreaded&) {}
+ explicit Lock(const SingleThreaded*) {}
+ };
- typedef Host VolatileType;
+ typedef Host VolatileType;
- typedef int IntType;
+ typedef int IntType;
- static IntType AtomicAdd(volatile IntType& lval, const IntType val)
- { return lval += val; }
+ static IntType AtomicAdd(volatile IntType& lval, const IntType val)
+ { return lval += val; }
- static IntType AtomicSubtract(volatile IntType& lval, const IntType val)
- { return lval -= val; }
+ static IntType AtomicSubtract(volatile IntType& lval, const IntType val)
+ { return lval -= val; }
- static IntType AtomicMultiply(volatile IntType& lval, const IntType val)
- { return lval *= val; }
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val)
+ { return lval *= val; }
- static IntType AtomicDivide(volatile IntType& lval, const IntType val)
- { return lval /= val; }
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val)
+ { return lval /= val; }
- static IntType AtomicIncrement(volatile IntType& lval)
- { return ++lval; }
+ static IntType AtomicIncrement(volatile IntType& lval)
+ { return ++lval; }
- static IntType AtomicDecrement(volatile IntType& lval)
- { return --lval; }
+ static IntType AtomicDecrement(volatile IntType& lval)
+ { return --lval; }
- static void AtomicAssign(volatile IntType & lval, const IntType val)
- { lval = val; }
+ static void AtomicAssign(volatile IntType& lval, const IntType val)
+ { lval = val; }
- static void AtomicAssign(IntType & lval, volatile IntType & val)
- { lval = val; }
+ static void AtomicAssign(IntType& lval, volatile IntType& val)
+ { lval = val; }
- static IntType AtomicAdd(volatile IntType& lval, const IntType val, const IntType compare, bool & matches )
- {
- lval += val;
- matches = ( lval == compare );
- return lval;
- }
+ static IntType AtomicAdd(volatile IntType& lval, const IntType val, const IntType compare, bool& matches )
+ {
+ lval += val;
+ matches = ( lval == compare );
+ return lval;
+ }
- static IntType AtomicSubtract(volatile IntType& lval, const IntType val, const IntType compare, bool & matches )
- {
- lval -= val;
- matches = ( lval == compare );
- return lval;
- }
+ static IntType AtomicSubtract(volatile IntType& lval, const IntType val, const IntType compare, bool& matches )
+ {
+ lval -= val;
+ matches = ( lval == compare );
+ return lval;
+ }
- static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool & matches )
- {
- lval *= val;
- matches = ( lval == compare );
- return lval;
- }
+ static IntType AtomicMultiply(volatile IntType& lval, const IntType val, const IntType compare, bool& matches )
+ {
+ lval *= val;
+ matches = ( lval == compare );
+ return lval;
+ }
- static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool & matches )
- {
- lval /= val;
- matches = ( lval == compare );
- return lval;
- }
+ static IntType AtomicDivide(volatile IntType& lval, const IntType val, const IntType compare, bool& matches )
+ {
+ lval /= val;
+ matches = ( lval == compare );
+ return lval;
+ }
- static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool & matches )
- {
- ++lval;
- matches = ( lval == compare );
- return lval;
- }
+ static IntType AtomicIncrement(volatile IntType& lval, const IntType compare, bool& matches )
+ {
+ ++lval;
+ matches = ( lval == compare );
+ return lval;
+ }
- static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool & matches )
- {
- --lval;
- matches = ( lval == compare );
- return lval;
- }
+ static IntType AtomicDecrement(volatile IntType& lval, const IntType compare, bool& matches )
+ {
+ --lval;
+ matches = ( lval == compare );
+ return lval;
+ }
- };
+};
#if defined(LOKI_WINDOWS_H) || defined(LOKI_PTHREAD_H)
- ////////////////////////////////////////////////////////////////////////////////
- /// \class ObjectLevelLockable
- ///
- /// \ingroup ThreadingGroup
- /// Implementation of the ThreadingModel policy used by various classes
- /// Implements a object-level locking scheme
- ////////////////////////////////////////////////////////////////////////////////
- template < class Host, class MutexPolicy = LOKI_DEFAULT_MUTEX >
- class ObjectLevelLockable
- {
- mutable MutexPolicy mtx_;
+////////////////////////////////////////////////////////////////////////////////
+/// \class ObjectLevelLockable
+///
+/// \ingroup ThreadingGroup
+/// Implementation of the ThreadingModel policy used by various classes
+/// Implements a object-level locking scheme
+////////////////////////////////////////////////////////////////////////////////
+template < class Host, class MutexPolicy = LOKI_DEFAULT_MUTEX >
+class ObjectLevelLockable
+{
+ mutable MutexPolicy mtx_;
- public:
- ObjectLevelLockable() : mtx_() {}
+public:
+ ObjectLevelLockable() : mtx_() {}
- ObjectLevelLockable(const ObjectLevelLockable&) : mtx_() {}
+ ObjectLevelLockable(const ObjectLevelLockable&) : mtx_() {}
- ~ObjectLevelLockable() {}
+ ~ObjectLevelLockable() {}
- class Lock;
- friend class Lock;
+ class Lock;
+ friend class Lock;
- /// \struct Lock
- /// Lock class to lock on object level
- class Lock
- {
- public:
+ /// \struct Lock
+ /// Lock class to lock on object level
+ class Lock
+ {
+ public:
- /// Lock object
- explicit Lock(const ObjectLevelLockable& host) : host_(host)
- {
- host_.mtx_.Lock();
- }
+ /// Lock object
+ explicit Lock(const ObjectLevelLockable& host) : host_(host)
+ {
+ host_.mtx_.Lock();
+ }
- /// Lock object
- explicit Lock(const ObjectLevelLockable* host) : host_(*host)
- {
- host_.mtx_.Lock();
- }
+ /// Lock object
+ explicit Lock(const ObjectLevelLockable* host) : host_(*host)
+ {
+ host_.mtx_.Lock();
+ }
- /// Unlock object
- ~Lock()
- {
- host_.mtx_.Unlock();
- }
+ /// Unlock object
+ ~Lock()
+ {
+ host_.mtx_.Unlock();
+ }
- private:
- /// private by design of the object level threading
- Lock();
- Lock(const Lock&);
- Lock& operator=(const Lock&);
- const ObjectLevelLockable& host_;
- };
+ private:
+ /// private by design of the object level threading
+ Lock();
+ Lock(const Lock&);
+ Lock& operator=(const Lock&);
+ const ObjectLevelLockable& host_;
+ };
- typedef volatile Host VolatileType;
+ typedef volatile Host VolatileType;
- typedef LOKI_THREADS_LONG IntType;
+ typedef LOKI_THREADS_LONG IntType;
- LOKI_THREADS_ATOMIC_FUNCTIONS
+ LOKI_THREADS_ATOMIC_FUNCTIONS
- };
+};
#ifdef LOKI_PTHREAD_H
- template <class Host, class MutexPolicy>
- pthread_mutex_t ObjectLevelLockable<Host, MutexPolicy>::atomic_mutex_ = PTHREAD_MUTEX_INITIALIZER;
+template <class Host, class MutexPolicy>
+pthread_mutex_t ObjectLevelLockable<Host, MutexPolicy>::atomic_mutex_ = PTHREAD_MUTEX_INITIALIZER;
#endif
- ////////////////////////////////////////////////////////////////////////////////
- /// \class ClassLevelLockable
- ///
- /// \ingroup ThreadingGroup
- /// Implementation of the ThreadingModel policy used by various classes
- /// Implements a class-level locking scheme
- ////////////////////////////////////////////////////////////////////////////////
- template <class Host, class MutexPolicy = LOKI_DEFAULT_MUTEX >
- class ClassLevelLockable
+////////////////////////////////////////////////////////////////////////////////
+/// \class ClassLevelLockable
+///
+/// \ingroup ThreadingGroup
+/// Implementation of the ThreadingModel policy used by various classes
+/// Implements a class-level locking scheme
+////////////////////////////////////////////////////////////////////////////////
+template <class Host, class MutexPolicy = LOKI_DEFAULT_MUTEX >
+class ClassLevelLockable
+{
+ struct Initializer
{
- struct Initializer
+ bool init_;
+ MutexPolicy mtx_;
+
+ Initializer() : init_(false), mtx_()
+ {
+ init_ = true;
+ }
+
+ ~Initializer()
{
- bool init_;
- MutexPolicy mtx_;
+ assert(init_);
+ }
+ };
- Initializer() : init_(false), mtx_()
- {
- init_ = true;
- }
+ static Initializer initializer_;
- ~Initializer()
- {
- assert(init_);
- }
- };
+public:
- static Initializer initializer_;
+ class Lock;
+ friend class Lock;
+ /// \struct Lock
+ /// Lock class to lock on class level
+ class Lock
+ {
public:
- class Lock;
- friend class Lock;
+ /// Lock class
+ Lock()
+ {
+ assert(initializer_.init_);
+ initializer_.mtx_.Lock();
+ }
- /// \struct Lock
- /// Lock class to lock on class level
- class Lock
+ /// Lock class
+ explicit Lock(const ClassLevelLockable&)
{
- public:
-
- /// Lock class
- Lock()
- {
- assert(initializer_.init_);
- initializer_.mtx_.Lock();
- }
-
- /// Lock class
- explicit Lock(const ClassLevelLockable&)
- {
- assert(initializer_.init_);
- initializer_.mtx_.Lock();
- }
-
- /// Lock class
- explicit Lock(const ClassLevelLockable*)
- {
- assert(initializer_.init_);
- initializer_.mtx_.Lock();
- }
-
- /// Unlock class
- ~Lock()
- {
- assert(initializer_.init_);
- initializer_.mtx_.Unlock();
- }
-
- private:
- Lock(const Lock&);
- Lock& operator=(const Lock&);
- };
-
- typedef volatile Host VolatileType;
-
- typedef LOKI_THREADS_LONG IntType;
-
- LOKI_THREADS_ATOMIC_FUNCTIONS
+ assert(initializer_.init_);
+ initializer_.mtx_.Lock();
+ }
+ /// Lock class
+ explicit Lock(const ClassLevelLockable*)
+ {
+ assert(initializer_.init_);
+ initializer_.mtx_.Lock();
+ }
+
+ /// Unlock class
+ ~Lock()
+ {
+ assert(initializer_.init_);
+ initializer_.mtx_.Unlock();
+ }
+
+ private:
+ Lock(const Lock&);
+ Lock& operator=(const Lock&);
};
+ typedef volatile Host VolatileType;
+
+ typedef LOKI_THREADS_LONG IntType;
+
+ LOKI_THREADS_ATOMIC_FUNCTIONS
+
+};
+
#ifdef LOKI_PTHREAD_H
- template <class Host, class MutexPolicy>
- pthread_mutex_t ClassLevelLockable<Host, MutexPolicy>::atomic_mutex_ = PTHREAD_MUTEX_INITIALIZER;
+template <class Host, class MutexPolicy>
+pthread_mutex_t ClassLevelLockable<Host, MutexPolicy>::atomic_mutex_ = PTHREAD_MUTEX_INITIALIZER;
#endif
- template < class Host, class MutexPolicy >
- typename ClassLevelLockable< Host, MutexPolicy >::Initializer
- ClassLevelLockable< Host, MutexPolicy >::initializer_;
+template < class Host, class MutexPolicy >
+typename ClassLevelLockable< Host, MutexPolicy >::Initializer
+ClassLevelLockable< Host, MutexPolicy >::initializer_;
#endif // #if defined(LOKI_WINDOWS_H) || defined(LOKI_PTHREAD_H)
diff --git a/shared/loki/Tuple.h b/shared/loki/Tuple.h
index 47fc19e2..ec5ae213 100644
--- a/shared/loki/Tuple.h
+++ b/shared/loki/Tuple.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
@@ -18,5 +18,5 @@
////////////////////////////////////////////////////////////////////////////////
// This file is intentionally left empty
// Due to compiler limitations, its contents has been moved to
-// HierarchyGenerators.h
+// HierarchyGenerators.h
////////////////////////////////////////////////////////////////////////////////
diff --git a/shared/loki/TypeManip.h b/shared/loki/TypeManip.h
index e08b4e03..6b7f4ab8 100644
--- a/shared/loki/TypeManip.h
+++ b/shared/loki/TypeManip.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Welsey Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Welsey Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_TYPEMANIP_INC_
@@ -27,12 +27,12 @@ namespace Loki
// Defines 'value', an enum that evaluates to v
////////////////////////////////////////////////////////////////////////////////
- template <int v>
- struct Int2Type
- {
- enum { value = v };
- };
-
+template <int v>
+struct Int2Type
+{
+ enum { value = v };
+};
+
////////////////////////////////////////////////////////////////////////////////
// class template Type2Type
// Converts each type into a unique, insipid type
@@ -40,12 +40,12 @@ namespace Loki
// Defines the type OriginalType which maps back to T
////////////////////////////////////////////////////////////////////////////////
- template <typename T>
- struct Type2Type
- {
- typedef T OriginalType;
- };
-
+template <typename T>
+struct Type2Type
+{
+ typedef T OriginalType;
+};
+
////////////////////////////////////////////////////////////////////////////////
// class template Select
// Selects one of two types based upon a boolean constant
@@ -56,17 +56,17 @@ namespace Loki
// Result evaluates to T if flag is true, and to U otherwise.
////////////////////////////////////////////////////////////////////////////////
- template <bool flag, typename T, typename U>
- struct Select
- {
- typedef T Result;
- };
- template <typename T, typename U>
- struct Select<false, T, U>
- {
- typedef U Result;
- };
-
+template <bool flag, typename T, typename U>
+struct Select
+{
+ typedef T Result;
+};
+template <typename T, typename U>
+struct Select<false, T, U>
+{
+ typedef U Result;
+};
+
////////////////////////////////////////////////////////////////////////////////
// class template IsSameType
// Return true iff two given types are the same
@@ -76,34 +76,34 @@ namespace Loki
// Result evaluates to true iff U == T (types equal)
////////////////////////////////////////////////////////////////////////////////
- template <typename T, typename U>
- struct IsSameType
- {
- enum { value = false };
- };
-
- template <typename T>
- struct IsSameType<T,T>
- {
- enum { value = true };
- };
+template <typename T, typename U>
+struct IsSameType
+{
+ enum { value = false };
+};
+
+template <typename T>
+struct IsSameType<T,T>
+{
+ enum { value = true };
+};
////////////////////////////////////////////////////////////////////////////////
// Helper types Small and Big - guarantee that sizeof(Small) < sizeof(Big)
////////////////////////////////////////////////////////////////////////////////
- namespace Private
- {
- template <class T, class U>
- struct ConversionHelper
- {
- typedef char Small;
- struct Big { char dummy[2]; };
- static Big Test(...);
- static Small Test(U);
- static T MakeT();
- };
- }
+namespace Private
+{
+template <class T, class U>
+struct ConversionHelper
+{
+ typedef char Small;
+ struct Big { char dummy[2]; };
+ static Big Test(...);
+ static Small Test(U);
+ static T MakeT();
+};
+}
////////////////////////////////////////////////////////////////////////////////
// class template Conversion
@@ -121,48 +121,48 @@ namespace Loki
// Caveat: might not work if T and U are in a private inheritance hierarchy.
////////////////////////////////////////////////////////////////////////////////
- template <class T, class U>
- struct Conversion
- {
- typedef Private::ConversionHelper<T, U> H;
+template <class T, class U>
+struct Conversion
+{
+ typedef Private::ConversionHelper<T, U> H;
#ifndef __MWERKS__
- enum { exists = sizeof(typename H::Small) == sizeof((H::Test(H::MakeT()))) };
+ enum { exists = sizeof(typename H::Small) == sizeof((H::Test(H::MakeT()))) };
#else
- enum { exists = false };
+ enum { exists = false };
#endif
- enum { exists2Way = exists && Conversion<U, T>::exists };
- enum { sameType = false };
- };
-
- template <class T>
- struct Conversion<T, T>
- {
- enum { exists = 1, exists2Way = 1, sameType = 1 };
- };
-
- template <class T>
- struct Conversion<void, T>
- {
- enum { exists = 0, exists2Way = 0, sameType = 0 };
- };
-
- template <class T>
- struct Conversion<T, void>
- {
- enum { exists = 0, exists2Way = 0, sameType = 0 };
- };
-
- template <>
- struct Conversion<void, void>
- {
- public:
- enum { exists = 1, exists2Way = 1, sameType = 1 };
- };
+ enum { exists2Way = exists && Conversion<U, T>::exists };
+ enum { sameType = false };
+};
+
+template <class T>
+struct Conversion<T, T>
+{
+ enum { exists = 1, exists2Way = 1, sameType = 1 };
+};
+
+template <class T>
+struct Conversion<void, T>
+{
+ enum { exists = 0, exists2Way = 0, sameType = 0 };
+};
+
+template <class T>
+struct Conversion<T, void>
+{
+ enum { exists = 0, exists2Way = 0, sameType = 0 };
+};
+
+template <>
+struct Conversion<void, void>
+{
+public:
+ enum { exists = 1, exists2Way = 1, sameType = 1 };
+};
////////////////////////////////////////////////////////////////////////////////
// class template SuperSubclass
-// Invocation: SuperSubclass<B, D>::value where B and D are types.
-// Returns true if B is a public base of D, or if B and D are aliases of the
+// Invocation: SuperSubclass<B, D>::value where B and D are types.
+// Returns true if B is a public base of D, or if B and D are aliases of the
// same type.
//
// Caveat: might not work if T and U are in a private inheritance hierarchy.
@@ -172,41 +172,44 @@ template <class T, class U>
struct SuperSubclass
{
enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists &&
- !::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
-
+ !::Loki::Conversion<const volatile T*, const volatile void*>::sameType)
+ };
+
// Dummy enum to make sure that both classes are fully defined.
- enum{ dontUseWithIncompleteTypes = ( sizeof (T) == sizeof (U) ) };
+ enum { dontUseWithIncompleteTypes = ( sizeof (T) == sizeof (U) ) };
};
template <>
-struct SuperSubclass<void, void>
+struct SuperSubclass<void, void>
{
enum { value = false };
};
template <class U>
-struct SuperSubclass<void, U>
+struct SuperSubclass<void, U>
{
enum { value = (::Loki::Conversion<const volatile U*, const volatile void*>::exists &&
- !::Loki::Conversion<const volatile void*, const volatile void*>::sameType) };
-
+ !::Loki::Conversion<const volatile void*, const volatile void*>::sameType)
+ };
+
// Dummy enum to make sure that both classes are fully defined.
- enum{ dontUseWithIncompleteTypes = ( 0 == sizeof (U) ) };
+ enum { dontUseWithIncompleteTypes = ( 0 == sizeof (U) ) };
};
template <class T>
-struct SuperSubclass<T, void>
+struct SuperSubclass<T, void>
{
enum { value = (::Loki::Conversion<const volatile void*, const volatile T*>::exists &&
- !::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
-
+ !::Loki::Conversion<const volatile T*, const volatile void*>::sameType)
+ };
+
// Dummy enum to make sure that both classes are fully defined.
- enum{ dontUseWithIncompleteTypes = ( sizeof (T) == 0 ) };
+ enum { dontUseWithIncompleteTypes = ( sizeof (T) == 0 ) };
};
////////////////////////////////////////////////////////////////////////////////
// class template SuperSubclassStrict
-// Invocation: SuperSubclassStrict<B, D>::value where B and D are types.
+// Invocation: SuperSubclassStrict<B, D>::value where B and D are types.
// Returns true if B is a public base of D.
//
// Caveat: might not work if T and U are in a private inheritance hierarchy.
@@ -216,39 +219,42 @@ template<class T,class U>
struct SuperSubclassStrict
{
enum { value = (::Loki::Conversion<const volatile U*, const volatile T*>::exists &&
- !::Loki::Conversion<const volatile T*, const volatile void*>::sameType &&
- !::Loki::Conversion<const volatile T*, const volatile U*>::sameType) };
-
+ !::Loki::Conversion<const volatile T*, const volatile void*>::sameType &&
+ !::Loki::Conversion<const volatile T*, const volatile U*>::sameType)
+ };
+
// Dummy enum to make sure that both classes are fully defined.
- enum{ dontUseWithIncompleteTypes = ( sizeof (T) == sizeof (U) ) };
+ enum { dontUseWithIncompleteTypes = ( sizeof (T) == sizeof (U) ) };
};
template<>
-struct SuperSubclassStrict<void, void>
+struct SuperSubclassStrict<void, void>
{
enum { value = false };
};
template<class U>
-struct SuperSubclassStrict<void, U>
+struct SuperSubclassStrict<void, U>
{
enum { value = (::Loki::Conversion<const volatile U*, const volatile void*>::exists &&
- !::Loki::Conversion<const volatile void*, const volatile void*>::sameType &&
- !::Loki::Conversion<const volatile void*, const volatile U*>::sameType) };
-
+ !::Loki::Conversion<const volatile void*, const volatile void*>::sameType &&
+ !::Loki::Conversion<const volatile void*, const volatile U*>::sameType)
+ };
+
// Dummy enum to make sure that both classes are fully defined.
- enum{ dontUseWithIncompleteTypes = ( 0 == sizeof (U) ) };
+ enum { dontUseWithIncompleteTypes = ( 0 == sizeof (U) ) };
};
template<class T>
-struct SuperSubclassStrict<T, void>
+struct SuperSubclassStrict<T, void>
{
enum { value = (::Loki::Conversion<const volatile void*, const volatile T*>::exists &&
- !::Loki::Conversion<const volatile T*, const volatile void*>::sameType &&
- !::Loki::Conversion<const volatile T*, const volatile void*>::sameType) };
-
+ !::Loki::Conversion<const volatile T*, const volatile void*>::sameType &&
+ !::Loki::Conversion<const volatile T*, const volatile void*>::sameType)
+ };
+
// Dummy enum to make sure that both classes are fully defined.
- enum{ dontUseWithIncompleteTypes = ( sizeof (T) == 0 ) };
+ enum { dontUseWithIncompleteTypes = ( sizeof (T) == 0 ) };
};
@@ -256,8 +262,8 @@ struct SuperSubclassStrict<T, void>
////////////////////////////////////////////////////////////////////////////////
// macro SUPERSUBCLASS
-// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
-// Returns true if B is a public base of D, or if B and D are aliases of the
+// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
+// Returns true if B is a public base of D, or if B and D are aliases of the
// same type.
//
// Caveat: might not work if T and U are in a private inheritance hierarchy.
@@ -269,7 +275,7 @@ struct SuperSubclassStrict<T, void>
////////////////////////////////////////////////////////////////////////////////
// macro SUPERSUBCLASS_STRICT
-// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
+// Invocation: SUPERSUBCLASS(B, D) where B and D are types.
// Returns true if B is a public base of D.
//
// Caveat: might not work if T and U are in a private inheritance hierarchy.
diff --git a/shared/loki/TypeTraits.h b/shared/loki/TypeTraits.h
index a592cab9..00ef069e 100644
--- a/shared/loki/TypeTraits.h
+++ b/shared/loki/TypeTraits.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_TYPETRAITS_INC_
@@ -27,7 +27,7 @@
#ifdef _MSC_VER
-#pragma warning( push )
+#pragma warning( push )
#pragma warning( disable : 4180 ) //qualifier applied to function type has no meaning; ignored
#endif
@@ -36,7 +36,7 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
// class template IsCustomUnsignedInt
// Offers a means to integrate nonstandard built-in unsigned integral types
-// (such as unsigned __int64 or unsigned long long int) with the TypeTraits
+// (such as unsigned __int64 or unsigned long long int) with the TypeTraits
// class template defined below.
// Invocation: IsCustomUnsignedInt<T> where T is any type
// Defines 'value', an enum that is 1 iff T is a custom built-in unsigned
@@ -45,16 +45,16 @@ namespace Loki
// and define value = 1 in those specializations
////////////////////////////////////////////////////////////////////////////////
- template <typename T>
- struct IsCustomUnsignedInt
- {
- enum { value = 0 };
- };
+template <typename T>
+struct IsCustomUnsignedInt
+{
+ enum { value = 0 };
+};
////////////////////////////////////////////////////////////////////////////////
// class template IsCustomSignedInt
// Offers a means to integrate nonstandard built-in unsigned integral types
-// (such as unsigned __int64 or unsigned long long int) with the TypeTraits
+// (such as unsigned __int64 or unsigned long long int) with the TypeTraits
// class template defined below.
// Invocation: IsCustomSignedInt<T> where T is any type
// Defines 'value', an enum that is 1 iff T is a custom built-in signed
@@ -63,11 +63,11 @@ namespace Loki
// and define value = 1 in those specializations
////////////////////////////////////////////////////////////////////////////////
- template <typename T>
- struct IsCustomSignedInt
- {
- enum { value = 0 };
- };
+template <typename T>
+struct IsCustomSignedInt
+{
+ enum { value = 0 };
+};
////////////////////////////////////////////////////////////////////////////////
// class template IsCustomFloat
@@ -80,1955 +80,1955 @@ namespace Loki
// and define value = 1 in those specializations
////////////////////////////////////////////////////////////////////////////////
- template <typename T>
- struct IsCustomFloat
- {
- enum { value = 0 };
- };
+template <typename T>
+struct IsCustomFloat
+{
+ enum { value = 0 };
+};
////////////////////////////////////////////////////////////////////////////////
// Helper types for class template TypeTraits defined below
////////////////////////////////////////////////////////////////////////////////
- namespace Private
- {
-#ifndef LOKI_DISABLE_TYPELIST_MACROS
- typedef LOKI_TYPELIST_4(unsigned char, unsigned short int,unsigned int, unsigned long int)
- StdUnsignedInts;
- typedef LOKI_TYPELIST_4(signed char, short int,int, long int)
- StdSignedInts;
- typedef LOKI_TYPELIST_3(bool, char, wchar_t)
- StdOtherInts;
- typedef LOKI_TYPELIST_3(float, double, long double)
- StdFloats;
+namespace Private
+{
+#ifndef LOKI_DISABLE_TYPELIST_MACROS
+typedef LOKI_TYPELIST_4(unsigned char, unsigned short int,unsigned int, unsigned long int)
+StdUnsignedInts;
+typedef LOKI_TYPELIST_4(signed char, short int,int, long int)
+StdSignedInts;
+typedef LOKI_TYPELIST_3(bool, char, wchar_t)
+StdOtherInts;
+typedef LOKI_TYPELIST_3(float, double, long double)
+StdFloats;
#else
- typedef Loki::Seq<unsigned char, unsigned short int,unsigned int, unsigned long int>::Type
- StdUnsignedInts;
- typedef Loki::Seq<signed char, short int,int, long int>::Type
- StdSignedInts;
- typedef Loki::Seq<bool, char, wchar_t>::Type
- StdOtherInts;
- typedef Loki::Seq<float, double, long double>::Type
- StdFloats;
-
-#endif
- template <typename U> struct AddPointer
- {
- typedef U* Result;
- };
-
- template <typename U> struct AddPointer<U&>
- {
- typedef U* Result;
- };
-
- template <class U> struct AddReference
- {
- typedef U & Result;
- };
-
- template <class U> struct AddReference<U &>
- {
- typedef U & Result;
- };
-
- template <> struct AddReference<void>
- {
- typedef NullType Result;
- };
-
- template <class U> struct AddParameterType
- {
- typedef const U & Result;
- };
-
- template <class U> struct AddParameterType<U &>
- {
- typedef U & Result;
- };
-
- template <> struct AddParameterType<void>
- {
- typedef NullType Result;
- };
-
- template <typename T>
- struct IsFunctionPointerRaw
- {enum{result = 0};};
-
- template <typename T>
- struct IsFunctionPointerRaw<T(*)()>
- {enum {result = 1};};
-
- template <typename T,
- typename P01>
- struct IsFunctionPointerRaw<T(*)(P01)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19, typename P20>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, P20)>
- {enum {result = 1};};
-
- template <typename T>
- struct IsFunctionPointerRaw<T(*)(
- ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01>
- struct IsFunctionPointerRaw<T(*)(
- P01, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, ...)>
- {enum {result = 1};};
-
- template <typename T,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19, typename P20>
- struct IsFunctionPointerRaw<T(*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, P20,
- ...)>
- {enum {result = 1};};
-
-
- template <typename T>
- struct IsMemberFunctionPointerRaw
- {enum{result = 0};};
-
- template <typename T, typename S>
- struct IsMemberFunctionPointerRaw<T (S::*)()>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01>
- struct IsMemberFunctionPointerRaw<T (S::*)(P01)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19, typename P20>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, P20)>
- {enum {result = 1};};
-
- template <typename T, typename S>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, ...)>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19, typename P20>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, P20,
- ...)>
- {enum {result = 1};};
-
- // Const versions
-
- template <typename T, typename S>
- struct IsMemberFunctionPointerRaw<T (S::*)() const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01>
- struct IsMemberFunctionPointerRaw<T (S::*)(P01) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19, typename P20>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, P20) const>
- {enum {result = 1};};
-
- template <typename T, typename S>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, ...) const>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19, typename P20>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, P20,
- ...) const>
- {enum {result = 1};};
-
- // Volatile versions
-
- template <typename T, typename S>
- struct IsMemberFunctionPointerRaw<T (S::*)() volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01>
- struct IsMemberFunctionPointerRaw<T (S::*)(P01) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19, typename P20>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, P20) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, ...) volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19, typename P20>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, P20,
- ...) volatile>
- {enum {result = 1};};
-
- // Const volatile versions
-
- template <typename T, typename S>
- struct IsMemberFunctionPointerRaw<T (S::*)() const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01>
- struct IsMemberFunctionPointerRaw<T (S::*)(P01) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19, typename P20>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, P20) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, ...) const volatile>
- {enum {result = 1};};
-
- template <typename T, typename S,
- typename P01, typename P02, typename P03, typename P04, typename P05,
- typename P06, typename P07, typename P08, typename P09, typename P10,
- typename P11, typename P12, typename P13, typename P14, typename P15,
- typename P16, typename P17, typename P18, typename P19, typename P20>
- struct IsMemberFunctionPointerRaw<T (S::*)(
- P01, P02, P03, P04, P05,
- P06, P07, P08, P09, P10,
- P11, P12, P13, P14, P15,
- P16, P17, P18, P19, P20,
- ...) const volatile>
- {enum {result = 1};};
-
- }// namespace Private
-
+typedef Loki::Seq<unsigned char, unsigned short int,unsigned int, unsigned long int>::Type
+StdUnsignedInts;
+typedef Loki::Seq<signed char, short int,int, long int>::Type
+StdSignedInts;
+typedef Loki::Seq<bool, char, wchar_t>::Type
+StdOtherInts;
+typedef Loki::Seq<float, double, long double>::Type
+StdFloats;
+
+#endif
+template <typename U> struct AddPointer
+{
+ typedef U* Result;
+};
+
+template <typename U> struct AddPointer<U&>
+{
+ typedef U* Result;
+};
+
+template <class U> struct AddReference
+{
+ typedef U& Result;
+};
+
+template <class U> struct AddReference<U&>
+{
+ typedef U& Result;
+};
+
+template <> struct AddReference<void>
+{
+ typedef NullType Result;
+};
+
+template <class U> struct AddParameterType
+{
+ typedef const U& Result;
+};
+
+template <class U> struct AddParameterType<U&>
+{
+ typedef U& Result;
+};
+
+template <> struct AddParameterType<void>
+{
+ typedef NullType Result;
+};
+
+template <typename T>
+struct IsFunctionPointerRaw
+ {enum {result = 0};};
+
+template <typename T>
+struct IsFunctionPointerRaw<T(*)()>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01>
+struct IsFunctionPointerRaw<T(*)(P01)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20)>
+{enum {result = 1};};
+
+template <typename T>
+struct IsFunctionPointerRaw<T(*)(
+ ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01>
+struct IsFunctionPointerRaw<T(*)(
+ P01, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, ...)>
+{enum {result = 1};};
+
+template <typename T,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+struct IsFunctionPointerRaw<T(*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20,
+ ...)>
+{enum {result = 1};};
+
+
+template <typename T>
+struct IsMemberFunctionPointerRaw
+ {enum {result = 0};};
+
+template <typename T, typename S>
+struct IsMemberFunctionPointerRaw<T (S::*)()>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01>
+struct IsMemberFunctionPointerRaw<T (S::*)(P01)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20)>
+{enum {result = 1};};
+
+template <typename T, typename S>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, ...)>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20,
+ ...)>
+{enum {result = 1};};
+
+// Const versions
+
+template <typename T, typename S>
+struct IsMemberFunctionPointerRaw<T (S::*)() const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01>
+struct IsMemberFunctionPointerRaw<T (S::*)(P01) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20) const>
+{enum {result = 1};};
+
+template <typename T, typename S>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, ...) const>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20,
+ ...) const>
+{enum {result = 1};};
+
+// Volatile versions
+
+template <typename T, typename S>
+struct IsMemberFunctionPointerRaw<T (S::*)() volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01>
+struct IsMemberFunctionPointerRaw<T (S::*)(P01) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, ...) volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20,
+ ...) volatile>
+{enum {result = 1};};
+
+// Const volatile versions
+
+template <typename T, typename S>
+struct IsMemberFunctionPointerRaw<T (S::*)() const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01>
+struct IsMemberFunctionPointerRaw<T (S::*)(P01) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, ...) const volatile>
+{enum {result = 1};};
+
+template <typename T, typename S,
+ typename P01, typename P02, typename P03, typename P04, typename P05,
+ typename P06, typename P07, typename P08, typename P09, typename P10,
+ typename P11, typename P12, typename P13, typename P14, typename P15,
+ typename P16, typename P17, typename P18, typename P19, typename P20>
+struct IsMemberFunctionPointerRaw<T (S::*)(
+ P01, P02, P03, P04, P05,
+ P06, P07, P08, P09, P10,
+ P11, P12, P13, P14, P15,
+ P16, P17, P18, P19, P20,
+ ...) const volatile>
+{enum {result = 1};};
+
+}// namespace Private
+
////////////////////////////////////////////////////////////////////////////////
// class template TypeTraits
//
@@ -2036,10 +2036,10 @@ namespace Loki
// Invocations (T is a type, TypeTraits<T>::Property):
//
// - isPointer : returns true if T is a pointer type
-// - PointeeType : returns the type to which T points if T is a pointer
+// - PointeeType : returns the type to which T points if T is a pointer
// type, NullType otherwise
// - isReference : returns true if T is a reference type
-// - ReferredType : returns the type to which T refers if T is a reference
+// - ReferredType : returns the type to which T refers if T is a reference
// type, NullType otherwise
// - isMemberPointer : returns true if T is a pointer to member type
// - isStdUnsignedInt: returns true if T is a standard unsigned integral type
@@ -2054,169 +2054,177 @@ namespace Loki
// - isFloat : returns true if T is a floating-point type
// - isArith : returns true if T is a arithmetic type
// - isFundamental : returns true if T is a fundamental type
-// - ParameterType : returns the optimal type to be used as a parameter for
+// - ParameterType : returns the optimal type to be used as a parameter for
// functions that take Ts
// - isConst : returns true if T is a const-qualified type
// - NonConstType : Type with removed 'const' qualifier from T, if any
// - isVolatile : returns true if T is a volatile-qualified type
// - NonVolatileType : Type with removed 'volatile' qualifier from T, if any
-// - UnqualifiedType : Type with removed 'const' and 'volatile' qualifiers from
+// - UnqualifiedType : Type with removed 'const' and 'volatile' qualifiers from
// T, if any
-// - ParameterType : returns the optimal type to be used as a parameter
+// - ParameterType : returns the optimal type to be used as a parameter
// for functions that take 'const T's
//
////////////////////////////////////////////////////////////////////////////////
- template <typename T>
- class TypeTraits
+template <typename T>
+class TypeTraits
+{
+private:
+
+ template <class U> struct ReferenceTraits
{
- private:
-
- template <class U> struct ReferenceTraits
- {
- enum { result = false };
- typedef U ReferredType;
- };
-
- template <class U> struct ReferenceTraits<U&>
- {
- enum { result = true };
- typedef U ReferredType;
- };
-
- template <class U> struct PointerTraits
- {
- enum { result = false };
- typedef NullType PointeeType;
- };
-
- template <class U> struct PointerTraits<U*>
- {
- enum { result = true };
- typedef U PointeeType;
- };
-
- template <class U> struct PointerTraits<U*&>
- {
- enum { result = true };
- typedef U PointeeType;
- };
-
- template <class U> struct PToMTraits
- {
- enum { result = false };
- };
-
- template <class U, class V> struct PToMTraits<U V::*>
- {
- enum { result = true };
- };
-
- template <class U, class V> struct PToMTraits<U V::*&>
- {
- enum { result = true };
- };
-
- template <class U> struct FunctionPointerTraits
- {
- enum{ result = Private::IsFunctionPointerRaw<U>::result };
- };
-
- template <typename U> struct PToMFunctionTraits
- {
- enum{ result = Private::IsMemberFunctionPointerRaw<U>::result };
- };
-
- template <class U> struct UnConst
- {
- typedef U Result;
- enum { isConst = 0 };
- };
-
- template <class U> struct UnConst<const U>
- {
- typedef U Result;
- enum { isConst = 1 };
- };
-
- template <class U> struct UnConst<const U&>
- {
- typedef U& Result;
- enum { isConst = 1 };
- };
-
- template <class U> struct UnVolatile
- {
- typedef U Result;
- enum { isVolatile = 0 };
- };
-
- template <class U> struct UnVolatile<volatile U>
- {
- typedef U Result;
- enum { isVolatile = 1 };
- };
-
- template <class U> struct UnVolatile<volatile U&>
- {
- typedef U& Result;
- enum { isVolatile = 1 };
- };
-
- public:
- typedef typename UnConst<T>::Result
- NonConstType;
- typedef typename UnVolatile<T>::Result
- NonVolatileType;
- typedef typename UnVolatile<typename UnConst<T>::Result>::Result
- UnqualifiedType;
- typedef typename PointerTraits<UnqualifiedType>::PointeeType
- PointeeType;
- typedef typename ReferenceTraits<T>::ReferredType
- ReferredType;
-
- enum { isConst = UnConst<T>::isConst };
- enum { isVolatile = UnVolatile<T>::isVolatile };
- enum { isReference = ReferenceTraits<UnqualifiedType>::result };
- enum { isFunction = FunctionPointerTraits<typename Private::AddPointer<T>::Result >::result };
- enum { isFunctionPointer= FunctionPointerTraits<
- typename ReferenceTraits<UnqualifiedType>::ReferredType >::result };
- enum { isMemberFunctionPointer= PToMFunctionTraits<
- typename ReferenceTraits<UnqualifiedType>::ReferredType >::result };
- enum { isMemberPointer = PToMTraits<
- typename ReferenceTraits<UnqualifiedType>::ReferredType >::result ||
- isMemberFunctionPointer };
- enum { isPointer = PointerTraits<
- typename ReferenceTraits<UnqualifiedType>::ReferredType >::result ||
- isFunctionPointer };
-
- enum { isStdUnsignedInt = TL::IndexOf<Private::StdUnsignedInts, UnqualifiedType>::value >= 0 ||
- TL::IndexOf<Private::StdUnsignedInts,
- typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0};
- enum { isStdSignedInt = TL::IndexOf<Private::StdSignedInts, UnqualifiedType>::value >= 0 ||
- TL::IndexOf<Private::StdSignedInts,
- typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0};
- enum { isStdIntegral = isStdUnsignedInt || isStdSignedInt ||
- TL::IndexOf<Private::StdOtherInts, UnqualifiedType>::value >= 0 ||
- TL::IndexOf<Private::StdOtherInts,
- typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0};
- enum { isStdFloat = TL::IndexOf<Private::StdFloats, UnqualifiedType>::value >= 0 ||
- TL::IndexOf<Private::StdFloats,
- typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0};
- enum { isStdArith = isStdIntegral || isStdFloat };
- enum { isStdFundamental = isStdArith || isStdFloat || Conversion<T, void>::sameType };
-
- enum { isUnsignedInt = isStdUnsignedInt || IsCustomUnsignedInt<UnqualifiedType>::value };
- enum { isSignedInt = isStdSignedInt || IsCustomSignedInt<UnqualifiedType>::value };
- enum { isIntegral = isStdIntegral || isUnsignedInt || isSignedInt };
- enum { isFloat = isStdFloat || IsCustomFloat<UnqualifiedType>::value };
- enum { isArith = isIntegral || isFloat };
- enum { isFundamental = isStdFundamental || isArith };
-
- typedef typename Select<isStdArith || isPointer || isMemberPointer, T,
- typename Private::AddParameterType<T>::Result>::Result
- ParameterType;
+ enum { result = false };
+ typedef U ReferredType;
+ };
+
+ template <class U> struct ReferenceTraits<U&>
+ {
+ enum { result = true };
+ typedef U ReferredType;
+ };
+
+ template <class U> struct PointerTraits
+ {
+ enum { result = false };
+ typedef NullType PointeeType;
+ };
+
+ template <class U> struct PointerTraits<U*>
+ {
+ enum { result = true };
+ typedef U PointeeType;
};
+
+ template <class U> struct PointerTraits<U*&>
+ {
+ enum { result = true };
+ typedef U PointeeType;
+ };
+
+ template <class U> struct PToMTraits
+ {
+ enum { result = false };
+ };
+
+ template <class U, class V> struct PToMTraits<U V::*>
+ {
+ enum { result = true };
+ };
+
+ template <class U, class V> struct PToMTraits<U V::*&>
+ {
+ enum { result = true };
+ };
+
+ template <class U> struct FunctionPointerTraits
+ {
+ enum { result = Private::IsFunctionPointerRaw<U>::result };
+ };
+
+ template <typename U> struct PToMFunctionTraits
+ {
+ enum { result = Private::IsMemberFunctionPointerRaw<U>::result };
+ };
+
+ template <class U> struct UnConst
+ {
+ typedef U Result;
+ enum { isConst = 0 };
+ };
+
+ template <class U> struct UnConst<const U>
+ {
+ typedef U Result;
+ enum { isConst = 1 };
+ };
+
+ template <class U> struct UnConst<const U&>
+ {
+ typedef U& Result;
+ enum { isConst = 1 };
+ };
+
+ template <class U> struct UnVolatile
+ {
+ typedef U Result;
+ enum { isVolatile = 0 };
+ };
+
+ template <class U> struct UnVolatile<volatile U>
+ {
+ typedef U Result;
+ enum { isVolatile = 1 };
+ };
+
+ template <class U> struct UnVolatile<volatile U&>
+ {
+ typedef U& Result;
+ enum { isVolatile = 1 };
+ };
+
+public:
+ typedef typename UnConst<T>::Result
+ NonConstType;
+ typedef typename UnVolatile<T>::Result
+ NonVolatileType;
+ typedef typename UnVolatile<typename UnConst<T>::Result>::Result
+ UnqualifiedType;
+ typedef typename PointerTraits<UnqualifiedType>::PointeeType
+ PointeeType;
+ typedef typename ReferenceTraits<T>::ReferredType
+ ReferredType;
+
+ enum { isConst = UnConst<T>::isConst };
+ enum { isVolatile = UnVolatile<T>::isVolatile };
+ enum { isReference = ReferenceTraits<UnqualifiedType>::result };
+ enum { isFunction = FunctionPointerTraits<typename Private::AddPointer<T>::Result >::result };
+ enum { isFunctionPointer= FunctionPointerTraits<
+ typename ReferenceTraits<UnqualifiedType>::ReferredType >::result
+ };
+ enum { isMemberFunctionPointer= PToMFunctionTraits<
+ typename ReferenceTraits<UnqualifiedType>::ReferredType >::result
+ };
+ enum { isMemberPointer = PToMTraits<
+ typename ReferenceTraits<UnqualifiedType>::ReferredType >::result ||
+ isMemberFunctionPointer
+ };
+ enum { isPointer = PointerTraits<
+ typename ReferenceTraits<UnqualifiedType>::ReferredType >::result ||
+ isFunctionPointer
+ };
+
+ enum { isStdUnsignedInt = TL::IndexOf<Private::StdUnsignedInts, UnqualifiedType>::value >= 0 ||
+ TL::IndexOf<Private::StdUnsignedInts,
+ typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0
+ };
+ enum { isStdSignedInt = TL::IndexOf<Private::StdSignedInts, UnqualifiedType>::value >= 0 ||
+ TL::IndexOf<Private::StdSignedInts,
+ typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0
+ };
+ enum { isStdIntegral = isStdUnsignedInt || isStdSignedInt ||
+ TL::IndexOf<Private::StdOtherInts, UnqualifiedType>::value >= 0 ||
+ TL::IndexOf<Private::StdOtherInts,
+ typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0
+ };
+ enum { isStdFloat = TL::IndexOf<Private::StdFloats, UnqualifiedType>::value >= 0 ||
+ TL::IndexOf<Private::StdFloats,
+ typename ReferenceTraits<UnqualifiedType>::ReferredType>::value >= 0
+ };
+ enum { isStdArith = isStdIntegral || isStdFloat };
+ enum { isStdFundamental = isStdArith || isStdFloat || Conversion<T, void>::sameType };
+
+ enum { isUnsignedInt = isStdUnsignedInt || IsCustomUnsignedInt<UnqualifiedType>::value };
+ enum { isSignedInt = isStdSignedInt || IsCustomSignedInt<UnqualifiedType>::value };
+ enum { isIntegral = isStdIntegral || isUnsignedInt || isSignedInt };
+ enum { isFloat = isStdFloat || IsCustomFloat<UnqualifiedType>::value };
+ enum { isArith = isIntegral || isFloat };
+ enum { isFundamental = isStdFundamental || isArith };
+
+ typedef typename Select<isStdArith || isPointer || isMemberPointer, T,
+ typename Private::AddParameterType<T>::Result>::Result
+ ParameterType;
+};
}
#ifdef _MSC_VER
diff --git a/shared/loki/Typelist.h b/shared/loki/Typelist.h
index 6a885927..ba18032f 100644
--- a/shared/loki/Typelist.h
+++ b/shared/loki/Typelist.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Welsey Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Welsey Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_TYPELIST_INC_
@@ -34,17 +34,17 @@ namespace Loki
// Tail (second element, can be another typelist)
////////////////////////////////////////////////////////////////////////////////
- template <class T, class U>
- struct Typelist
- {
- typedef T Head;
- typedef U Tail;
- };
+template <class T, class U>
+struct Typelist
+{
+ typedef T Head;
+ typedef U Tail;
+};
// Typelist utility algorithms
- namespace TL
- {
+namespace TL
+{
////////////////////////////////////////////////////////////////////////////////
// class template MakeTypelist
@@ -54,38 +54,38 @@ namespace Loki
// returns a typelist that is of T1, T2, ...
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename T1 = NullType, typename T2 = NullType, typename T3 = NullType,
- typename T4 = NullType, typename T5 = NullType, typename T6 = NullType,
- typename T7 = NullType, typename T8 = NullType, typename T9 = NullType,
- typename T10 = NullType, typename T11 = NullType, typename T12 = NullType,
- typename T13 = NullType, typename T14 = NullType, typename T15 = NullType,
- typename T16 = NullType, typename T17 = NullType, typename T18 = NullType
- >
- struct MakeTypelist
- {
- private:
- typedef typename MakeTypelist
- <
- T2 , T3 , T4 ,
- T5 , T6 , T7 ,
- T8 , T9 , T10,
- T11, T12, T13,
- T14, T15, T16,
- T17, T18
- >
- ::Result TailResult;
-
- public:
- typedef Typelist<T1, TailResult> Result;
- };
-
- template<>
- struct MakeTypelist<>
- {
- typedef NullType Result;
- };
+template
+<
+typename T1 = NullType, typename T2 = NullType, typename T3 = NullType,
+ typename T4 = NullType, typename T5 = NullType, typename T6 = NullType,
+ typename T7 = NullType, typename T8 = NullType, typename T9 = NullType,
+ typename T10 = NullType, typename T11 = NullType, typename T12 = NullType,
+ typename T13 = NullType, typename T14 = NullType, typename T15 = NullType,
+ typename T16 = NullType, typename T17 = NullType, typename T18 = NullType
+ >
+struct MakeTypelist
+{
+private:
+ typedef typename MakeTypelist
+ <
+ T2 , T3 , T4 ,
+ T5 , T6 , T7 ,
+ T8 , T9 , T10,
+ T11, T12, T13,
+ T14, T15, T16,
+ T17, T18
+ >
+ ::Result TailResult;
+
+public:
+ typedef Typelist<T1, TailResult> Result;
+};
+
+template<>
+struct MakeTypelist<>
+{
+ typedef NullType Result;
+};
////////////////////////////////////////////////////////////////////////////////
// class template Length
@@ -96,73 +96,73 @@ namespace Loki
// the end terminator (which by convention is NullType)
////////////////////////////////////////////////////////////////////////////////
- template <class TList> struct Length;
- template <> struct Length<NullType>
- {
- enum { value = 0 };
- };
-
- template <class T, class U>
- struct Length< Typelist<T, U> >
- {
- enum { value = 1 + Length<U>::value };
- };
+template <class TList> struct Length;
+template <> struct Length<NullType>
+{
+ enum { value = 0 };
+};
+
+template <class T, class U>
+struct Length< Typelist<T, U> >
+{
+ enum { value = 1 + Length<U>::value };
+};
////////////////////////////////////////////////////////////////////////////////
// class template TypeAt
// Finds the type at a given index in a typelist
-// Invocation (TList is a typelist and index is a compile-time integral
+// Invocation (TList is a typelist and index is a compile-time integral
// constant):
// TypeAt<TList, index>::Result
// returns the type in position 'index' in TList
// If you pass an out-of-bounds index, the result is a compile-time error
////////////////////////////////////////////////////////////////////////////////
- template <class TList, unsigned int index> struct TypeAt;
-
- template <class Head, class Tail>
- struct TypeAt<Typelist<Head, Tail>, 0>
- {
- typedef Head Result;
- };
+template <class TList, unsigned int index> struct TypeAt;
+
+template <class Head, class Tail>
+struct TypeAt<Typelist<Head, Tail>, 0>
+{
+ typedef Head Result;
+};
- template <class Head, class Tail, unsigned int i>
- struct TypeAt<Typelist<Head, Tail>, i>
- {
- typedef typename TypeAt<Tail, i - 1>::Result Result;
- };
+template <class Head, class Tail, unsigned int i>
+struct TypeAt<Typelist<Head, Tail>, i>
+{
+ typedef typename TypeAt<Tail, i - 1>::Result Result;
+};
////////////////////////////////////////////////////////////////////////////////
// class template TypeAtNonStrict
// Finds the type at a given index in a typelist
-// Invocations (TList is a typelist and index is a compile-time integral
+// Invocations (TList is a typelist and index is a compile-time integral
// constant):
// a) TypeAt<TList, index>::Result
-// returns the type in position 'index' in TList, or NullType if index is
+// returns the type in position 'index' in TList, or NullType if index is
// out-of-bounds
// b) TypeAt<TList, index, D>::Result
// returns the type in position 'index' in TList, or D if index is out-of-bounds
////////////////////////////////////////////////////////////////////////////////
- template <class TList, unsigned int index,
- typename DefaultType = NullType>
- struct TypeAtNonStrict
- {
- typedef DefaultType Result;
- };
-
- template <class Head, class Tail, typename DefaultType>
- struct TypeAtNonStrict<Typelist<Head, Tail>, 0, DefaultType>
- {
- typedef Head Result;
- };
-
- template <class Head, class Tail, unsigned int i, typename DefaultType>
- struct TypeAtNonStrict<Typelist<Head, Tail>, i, DefaultType>
- {
- typedef typename
- TypeAtNonStrict<Tail, i - 1, DefaultType>::Result Result;
- };
+template <class TList, unsigned int index,
+ typename DefaultType = NullType>
+struct TypeAtNonStrict
+{
+ typedef DefaultType Result;
+};
+
+template <class Head, class Tail, typename DefaultType>
+struct TypeAtNonStrict<Typelist<Head, Tail>, 0, DefaultType>
+{
+ typedef Head Result;
+};
+
+template <class Head, class Tail, unsigned int i, typename DefaultType>
+struct TypeAtNonStrict<Typelist<Head, Tail>, i, DefaultType>
+{
+ typedef typename
+ TypeAtNonStrict<Tail, i - 1, DefaultType>::Result Result;
+};
////////////////////////////////////////////////////////////////////////////////
// class template IndexOf
@@ -172,28 +172,28 @@ namespace Loki
// returns the position of T in TList, or NullType if T is not found in TList
////////////////////////////////////////////////////////////////////////////////
- template <class TList, class T> struct IndexOf;
-
- template <class T>
- struct IndexOf<NullType, T>
- {
- enum { value = -1 };
- };
-
- template <class T, class Tail>
- struct IndexOf<Typelist<T, Tail>, T>
- {
- enum { value = 0 };
- };
-
- template <class Head, class Tail, class T>
- struct IndexOf<Typelist<Head, Tail>, T>
- {
- private:
- enum { temp = IndexOf<Tail, T>::value };
- public:
- enum { value = (temp == -1 ? -1 : 1 + temp) };
- };
+template <class TList, class T> struct IndexOf;
+
+template <class T>
+struct IndexOf<NullType, T>
+{
+ enum { value = -1 };
+};
+
+template <class T, class Tail>
+struct IndexOf<Typelist<T, Tail>, T>
+{
+ enum { value = 0 };
+};
+
+template <class Head, class Tail, class T>
+struct IndexOf<Typelist<Head, Tail>, T>
+{
+private:
+ enum { temp = IndexOf<Tail, T>::value };
+public:
+ enum { value = (temp == -1 ? -1 : 1 + temp) };
+};
////////////////////////////////////////////////////////////////////////////////
// class template Append
@@ -203,32 +203,32 @@ namespace Loki
// returns a typelist that is TList followed by T and NullType-terminated
////////////////////////////////////////////////////////////////////////////////
- template <class TList, class T> struct Append;
-
- template <> struct Append<NullType, NullType>
- {
- typedef NullType Result;
- };
-
- template <class T> struct Append<NullType, T>
- {
- typedef Typelist<T,NullType> Result;
- };
-
- template <class Head, class Tail>
- struct Append<NullType, Typelist<Head, Tail> >
- {
- typedef Typelist<Head, Tail> Result;
- };
-
- template <class Head, class Tail, class T>
- struct Append<Typelist<Head, Tail>, T>
- {
- typedef Typelist<Head,
- typename Append<Tail, T>::Result>
- Result;
- };
-
+template <class TList, class T> struct Append;
+
+template <> struct Append<NullType, NullType>
+{
+ typedef NullType Result;
+};
+
+template <class T> struct Append<NullType, T>
+{
+ typedef Typelist<T,NullType> Result;
+};
+
+template <class Head, class Tail>
+struct Append<NullType, Typelist<Head, Tail> >
+{
+ typedef Typelist<Head, Tail> Result;
+};
+
+template <class Head, class Tail, class T>
+struct Append<Typelist<Head, Tail>, T>
+{
+ typedef Typelist<Head,
+ typename Append<Tail, T>::Result>
+ Result;
+};
+
////////////////////////////////////////////////////////////////////////////////
// class template Erase
// Erases the first occurence, if any, of a type in a typelist
@@ -237,27 +237,27 @@ namespace Loki
// returns a typelist that is TList without the first occurence of T
////////////////////////////////////////////////////////////////////////////////
- template <class TList, class T> struct Erase;
-
- template <class T> // Specialization 1
- struct Erase<NullType, T>
- {
- typedef NullType Result;
- };
+template <class TList, class T> struct Erase;
+
+template <class T> // Specialization 1
+struct Erase<NullType, T>
+{
+ typedef NullType Result;
+};
- template <class T, class Tail> // Specialization 2
- struct Erase<Typelist<T, Tail>, T>
- {
- typedef Tail Result;
- };
+template <class T, class Tail> // Specialization 2
+struct Erase<Typelist<T, Tail>, T>
+{
+ typedef Tail Result;
+};
- template <class Head, class Tail, class T> // Specialization 3
- struct Erase<Typelist<Head, Tail>, T>
- {
- typedef Typelist<Head,
- typename Erase<Tail, T>::Result>
- Result;
- };
+template <class Head, class Tail, class T> // Specialization 3
+struct Erase<Typelist<Head, Tail>, T>
+{
+ typedef Typelist<Head,
+ typename Erase<Tail, T>::Result>
+ Result;
+};
////////////////////////////////////////////////////////////////////////////////
// class template EraseAll
@@ -267,26 +267,26 @@ namespace Loki
// returns a typelist that is TList without any occurence of T
////////////////////////////////////////////////////////////////////////////////
- template <class TList, class T> struct EraseAll;
- template <class T>
- struct EraseAll<NullType, T>
- {
- typedef NullType Result;
- };
- template <class T, class Tail>
- struct EraseAll<Typelist<T, Tail>, T>
- {
- // Go all the way down the list removing the type
- typedef typename EraseAll<Tail, T>::Result Result;
- };
- template <class Head, class Tail, class T>
- struct EraseAll<Typelist<Head, Tail>, T>
- {
- // Go all the way down the list removing the type
- typedef Typelist<Head,
- typename EraseAll<Tail, T>::Result>
- Result;
- };
+template <class TList, class T> struct EraseAll;
+template <class T>
+struct EraseAll<NullType, T>
+{
+ typedef NullType Result;
+};
+template <class T, class Tail>
+struct EraseAll<Typelist<T, Tail>, T>
+{
+ // Go all the way down the list removing the type
+ typedef typename EraseAll<Tail, T>::Result Result;
+};
+template <class Head, class Tail, class T>
+struct EraseAll<Typelist<Head, Tail>, T>
+{
+ // Go all the way down the list removing the type
+ typedef Typelist<Head,
+ typename EraseAll<Tail, T>::Result>
+ Result;
+};
////////////////////////////////////////////////////////////////////////////////
// class template NoDuplicates
@@ -295,22 +295,22 @@ namespace Loki
// NoDuplicates<TList, T>::Result
////////////////////////////////////////////////////////////////////////////////
- template <class TList> struct NoDuplicates;
-
- template <> struct NoDuplicates<NullType>
- {
- typedef NullType Result;
- };
+template <class TList> struct NoDuplicates;
+
+template <> struct NoDuplicates<NullType>
+{
+ typedef NullType Result;
+};
- template <class Head, class Tail>
- struct NoDuplicates< Typelist<Head, Tail> >
- {
- private:
- typedef typename NoDuplicates<Tail>::Result L1;
- typedef typename Erase<L1, Head>::Result L2;
- public:
- typedef Typelist<Head, L2> Result;
- };
+template <class Head, class Tail>
+struct NoDuplicates< Typelist<Head, Tail> >
+{
+private:
+ typedef typename NoDuplicates<Tail>::Result L1;
+ typedef typename Erase<L1, Head>::Result L2;
+public:
+ typedef Typelist<Head, L2> Result;
+};
////////////////////////////////////////////////////////////////////////////////
// class template Replace
@@ -320,27 +320,27 @@ namespace Loki
// returns a typelist in which the first occurence of T is replaced with U
////////////////////////////////////////////////////////////////////////////////
- template <class TList, class T, class U> struct Replace;
-
- template <class T, class U>
- struct Replace<NullType, T, U>
- {
- typedef NullType Result;
- };
+template <class TList, class T, class U> struct Replace;
- template <class T, class Tail, class U>
- struct Replace<Typelist<T, Tail>, T, U>
- {
- typedef Typelist<U, Tail> Result;
- };
+template <class T, class U>
+struct Replace<NullType, T, U>
+{
+ typedef NullType Result;
+};
+
+template <class T, class Tail, class U>
+struct Replace<Typelist<T, Tail>, T, U>
+{
+ typedef Typelist<U, Tail> Result;
+};
- template <class Head, class Tail, class T, class U>
- struct Replace<Typelist<Head, Tail>, T, U>
- {
- typedef Typelist<Head,
- typename Replace<Tail, T, U>::Result>
- Result;
- };
+template <class Head, class Tail, class T, class U>
+struct Replace<Typelist<Head, Tail>, T, U>
+{
+ typedef Typelist<Head,
+ typename Replace<Tail, T, U>::Result>
+ Result;
+};
////////////////////////////////////////////////////////////////////////////////
// class template ReplaceAll
@@ -350,27 +350,27 @@ namespace Loki
// returns a typelist in which all occurences of T is replaced with U
////////////////////////////////////////////////////////////////////////////////
- template <class TList, class T, class U> struct ReplaceAll;
-
- template <class T, class U>
- struct ReplaceAll<NullType, T, U>
- {
- typedef NullType Result;
- };
-
- template <class T, class Tail, class U>
- struct ReplaceAll<Typelist<T, Tail>, T, U>
- {
- typedef Typelist<U, typename ReplaceAll<Tail, T, U>::Result> Result;
- };
-
- template <class Head, class Tail, class T, class U>
- struct ReplaceAll<Typelist<Head, Tail>, T, U>
- {
- typedef Typelist<Head,
- typename ReplaceAll<Tail, T, U>::Result>
- Result;
- };
+template <class TList, class T, class U> struct ReplaceAll;
+
+template <class T, class U>
+struct ReplaceAll<NullType, T, U>
+{
+ typedef NullType Result;
+};
+
+template <class T, class Tail, class U>
+struct ReplaceAll<Typelist<T, Tail>, T, U>
+{
+ typedef Typelist<U, typename ReplaceAll<Tail, T, U>::Result> Result;
+};
+
+template <class Head, class Tail, class T, class U>
+struct ReplaceAll<Typelist<Head, Tail>, T, U>
+{
+ typedef Typelist<Head,
+ typename ReplaceAll<Tail, T, U>::Result>
+ Result;
+};
////////////////////////////////////////////////////////////////////////////////
// class template Reverse
@@ -380,20 +380,20 @@ namespace Loki
// returns a typelist that is TList reversed
////////////////////////////////////////////////////////////////////////////////
- template <class TList> struct Reverse;
-
- template <>
- struct Reverse<NullType>
- {
- typedef NullType Result;
- };
-
- template <class Head, class Tail>
- struct Reverse< Typelist<Head, Tail> >
- {
- typedef typename Append<
- typename Reverse<Tail>::Result, Head>::Result Result;
- };
+template <class TList> struct Reverse;
+
+template <>
+struct Reverse<NullType>
+{
+ typedef NullType Result;
+};
+
+template <class Head, class Tail>
+struct Reverse< Typelist<Head, Tail> >
+{
+ typedef typename Append<
+ typename Reverse<Tail>::Result, Head>::Result Result;
+};
////////////////////////////////////////////////////////////////////////////////
// class template MostDerived
@@ -403,55 +403,55 @@ namespace Loki
// returns the type in TList that's the most derived from T
////////////////////////////////////////////////////////////////////////////////
- template <class TList, class T> struct MostDerived;
-
- template <class T>
- struct MostDerived<NullType, T>
- {
- typedef T Result;
- };
-
- template <class Head, class Tail, class T>
- struct MostDerived<Typelist<Head, Tail>, T>
- {
- private:
- typedef typename MostDerived<Tail, T>::Result Candidate;
- public:
- typedef typename Select<
- SuperSubclass<Candidate,Head>::value,
- Head, Candidate>::Result Result;
- };
+template <class TList, class T> struct MostDerived;
+
+template <class T>
+struct MostDerived<NullType, T>
+{
+ typedef T Result;
+};
+
+template <class Head, class Tail, class T>
+struct MostDerived<Typelist<Head, Tail>, T>
+{
+private:
+ typedef typename MostDerived<Tail, T>::Result Candidate;
+public:
+ typedef typename Select<
+ SuperSubclass<Candidate,Head>::value,
+ Head, Candidate>::Result Result;
+};
////////////////////////////////////////////////////////////////////////////////
// class template DerivedToFront
// Arranges the types in a typelist so that the most derived types appear first
// Invocation (TList is a typelist):
// DerivedToFront<TList>::Result
-// returns the reordered TList
-////////////////////////////////////////////////////////////////////////////////
-
- template <class TList> struct DerivedToFront;
-
- template <>
- struct DerivedToFront<NullType>
- {
- typedef NullType Result;
- };
-
- template <class Head, class Tail>
- struct DerivedToFront< Typelist<Head, Tail> >
- {
- private:
- typedef typename MostDerived<Tail, Head>::Result
- TheMostDerived;
- typedef typename Replace<Tail,
- TheMostDerived, Head>::Result Temp;
- typedef typename DerivedToFront<Temp>::Result L;
- public:
- typedef Typelist<TheMostDerived, L> Result;
- };
-
- } // namespace TL
+// returns the reordered TList
+////////////////////////////////////////////////////////////////////////////////
+
+template <class TList> struct DerivedToFront;
+
+template <>
+struct DerivedToFront<NullType>
+{
+ typedef NullType Result;
+};
+
+template <class Head, class Tail>
+struct DerivedToFront< Typelist<Head, Tail> >
+{
+private:
+ typedef typename MostDerived<Tail, Head>::Result
+ TheMostDerived;
+ typedef typename Replace<Tail,
+ TheMostDerived, Head>::Result Temp;
+ typedef typename DerivedToFront<Temp>::Result L;
+public:
+ typedef Typelist<TheMostDerived, L> Result;
+};
+
+} // namespace TL
} // namespace Loki
diff --git a/shared/loki/TypelistMacros.h b/shared/loki/TypelistMacros.h
index 6c14b348..1c3c3e63 100644
--- a/shared/loki/TypelistMacros.h
+++ b/shared/loki/TypelistMacros.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Welsey Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Welsey Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_TYPELISTMACROS_INC_
@@ -24,7 +24,7 @@
////////////////////////////////////////////////////////////////////////////////
// macros LOKI_TYPELIST_1, LOKI_TYPELIST_2, ... LOKI_TYPELIST_50
// Each takes a number of arguments equal to its numeric suffix
-// The arguments are type names. LOKI_TYPELIST_NN generates a typelist containing
+// The arguments are type names. LOKI_TYPELIST_NN generates a typelist containing
// all types passed as arguments, in that order.
// Example: LOKI_TYPELIST_2(char, int) generates a type containing char and int.
////////////////////////////////////////////////////////////////////////////////
diff --git a/shared/loki/Visitor.h b/shared/loki/Visitor.h
index 4425a9fa..f6b0ad81 100644
--- a/shared/loki/Visitor.h
+++ b/shared/loki/Visitor.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_VISITOR_INC_
@@ -28,17 +28,17 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
/// \class BaseVisitor
-///
+///
/// \ingroup VisitorGroup
/// The base class of any Acyclic Visitor
////////////////////////////////////////////////////////////////////////////////
- class BaseVisitor
- {
- public:
- virtual ~BaseVisitor() {}
- };
-
+class BaseVisitor
+{
+public:
+ virtual ~BaseVisitor() {}
+};
+
////////////////////////////////////////////////////////////////////////////////
/// \class Visitor
///
@@ -48,7 +48,7 @@ namespace Loki
/// \par Usage
///
/// Defining the visitable class:
-///
+///
/// \code
/// class RasterBitmap : public BaseVisitable<>
/// {
@@ -59,7 +59,7 @@ namespace Loki
///
/// Way 1 to define a visitor:
/// \code
-/// class SomeVisitor :
+/// class SomeVisitor :
/// public BaseVisitor // required
/// public Visitor<RasterBitmap>,
/// public Visitor<Paragraph>
@@ -72,7 +72,7 @@ namespace Loki
///
/// Way 2 to define the visitor:
/// \code
-/// class SomeVisitor :
+/// class SomeVisitor :
/// public BaseVisitor // required
/// public Visitor<LOKI_TYPELIST_2(RasterBitmap, Paragraph)>
/// {
@@ -84,7 +84,7 @@ namespace Loki
///
/// Way 3 to define the visitor:
/// \code
-/// class SomeVisitor :
+/// class SomeVisitor :
/// public BaseVisitor // required
/// public Visitor<Seq<RasterBitmap, Paragraph>::Type>
/// {
@@ -97,7 +97,7 @@ namespace Loki
/// \par Using const visit functions:
///
/// Defining the visitable class (true for const):
-///
+///
/// \code
/// class RasterBitmap : public BaseVisitable<void, DefaultCatchAll, true>
/// {
@@ -108,7 +108,7 @@ namespace Loki
///
/// Defining the visitor which only calls const member functions:
/// \code
-/// class SomeVisitor :
+/// class SomeVisitor :
/// public BaseVisitor // required
/// public Visitor<RasterBitmap, void, true>,
/// {
@@ -119,38 +119,38 @@ namespace Loki
///
/// \par Example:
///
-/// test/Visitor/main.cpp
+/// test/Visitor/main.cpp
////////////////////////////////////////////////////////////////////////////////
- template <class T, typename R = void, bool ConstVisit = false>
- class Visitor;
+template <class T, typename R = void, bool ConstVisit = false>
+class Visitor;
- template <class T, typename R>
- class Visitor<T, R, false>
- {
- public:
- typedef R ReturnType;
- typedef T ParamType;
- virtual ~Visitor() {}
- virtual ReturnType Visit(ParamType&) = 0;
- };
-
- template <class T, typename R>
- class Visitor<T, R, true>
- {
- public:
- typedef R ReturnType;
- typedef const T ParamType;
- virtual ~Visitor() {}
- virtual ReturnType Visit(ParamType&) = 0;
- };
+template <class T, typename R>
+class Visitor<T, R, false>
+{
+public:
+ typedef R ReturnType;
+ typedef T ParamType;
+ virtual ~Visitor() {}
+ virtual ReturnType Visit(ParamType&) = 0;
+};
+
+template <class T, typename R>
+class Visitor<T, R, true>
+{
+public:
+ typedef R ReturnType;
+ typedef const T ParamType;
+ virtual ~Visitor() {}
+ virtual ReturnType Visit(ParamType&) = 0;
+};
////////////////////////////////////////////////////////////////////////////////
// class template Visitor (specialization)
// This specialization is not present in the book. It makes it easier to define
// Visitors for multiple types in a shot by using a typelist. Example:
//
-// class SomeVisitor :
+// class SomeVisitor :
// public BaseVisitor // required
// public Visitor<LOKI_TYPELIST_2(RasterBitmap, Paragraph)>
// {
@@ -160,41 +160,41 @@ namespace Loki
// };
////////////////////////////////////////////////////////////////////////////////
- template <class Head, class Tail, typename R>
- class Visitor<Typelist<Head, Tail>, R, false>
- : public Visitor<Head, R, false>, public Visitor<Tail, R, false>
- {
- public:
- typedef R ReturnType;
- // using Visitor<Head, R>::Visit;
- // using Visitor<Tail, R>::Visit;
- };
-
- template <class Head, typename R>
- class Visitor<Typelist<Head, NullType>, R, false> : public Visitor<Head, R, false>
- {
- public:
- typedef R ReturnType;
- using Visitor<Head, R, false>::Visit;
- };
-
- template <class Head, class Tail, typename R>
- class Visitor<Typelist<Head, Tail>, R, true>
- : public Visitor<Head, R, true>, public Visitor<Tail, R, true>
- {
- public:
- typedef R ReturnType;
- // using Visitor<Head, R>::Visit;
- // using Visitor<Tail, R>::Visit;
- };
-
- template <class Head, typename R>
- class Visitor<Typelist<Head, NullType>, R, true> : public Visitor<Head, R, true>
- {
- public:
- typedef R ReturnType;
- using Visitor<Head, R, true>::Visit;
- };
+template <class Head, class Tail, typename R>
+class Visitor<Typelist<Head, Tail>, R, false>
+ : public Visitor<Head, R, false>, public Visitor<Tail, R, false>
+{
+public:
+ typedef R ReturnType;
+ // using Visitor<Head, R>::Visit;
+ // using Visitor<Tail, R>::Visit;
+};
+
+template <class Head, typename R>
+class Visitor<Typelist<Head, NullType>, R, false> : public Visitor<Head, R, false>
+{
+public:
+ typedef R ReturnType;
+ using Visitor<Head, R, false>::Visit;
+};
+
+template <class Head, class Tail, typename R>
+class Visitor<Typelist<Head, Tail>, R, true>
+ : public Visitor<Head, R, true>, public Visitor<Tail, R, true>
+{
+public:
+ typedef R ReturnType;
+ // using Visitor<Head, R>::Visit;
+ // using Visitor<Tail, R>::Visit;
+};
+
+template <class Head, typename R>
+class Visitor<Typelist<Head, NullType>, R, true> : public Visitor<Head, R, true>
+{
+public:
+ typedef R ReturnType;
+ using Visitor<Head, R, true>::Visit;
+};
////////////////////////////////////////////////////////////////////////////////
@@ -203,29 +203,29 @@ namespace Loki
// functions)
////////////////////////////////////////////////////////////////////////////////
- template <class TList, typename R = void> class BaseVisitorImpl;
+template <class TList, typename R = void> class BaseVisitorImpl;
+
+template <class Head, class Tail, typename R>
+class BaseVisitorImpl<Typelist<Head, Tail>, R>
+ : public Visitor<Head, R>
+ , public BaseVisitorImpl<Tail, R>
+{
+public:
+ // using BaseVisitorImpl<Tail, R>::Visit;
+
+ virtual R Visit(Head&)
+ { return R(); }
+};
+
+template <class Head, typename R>
+class BaseVisitorImpl<Typelist<Head, NullType>, R>
+ : public Visitor<Head, R>
+{
+public:
+ virtual R Visit(Head&)
+ { return R(); }
+};
- template <class Head, class Tail, typename R>
- class BaseVisitorImpl<Typelist<Head, Tail>, R>
- : public Visitor<Head, R>
- , public BaseVisitorImpl<Tail, R>
- {
- public:
- // using BaseVisitorImpl<Tail, R>::Visit;
-
- virtual R Visit(Head&)
- { return R(); }
- };
-
- template <class Head, typename R>
- class BaseVisitorImpl<Typelist<Head, NullType>, R>
- : public Visitor<Head, R>
- {
- public:
- virtual R Visit(Head&)
- { return R(); }
- };
-
////////////////////////////////////////////////////////////////////////////////
// class template BaseVisitable
////////////////////////////////////////////////////////////////////////////////
@@ -241,61 +241,61 @@ struct DefaultCatchAll
// class template BaseVisitable
////////////////////////////////////////////////////////////////////////////////
- template
- <
- typename R = void,
- template <typename, class> class CatchAll = DefaultCatchAll,
- bool ConstVisitable = false
- >
- class BaseVisitable;
+template
+<
+typename R = void,
+ template <typename, class> class CatchAll = DefaultCatchAll,
+ bool ConstVisitable = false
+ >
+class BaseVisitable;
- template<typename R,template <typename, class> class CatchAll>
- class BaseVisitable<R, CatchAll, false>
+template<typename R,template <typename, class> class CatchAll>
+class BaseVisitable<R, CatchAll, false>
+{
+public:
+ typedef R ReturnType;
+ virtual ~BaseVisitable() {}
+ virtual ReturnType Accept(BaseVisitor&) = 0;
+
+protected: // give access only to the hierarchy
+ template <class T>
+ static ReturnType AcceptImpl(T& visited, BaseVisitor& guest)
{
- public:
- typedef R ReturnType;
- virtual ~BaseVisitable() {}
- virtual ReturnType Accept(BaseVisitor&) = 0;
-
- protected: // give access only to the hierarchy
- template <class T>
- static ReturnType AcceptImpl(T& visited, BaseVisitor& guest)
+ // Apply the Acyclic Visitor
+ if (Visitor<T,R>* p = dynamic_cast<Visitor<T,R>*>(&guest))
{
- // Apply the Acyclic Visitor
- if (Visitor<T,R>* p = dynamic_cast<Visitor<T,R>*>(&guest))
- {
- return p->Visit(visited);
- }
- return CatchAll<R, T>::OnUnknownVisitor(visited, guest);
+ return p->Visit(visited);
}
- };
+ return CatchAll<R, T>::OnUnknownVisitor(visited, guest);
+ }
+};
- template<typename R,template <typename, class> class CatchAll>
- class BaseVisitable<R, CatchAll, true>
+template<typename R,template <typename, class> class CatchAll>
+class BaseVisitable<R, CatchAll, true>
+{
+public:
+ typedef R ReturnType;
+ virtual ~BaseVisitable() {}
+ virtual ReturnType Accept(BaseVisitor&) const = 0;
+
+protected: // give access only to the hierarchy
+ template <class T>
+ static ReturnType AcceptImpl(const T& visited, BaseVisitor& guest)
{
- public:
- typedef R ReturnType;
- virtual ~BaseVisitable() {}
- virtual ReturnType Accept(BaseVisitor&) const = 0;
-
- protected: // give access only to the hierarchy
- template <class T>
- static ReturnType AcceptImpl(const T& visited, BaseVisitor& guest)
+ // Apply the Acyclic Visitor
+ if (Visitor<T,R,true>* p = dynamic_cast<Visitor<T,R,true>*>(&guest))
{
- // Apply the Acyclic Visitor
- if (Visitor<T,R,true>* p = dynamic_cast<Visitor<T,R,true>*>(&guest))
- {
- return p->Visit(visited);
- }
- return CatchAll<R, T>::OnUnknownVisitor(const_cast<T&>(visited), guest);
+ return p->Visit(visited);
}
- };
+ return CatchAll<R, T>::OnUnknownVisitor(const_cast<T&>(visited), guest);
+ }
+};
////////////////////////////////////////////////////////////////////////////////
/// \def LOKI_DEFINE_VISITABLE()
/// \ingroup VisitorGroup
-/// Put it in every class that you want to make visitable
+/// Put it in every class that you want to make visitable
/// (in addition to deriving it from BaseVisitable<R>)
////////////////////////////////////////////////////////////////////////////////
@@ -306,7 +306,7 @@ struct DefaultCatchAll
////////////////////////////////////////////////////////////////////////////////
/// \def LOKI_DEFINE_CONST_VISITABLE()
/// \ingroup VisitorGroup
-/// Put it in every class that you want to make visitable by const member
+/// Put it in every class that you want to make visitable by const member
/// functions (in addition to deriving it from BaseVisitable<R>)
////////////////////////////////////////////////////////////////////////////////
@@ -318,25 +318,25 @@ struct DefaultCatchAll
/// \class CyclicVisitor
///
/// \ingroup VisitorGroup
-/// Put it in every class that you want to make visitable (in addition to
+/// Put it in every class that you want to make visitable (in addition to
/// deriving it from BaseVisitable<R>
////////////////////////////////////////////////////////////////////////////////
- template <typename R, class TList>
- class CyclicVisitor : public Visitor<TList, R>
+template <typename R, class TList>
+class CyclicVisitor : public Visitor<TList, R>
+{
+public:
+ typedef R ReturnType;
+ // using Visitor<TList, R>::Visit;
+
+ template <class Visited>
+ ReturnType GenericVisit(Visited& host)
{
- public:
- typedef R ReturnType;
- // using Visitor<TList, R>::Visit;
-
- template <class Visited>
- ReturnType GenericVisit(Visited& host)
- {
- Visitor<Visited, ReturnType>& subObj = *this;
- return subObj.Visit(host);
- }
- };
-
+ Visitor<Visited, ReturnType>& subObj = *this;
+ return subObj.Visit(host);
+ }
+};
+
////////////////////////////////////////////////////////////////////////////////
/// \def LOKI_DEFINE_CYCLIC_VISITABLE(SomeVisitor)
/// \ingroup VisitorGroup
diff --git a/shared/loki/static_check.h b/shared/loki/static_check.h
index 51ce389e..b4c455c9 100644
--- a/shared/loki/static_check.h
+++ b/shared/loki/static_check.h
@@ -2,14 +2,14 @@
// The Loki Library
// Copyright (c) 2001 by Andrei Alexandrescu
// This code accompanies the book:
-// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
+// Alexandrescu, Andrei. "Modern C++ Design: Generic Programming and Design
// Patterns Applied". Copyright (c) 2001. Addison-Wesley.
-// Permission to use, copy, modify, distribute and sell this software for any
-// purpose is hereby granted without fee, provided that the above copyright
-// notice appear in all copies and that both that copyright notice and this
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
// permission notice appear in supporting documentation.
-// The author or Addison-Wesley Longman make no representations about the
-// suitability of this software for any purpose. It is provided "as is"
+// The author or Addison-Wesley Longman make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
// without express or implied warranty.
////////////////////////////////////////////////////////////////////////////////
#ifndef LOKI_STATIC_CHECK_INC_
@@ -24,8 +24,8 @@ namespace Loki
// Helper structure for the STATIC_CHECK macro
////////////////////////////////////////////////////////////////////////////////
- template<int> struct CompileTimeError;
- template<> struct CompileTimeError<true> {};
+template<int> struct CompileTimeError;
+template<> struct CompileTimeError<true> {};
}
////////////////////////////////////////////////////////////////////////////////
@@ -38,7 +38,7 @@ namespace Loki
////////////////////////////////////////////////////////////////////////////////
#define LOKI_STATIC_CHECK(expr, msg) \
- { Loki::CompileTimeError<((expr) != 0)> ERROR_##msg; (void)ERROR_##msg; }
+ { Loki::CompileTimeError<((expr) != 0)> ERROR_##msg; (void)ERROR_##msg; }
#endif // end file guardian
bgstack15