1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Joaquin M Lopez Munoz  2006-2009
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_DETAIL_EBO_HOLDER_HPP
14 #define BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
15 
16 #include <boost/intrusive/detail/config_begin.hpp>
17 #include <boost/intrusive/detail/mpl.hpp>
18 
19 namespace boost {
20 namespace intrusive {
21 namespace detail {
22 
23 template<typename T, bool IsEmpty = true>
24 class ebo_functor_holder_impl
25 {
26    public:
ebo_functor_holder_impl()27    ebo_functor_holder_impl()
28    {}
ebo_functor_holder_impl(const T & t)29    ebo_functor_holder_impl(const T& t)
30       :  t_(t)
31    {}
32    template<class Arg1, class Arg2>
ebo_functor_holder_impl(const Arg1 & arg1,const Arg2 & arg2)33    ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2)
34       :  t_(arg1, arg2)
35    {}
36 
get()37    T&       get(){return t_;}
get() const38    const T& get()const{return t_;}
39 
40    private:
41    T t_;
42 };
43 
44 template<typename T>
45 class ebo_functor_holder_impl<T, false>
46    :  public T
47 {
48    public:
ebo_functor_holder_impl()49    ebo_functor_holder_impl()
50    {}
ebo_functor_holder_impl(const T & t)51    ebo_functor_holder_impl(const T& t)
52       :  T(t)
53    {}
54    template<class Arg1, class Arg2>
ebo_functor_holder_impl(const Arg1 & arg1,const Arg2 & arg2)55    ebo_functor_holder_impl(const Arg1& arg1, const Arg2& arg2)
56       :  T(arg1, arg2)
57    {}
58 
get()59    T&       get(){return *this;}
get() const60    const T& get()const{return *this;}
61 };
62 
63 template<typename T>
64 class ebo_functor_holder
65    :  public ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value>
66 {
67    private:
68    typedef ebo_functor_holder_impl<T, is_unary_or_binary_function<T>::value> super;
69 
70    public:
ebo_functor_holder()71    ebo_functor_holder(){}
ebo_functor_holder(const T & t)72    ebo_functor_holder(const T& t)
73       :  super(t)
74    {}
75 
76    template<class Arg1, class Arg2>
ebo_functor_holder(const Arg1 & arg1,const Arg2 & arg2)77    ebo_functor_holder(const Arg1& arg1, const Arg2& arg2)
78       :  super(arg1, arg2)
79    {}
80 
operator =(const ebo_functor_holder & x)81    ebo_functor_holder& operator=(const ebo_functor_holder& x)
82    {
83       this->get()=x.get();
84       return *this;
85    }
86 };
87 
88 
89 }  //namespace detail {
90 }  //namespace intrusive {
91 }  //namespace boost {
92 
93 #include <boost/intrusive/detail/config_end.hpp>
94 
95 #endif   //#ifndef BOOST_INTRUSIVE_DETAIL_EBO_HOLDER_HPP
96