--- /dev/null
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// (C) Copyright Joaquín M López Muñoz 2006-2007\r
+//\r
+// Distributed under the Boost Software License, Version 1.0.\r
+// (See accompanying file LICENSE_1_0.txt or copy at\r
+// http://www.boost.org/LICENSE_1_0.txt)\r
+//\r
+// See http://www.boost.org/libs/intrusive for documentation.\r
+//\r
+/////////////////////////////////////////////////////////////////////////////\r
+#include <boost/type_traits/is_empty.hpp>\r
+\r
+namespace boost {\r
+namespace intrusive {\r
+namespace detail {\r
+\r
+template<typename T, bool IsEmpty = false>\r
+class ebo_holder_impl\r
+{\r
+ public:\r
+ ebo_holder_impl(){}\r
+ ebo_holder_impl(const T& t):t(t){}\r
+\r
+ T& get(){return t;}\r
+ const T& get()const{return t;}\r
+\r
+ private:\r
+ T t;\r
+};\r
+\r
+template<typename T>\r
+class ebo_holder_impl<T, true>\r
+ : private T\r
+{\r
+ public:\r
+ ebo_holder_impl(){}\r
+ ebo_holder_impl(const T& t):T(t){}\r
+\r
+ T& get(){return *this;}\r
+ const T& get()const{return *this;}\r
+};\r
+\r
+template<typename T>\r
+class ebo_holder\r
+ : public ebo_holder_impl<T,boost::is_empty<T>::value>\r
+{\r
+ private:\r
+ typedef ebo_holder_impl<T,boost::is_empty<T>::value> super;\r
+\r
+ public:\r
+ ebo_holder(){}\r
+ ebo_holder(const T& t):super(t){}\r
+\r
+ ebo_holder& operator=(const ebo_holder& x)\r
+ {\r
+ this->get()=x.get();\r
+ return *this;\r
+ }\r
+};\r
+\r
+\r
+} //namespace detail {\r
+} //namespace intrusive {\r
+} //namespace boost {\r
+\r
+/*\r
+\r
+// testing\r
+\r
+#include <boost/assert.hpp>\r
+#include <string>\r
+\r
+struct empty_member{};\r
+\r
+struct foo:public ebo_holder<empty_member>\r
+{\r
+ int x;\r
+};\r
+\r
+int main()\r
+{\r
+ ebo_holder<int> ei=5;\r
+ BOOST_ASSERT(ei.get()==5);\r
+ ei=6;\r
+ BOOST_ASSERT(ei.get()==6);\r
+\r
+ ebo_holder<std::string> es("hello");\r
+ BOOST_ASSERT(es.get()=="hello");\r
+ es=std::string("bye");\r
+ BOOST_ASSERT(es.get()=="bye");\r
+\r
+ BOOST_ASSERT(sizeof(foo)==sizeof(int)); // if EBO applies\r
+}\r
+*/\r