0cc9d96483be0783055bfcfbfffbc4610a1c8f6f
[platform/upstream/boost.git] / libs / intrusive / test / common_functors.hpp
1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga  2006-2012
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/utilities.hpp>
17 #include<boost/intrusive/detail/mpl.hpp>
18
19 namespace boost      {
20 namespace intrusive  {
21 namespace test       {
22
23 template<class T>
24 class delete_disposer
25 {
26    public:
27    template <class Pointer>
28       void operator()(Pointer p)
29    {
30       typedef typename std::iterator_traits<Pointer>::value_type value_type;
31       BOOST_INTRUSIVE_INVARIANT_ASSERT(( detail::is_same<T, value_type>::value ));
32       delete boost::intrusive::detail::to_raw_pointer(p);
33    }
34 };
35
36 template<class T>
37 class new_cloner
38 {
39    public:
40       T *operator()(const T &t)
41    {  return new T(t);  }
42 };
43
44 template<class T>
45 class new_default_factory
46 {
47    public:
48       T *operator()()
49    {  return new T();  }
50 };
51
52 }  //namespace test       {
53 }  //namespace intrusive  {
54 }  //namespace boost      {
55
56 #endif