summaryrefslogtreecommitdiff
path: root/boost/intrusive/detail/pointer_element.hpp
diff options
context:
space:
mode:
authorChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
committerChanho Park <chanho61.park@samsung.com>2014-12-11 18:55:56 +0900
commit08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch)
tree7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/intrusive/detail/pointer_element.hpp
parentbb4dd8289b351fae6b55e303f189127a394a1edd (diff)
downloadboost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2
boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/intrusive/detail/pointer_element.hpp')
-rw-r--r--boost/intrusive/detail/pointer_element.hpp170
1 files changed, 170 insertions, 0 deletions
diff --git a/boost/intrusive/detail/pointer_element.hpp b/boost/intrusive/detail/pointer_element.hpp
new file mode 100644
index 0000000000..1c17f419ec
--- /dev/null
+++ b/boost/intrusive/detail/pointer_element.hpp
@@ -0,0 +1,170 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Ion Gaztanaga 2014-2014. 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.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_INTRUSIVE_DETAIL_POINTER_ELEMENT_HPP
+#define BOOST_INTRUSIVE_DETAIL_POINTER_ELEMENT_HPP
+
+#if defined(_MSC_VER)
+# pragma once
+#endif
+
+#include <boost/intrusive/detail/workaround.hpp>
+
+namespace boost {
+namespace intrusive {
+namespace detail{
+
+//////////////////////
+//struct first_param
+//////////////////////
+
+template <typename T> struct first_param
+{ typedef void type; };
+
+#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+
+ template <template <typename, typename...> class TemplateClass, typename T, typename... Args>
+ struct first_param< TemplateClass<T, Args...> >
+ {
+ typedef T type;
+ };
+
+#else //C++03 compilers
+
+ template < template //0arg
+ <class
+ > class TemplateClass, class T
+ >
+ struct first_param
+ < TemplateClass<T> >
+ { typedef T type; };
+
+ template < template //1arg
+ <class,class
+ > class TemplateClass, class T
+ , class P0>
+ struct first_param
+ < TemplateClass<T, P0> >
+ { typedef T type; };
+
+ template < template //2arg
+ <class,class,class
+ > class TemplateClass, class T
+ , class P0, class P1>
+ struct first_param
+ < TemplateClass<T, P0, P1> >
+ { typedef T type; };
+
+ template < template //3arg
+ <class,class,class,class
+ > class TemplateClass, class T
+ , class P0, class P1, class P2>
+ struct first_param
+ < TemplateClass<T, P0, P1, P2> >
+ { typedef T type; };
+
+ template < template //4arg
+ <class,class,class,class,class
+ > class TemplateClass, class T
+ , class P0, class P1, class P2, class P3>
+ struct first_param
+ < TemplateClass<T, P0, P1, P2, P3> >
+ { typedef T type; };
+
+ template < template //5arg
+ <class,class,class,class,class,class
+ > class TemplateClass, class T
+ , class P0, class P1, class P2, class P3, class P4>
+ struct first_param
+ < TemplateClass<T, P0, P1, P2, P3, P4> >
+ { typedef T type; };
+
+ template < template //6arg
+ <class,class,class,class,class,class,class
+ > class TemplateClass, class T
+ , class P0, class P1, class P2, class P3, class P4, class P5>
+ struct first_param
+ < TemplateClass<T, P0, P1, P2, P3, P4, P5> >
+ { typedef T type; };
+
+ template < template //7arg
+ <class,class,class,class,class,class,class,class
+ > class TemplateClass, class T
+ , class P0, class P1, class P2, class P3, class P4, class P5, class P6>
+ struct first_param
+ < TemplateClass<T, P0, P1, P2, P3, P4, P5, P6> >
+ { typedef T type; };
+
+ template < template //8arg
+ <class,class,class,class,class,class,class,class,class
+ > class TemplateClass, class T
+ , class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7>
+ struct first_param
+ < TemplateClass<T, P0, P1, P2, P3, P4, P5, P6, P7> >
+ { typedef T type; };
+
+ template < template //9arg
+ <class,class,class,class,class,class,class,class,class,class
+ > class TemplateClass, class T
+ , class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
+ struct first_param
+ < TemplateClass<T, P0, P1, P2, P3, P4, P5, P6, P7, P8> >
+ { typedef T type; };
+
+ template < template //10arg
+ <class,class,class,class,class,class,class,class,class,class,class
+ > class TemplateClass, class T
+ , class P0, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
+ struct first_param
+ < TemplateClass<T, P0, P1, P2, P3, P4, P5, P6, P7, P8, P9> >
+ { typedef T type; };
+
+#endif //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+
+template <typename T>
+struct has_internal_pointer_element
+{
+ template <typename X>
+ static char test(int, typename X::element_type*);
+
+ template <typename X>
+ static int test(...);
+
+ static const bool value = (1 == sizeof(test<T>(0, 0)));
+};
+
+template<class Ptr, bool = has_internal_pointer_element<Ptr>::value>
+struct pointer_element_impl
+{
+ typedef typename Ptr::element_type type;
+};
+
+template<class Ptr>
+struct pointer_element_impl<Ptr, false>
+{
+ typedef typename boost::intrusive::detail::first_param<Ptr>::type type;
+};
+
+} //namespace detail{
+
+template <typename Ptr>
+struct pointer_element
+{
+ typedef typename ::boost::intrusive::detail::pointer_element_impl<Ptr>::type type;
+};
+
+template <typename T>
+struct pointer_element<T*>
+{ typedef T type; };
+
+} //namespace container {
+} //namespace boost {
+
+#endif // defined(BOOST_INTRUSIVE_DETAIL_POINTER_ELEMENT_HPP)