1 ///////////////////////////////////////////////////////////////////////////// 2 // 3 // (C) Copyright Ion Gaztanaga 2006-2013 4 // 5 // Distributed under the Boost Software License, Version 1.0. 6 // (See accompanying file LICENSE_1_0.txt or copy at 7 // http://www.boost.org/LICENSE_1_0.txt) 8 // 9 // See http://www.boost.org/libs/intrusive for documentation. 10 // 11 ///////////////////////////////////////////////////////////////////////////// 12 13 #ifndef BOOST_INTRUSIVE_TEST_COMMON_FUNCTORS_HPP 14 #define BOOST_INTRUSIVE_TEST_COMMON_FUNCTORS_HPP 15 16 #include<boost/intrusive/detail/iterator.hpp> 17 #include<boost/intrusive/detail/mpl.hpp> 18 #include<boost/static_assert.hpp> 19 #include<boost/move/detail/to_raw_pointer.hpp> 20 21 namespace boost { 22 namespace intrusive { 23 namespace test { 24 25 template<class T> 26 class delete_disposer 27 { 28 public: 29 template <class Pointer> operator ()(Pointer p)30 void operator()(Pointer p) 31 { 32 typedef typename boost::intrusive::iterator_traits<Pointer>::value_type value_type; 33 BOOST_STATIC_ASSERT(( detail::is_same<T, value_type>::value )); 34 delete boost::movelib::to_raw_pointer(p); 35 } 36 }; 37 38 template<class T> 39 class new_cloner 40 { 41 public: operator ()(const T & t)42 T *operator()(const T &t) 43 { return new T(t); } 44 }; 45 46 template<class T> 47 class new_nonconst_cloner 48 { 49 public: operator ()(T & t)50 T *operator()(T &t) 51 { return new T(t); } 52 }; 53 54 template<class T> 55 class new_default_factory 56 { 57 public: operator ()()58 T *operator()() 59 { return new T(); } 60 }; 61 62 class empty_disposer 63 { 64 public: 65 template<class T> operator ()(const T &)66 void operator()(const T &) 67 {} 68 }; 69 70 struct any_less 71 { 72 template<class T, class U> operator ()boost::intrusive::test::any_less73 bool operator()(const T &t, const U &u) const 74 { return t < u; } 75 }; 76 77 struct any_greater 78 { 79 template<class T, class U> operator ()boost::intrusive::test::any_greater80 bool operator()(const T &t, const U &u) const 81 { return t > u; } 82 }; 83 84 } //namespace test { 85 } //namespace intrusive { 86 } //namespace boost { 87 88 #endif 89