X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2Fboost_intrusive%2Fdetail%2Febo_holder.hpp;fp=senf%2Fboost_intrusive%2Fdetail%2Febo_holder.hpp;h=29e77256829240fca14b5557464e5c39eed42b8a;hb=8f1ff66f5b7d10cfc6d35fb72267bc2fb3b588f7;hp=0000000000000000000000000000000000000000;hpb=fbd3d0ff298683f08b59f25288d8c243e03b206c;p=senf.git diff --git a/senf/boost_intrusive/detail/ebo_holder.hpp b/senf/boost_intrusive/detail/ebo_holder.hpp new file mode 100644 index 0000000..29e7725 --- /dev/null +++ b/senf/boost_intrusive/detail/ebo_holder.hpp @@ -0,0 +1,95 @@ +///////////////////////////////////////////////////////////////////////////// +// +// (C) Copyright Joaquín M López Muñoz 2006-2007 +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// +// See http://www.boost.org/libs/intrusive for documentation. +// +///////////////////////////////////////////////////////////////////////////// +#include + +namespace boost { +namespace intrusive { +namespace detail { + +template +class ebo_holder_impl +{ + public: + ebo_holder_impl(){} + ebo_holder_impl(const T& t):t(t){} + + T& get(){return t;} + const T& get()const{return t;} + + private: + T t; +}; + +template +class ebo_holder_impl + : private T +{ + public: + ebo_holder_impl(){} + ebo_holder_impl(const T& t):T(t){} + + T& get(){return *this;} + const T& get()const{return *this;} +}; + +template +class ebo_holder + : public ebo_holder_impl::value> +{ + private: + typedef ebo_holder_impl::value> super; + + public: + ebo_holder(){} + ebo_holder(const T& t):super(t){} + + ebo_holder& operator=(const ebo_holder& x) + { + this->get()=x.get(); + return *this; + } +}; + + +} //namespace detail { +} //namespace intrusive { +} //namespace boost { + +/* + +// testing + +#include +#include + +struct empty_member{}; + +struct foo:public ebo_holder +{ + int x; +}; + +int main() +{ + ebo_holder ei=5; + BOOST_ASSERT(ei.get()==5); + ei=6; + BOOST_ASSERT(ei.get()==6); + + ebo_holder es("hello"); + BOOST_ASSERT(es.get()=="hello"); + es=std::string("bye"); + BOOST_ASSERT(es.get()=="bye"); + + BOOST_ASSERT(sizeof(foo)==sizeof(int)); // if EBO applies +} +*/