summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/Boost/src/boost/detail')
-rw-r--r--3rdParty/Boost/src/boost/detail/allocator_utilities.hpp212
-rw-r--r--3rdParty/Boost/src/boost/detail/compressed_pair.hpp443
-rw-r--r--3rdParty/Boost/src/boost/detail/ob_compressed_pair.hpp510
3 files changed, 1165 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/detail/allocator_utilities.hpp b/3rdParty/Boost/src/boost/detail/allocator_utilities.hpp
new file mode 100644
index 0000000..5d6ef48
--- /dev/null
+++ b/3rdParty/Boost/src/boost/detail/allocator_utilities.hpp
@@ -0,0 +1,212 @@
+/* Copyright 2003-2009 Joaquin M Lopez Munoz.
+ * 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 Boost website at http://www.boost.org/
+ */
+
+#ifndef BOOST_DETAIL_ALLOCATOR_UTILITIES_HPP
+#define BOOST_DETAIL_ALLOCATOR_UTILITIES_HPP
+
+#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
+#include <boost/detail/workaround.hpp>
+#include <boost/mpl/aux_/msvc_never_true.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <cstddef>
+#include <memory>
+#include <new>
+
+namespace boost{
+
+namespace detail{
+
+/* Allocator adaption layer. Some stdlibs provide allocators without rebind
+ * and template ctors. These facilities are simulated with the external
+ * template class rebind_to and the aid of partial_std_allocator_wrapper.
+ */
+
+namespace allocator{
+
+/* partial_std_allocator_wrapper inherits the functionality of a std
+ * allocator while providing a templatized ctor and other bits missing
+ * in some stdlib implementation or another.
+ */
+
+template<typename Type>
+class partial_std_allocator_wrapper:public std::allocator<Type>
+{
+public:
+ /* Oddly enough, STLport does not define std::allocator<void>::value_type
+ * when configured to work without partial template specialization.
+ * No harm in supplying the definition here unconditionally.
+ */
+
+ typedef Type value_type;
+
+ partial_std_allocator_wrapper(){};
+
+ template<typename Other>
+ partial_std_allocator_wrapper(const partial_std_allocator_wrapper<Other>&){}
+
+ partial_std_allocator_wrapper(const std::allocator<Type>& x):
+ std::allocator<Type>(x)
+ {
+ };
+
+#if defined(BOOST_DINKUMWARE_STDLIB)
+ /* Dinkumware guys didn't provide a means to call allocate() without
+ * supplying a hint, in disagreement with the standard.
+ */
+
+ Type* allocate(std::size_t n,const void* hint=0)
+ {
+ std::allocator<Type>& a=*this;
+ return a.allocate(n,hint);
+ }
+#endif
+
+};
+
+/* Detects whether a given allocator belongs to a defective stdlib not
+ * having the required member templates.
+ * Note that it does not suffice to check the Boost.Config stdlib
+ * macros, as the user might have passed a custom, compliant allocator.
+ * The checks also considers partial_std_allocator_wrapper to be
+ * a standard defective allocator.
+ */
+
+#if defined(BOOST_NO_STD_ALLOCATOR)&&\
+ (defined(BOOST_HAS_PARTIAL_STD_ALLOCATOR)||defined(BOOST_DINKUMWARE_STDLIB))
+
+template<typename Allocator>
+struct is_partial_std_allocator
+{
+ BOOST_STATIC_CONSTANT(bool,
+ value=
+ (is_same<
+ std::allocator<BOOST_DEDUCED_TYPENAME Allocator::value_type>,
+ Allocator
+ >::value)||
+ (is_same<
+ partial_std_allocator_wrapper<
+ BOOST_DEDUCED_TYPENAME Allocator::value_type>,
+ Allocator
+ >::value));
+};
+
+#else
+
+template<typename Allocator>
+struct is_partial_std_allocator
+{
+ BOOST_STATIC_CONSTANT(bool,value=false);
+};
+
+#endif
+
+/* rebind operations for defective std allocators */
+
+template<typename Allocator,typename Type>
+struct partial_std_allocator_rebind_to
+{
+ typedef partial_std_allocator_wrapper<Type> type;
+};
+
+/* rebind operation in all other cases */
+
+#if BOOST_WORKAROUND(BOOST_MSVC,<1300)
+/* Workaround for a problem in MSVC with dependent template typedefs
+ * when doing rebinding of allocators.
+ * Modeled after <boost/mpl/aux_/msvc_dtw.hpp> (thanks, Aleksey!)
+ */
+
+template<typename Allocator>
+struct rebinder
+{
+ template<bool> struct fake_allocator:Allocator{};
+ template<> struct fake_allocator<true>
+ {
+ template<typename Type> struct rebind{};
+ };
+
+ template<typename Type>
+ struct result:
+ fake_allocator<mpl::aux::msvc_never_true<Allocator>::value>::
+ template rebind<Type>
+ {
+ };
+};
+#else
+template<typename Allocator>
+struct rebinder
+{
+ template<typename Type>
+ struct result
+ {
+ typedef typename Allocator::BOOST_NESTED_TEMPLATE
+ rebind<Type>::other other;
+ };
+};
+#endif
+
+template<typename Allocator,typename Type>
+struct compliant_allocator_rebind_to
+{
+ typedef typename rebinder<Allocator>::
+ BOOST_NESTED_TEMPLATE result<Type>::other type;
+};
+
+/* rebind front-end */
+
+template<typename Allocator,typename Type>
+struct rebind_to:
+ mpl::eval_if_c<
+ is_partial_std_allocator<Allocator>::value,
+ partial_std_allocator_rebind_to<Allocator,Type>,
+ compliant_allocator_rebind_to<Allocator,Type>
+ >
+{
+};
+
+/* allocator-independent versions of construct and destroy */
+
+template<typename Type>
+void construct(void* p,const Type& t)
+{
+ new (p) Type(t);
+}
+
+#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
+/* MSVC++ issues spurious warnings about unreferencend formal parameters
+ * in destroy<Type> when Type is a class with trivial dtor.
+ */
+
+#pragma warning(push)
+#pragma warning(disable:4100)
+#endif
+
+template<typename Type>
+void destroy(const Type* p)
+{
+
+#if BOOST_WORKAROUND(__SUNPRO_CC,BOOST_TESTED_AT(0x590))
+ const_cast<Type*>(p)->~Type();
+#else
+ p->~Type();
+#endif
+
+}
+
+#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
+#pragma warning(pop)
+#endif
+
+} /* namespace boost::detail::allocator */
+
+} /* namespace boost::detail */
+
+} /* namespace boost */
+
+#endif
diff --git a/3rdParty/Boost/src/boost/detail/compressed_pair.hpp b/3rdParty/Boost/src/boost/detail/compressed_pair.hpp
new file mode 100644
index 0000000..3f32645
--- /dev/null
+++ b/3rdParty/Boost/src/boost/detail/compressed_pair.hpp
@@ -0,0 +1,443 @@
+// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
+// Use, modification and distribution are subject to 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/utility for most recent version including documentation.
+
+// compressed_pair: pair that "compresses" empty members
+// (see libs/utility/compressed_pair.htm)
+//
+// JM changes 25 Jan 2004:
+// For the case where T1 == T2 and both are empty, then first() and second()
+// should return different objects.
+// JM changes 25 Jan 2000:
+// Removed default arguments from compressed_pair_switch to get
+// C++ Builder 4 to accept them
+// rewriten swap to get gcc and C++ builder to compile.
+// added partial specialisations for case T1 == T2 to avoid duplicate constructor defs.
+
+#ifndef BOOST_DETAIL_COMPRESSED_PAIR_HPP
+#define BOOST_DETAIL_COMPRESSED_PAIR_HPP
+
+#include <algorithm>
+
+#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/is_empty.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/call_traits.hpp>
+
+#ifdef BOOST_MSVC
+# pragma warning(push)
+# pragma warning(disable:4512)
+#endif
+namespace boost
+{
+
+template <class T1, class T2>
+class compressed_pair;
+
+
+// compressed_pair
+
+namespace details
+{
+ // JM altered 26 Jan 2000:
+ template <class T1, class T2, bool IsSame, bool FirstEmpty, bool SecondEmpty>
+ struct compressed_pair_switch;
+
+ template <class T1, class T2>
+ struct compressed_pair_switch<T1, T2, false, false, false>
+ {static const int value = 0;};
+
+ template <class T1, class T2>
+ struct compressed_pair_switch<T1, T2, false, true, true>
+ {static const int value = 3;};
+
+ template <class T1, class T2>
+ struct compressed_pair_switch<T1, T2, false, true, false>
+ {static const int value = 1;};
+
+ template <class T1, class T2>
+ struct compressed_pair_switch<T1, T2, false, false, true>
+ {static const int value = 2;};
+
+ template <class T1, class T2>
+ struct compressed_pair_switch<T1, T2, true, true, true>
+ {static const int value = 4;};
+
+ template <class T1, class T2>
+ struct compressed_pair_switch<T1, T2, true, false, false>
+ {static const int value = 5;};
+
+ template <class T1, class T2, int Version> class compressed_pair_imp;
+
+#ifdef __GNUC__
+ // workaround for GCC (JM):
+ using std::swap;
+#endif
+ //
+ // can't call unqualified swap from within classname::swap
+ // as Koenig lookup rules will find only the classname::swap
+ // member function not the global declaration, so use cp_swap
+ // as a forwarding function (JM):
+ template <typename T>
+ inline void cp_swap(T& t1, T& t2)
+ {
+#ifndef __GNUC__
+ using std::swap;
+#endif
+ swap(t1, t2);
+ }
+
+ // 0 derive from neither
+
+ template <class T1, class T2>
+ class compressed_pair_imp<T1, T2, 0>
+ {
+ public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_imp() {}
+
+ compressed_pair_imp(first_param_type x, second_param_type y)
+ : first_(x), second_(y) {}
+
+ compressed_pair_imp(first_param_type x)
+ : first_(x) {}
+
+ compressed_pair_imp(second_param_type y)
+ : second_(y) {}
+
+ first_reference first() {return first_;}
+ first_const_reference first() const {return first_;}
+
+ second_reference second() {return second_;}
+ second_const_reference second() const {return second_;}
+
+ void swap(::boost::compressed_pair<T1, T2>& y)
+ {
+ cp_swap(first_, y.first());
+ cp_swap(second_, y.second());
+ }
+ private:
+ first_type first_;
+ second_type second_;
+ };
+
+ // 1 derive from T1
+
+ template <class T1, class T2>
+ class compressed_pair_imp<T1, T2, 1>
+ : protected ::boost::remove_cv<T1>::type
+ {
+ public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_imp() {}
+
+ compressed_pair_imp(first_param_type x, second_param_type y)
+ : first_type(x), second_(y) {}
+
+ compressed_pair_imp(first_param_type x)
+ : first_type(x) {}
+
+ compressed_pair_imp(second_param_type y)
+ : second_(y) {}
+
+ first_reference first() {return *this;}
+ first_const_reference first() const {return *this;}
+
+ second_reference second() {return second_;}
+ second_const_reference second() const {return second_;}
+
+ void swap(::boost::compressed_pair<T1,T2>& y)
+ {
+ // no need to swap empty base class:
+ cp_swap(second_, y.second());
+ }
+ private:
+ second_type second_;
+ };
+
+ // 2 derive from T2
+
+ template <class T1, class T2>
+ class compressed_pair_imp<T1, T2, 2>
+ : protected ::boost::remove_cv<T2>::type
+ {
+ public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_imp() {}
+
+ compressed_pair_imp(first_param_type x, second_param_type y)
+ : second_type(y), first_(x) {}
+
+ compressed_pair_imp(first_param_type x)
+ : first_(x) {}
+
+ compressed_pair_imp(second_param_type y)
+ : second_type(y) {}
+
+ first_reference first() {return first_;}
+ first_const_reference first() const {return first_;}
+
+ second_reference second() {return *this;}
+ second_const_reference second() const {return *this;}
+
+ void swap(::boost::compressed_pair<T1,T2>& y)
+ {
+ // no need to swap empty base class:
+ cp_swap(first_, y.first());
+ }
+
+ private:
+ first_type first_;
+ };
+
+ // 3 derive from T1 and T2
+
+ template <class T1, class T2>
+ class compressed_pair_imp<T1, T2, 3>
+ : protected ::boost::remove_cv<T1>::type,
+ protected ::boost::remove_cv<T2>::type
+ {
+ public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_imp() {}
+
+ compressed_pair_imp(first_param_type x, second_param_type y)
+ : first_type(x), second_type(y) {}
+
+ compressed_pair_imp(first_param_type x)
+ : first_type(x) {}
+
+ compressed_pair_imp(second_param_type y)
+ : second_type(y) {}
+
+ first_reference first() {return *this;}
+ first_const_reference first() const {return *this;}
+
+ second_reference second() {return *this;}
+ second_const_reference second() const {return *this;}
+ //
+ // no need to swap empty bases:
+ void swap(::boost::compressed_pair<T1,T2>&) {}
+ };
+
+ // JM
+ // 4 T1 == T2, T1 and T2 both empty
+ // Originally this did not store an instance of T2 at all
+ // but that led to problems beause it meant &x.first() == &x.second()
+ // which is not true for any other kind of pair, so now we store an instance
+ // of T2 just in case the user is relying on first() and second() returning
+ // different objects (albeit both empty).
+ template <class T1, class T2>
+ class compressed_pair_imp<T1, T2, 4>
+ : protected ::boost::remove_cv<T1>::type
+ {
+ public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_imp() {}
+
+ compressed_pair_imp(first_param_type x, second_param_type y)
+ : first_type(x), m_second(y) {}
+
+ compressed_pair_imp(first_param_type x)
+ : first_type(x), m_second(x) {}
+
+ first_reference first() {return *this;}
+ first_const_reference first() const {return *this;}
+
+ second_reference second() {return m_second;}
+ second_const_reference second() const {return m_second;}
+
+ void swap(::boost::compressed_pair<T1,T2>&) {}
+ private:
+ T2 m_second;
+ };
+
+ // 5 T1 == T2 and are not empty: //JM
+
+ template <class T1, class T2>
+ class compressed_pair_imp<T1, T2, 5>
+ {
+ public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_imp() {}
+
+ compressed_pair_imp(first_param_type x, second_param_type y)
+ : first_(x), second_(y) {}
+
+ compressed_pair_imp(first_param_type x)
+ : first_(x), second_(x) {}
+
+ first_reference first() {return first_;}
+ first_const_reference first() const {return first_;}
+
+ second_reference second() {return second_;}
+ second_const_reference second() const {return second_;}
+
+ void swap(::boost::compressed_pair<T1, T2>& y)
+ {
+ cp_swap(first_, y.first());
+ cp_swap(second_, y.second());
+ }
+ private:
+ first_type first_;
+ second_type second_;
+ };
+
+} // details
+
+template <class T1, class T2>
+class compressed_pair
+ : private ::boost::details::compressed_pair_imp<T1, T2,
+ ::boost::details::compressed_pair_switch<
+ T1,
+ T2,
+ ::boost::is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
+ ::boost::is_empty<T1>::value,
+ ::boost::is_empty<T2>::value>::value>
+{
+private:
+ typedef details::compressed_pair_imp<T1, T2,
+ ::boost::details::compressed_pair_switch<
+ T1,
+ T2,
+ ::boost::is_same<typename remove_cv<T1>::type, typename remove_cv<T2>::type>::value,
+ ::boost::is_empty<T1>::value,
+ ::boost::is_empty<T2>::value>::value> base;
+public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair() : base() {}
+ compressed_pair(first_param_type x, second_param_type y) : base(x, y) {}
+ explicit compressed_pair(first_param_type x) : base(x) {}
+ explicit compressed_pair(second_param_type y) : base(y) {}
+
+ first_reference first() {return base::first();}
+ first_const_reference first() const {return base::first();}
+
+ second_reference second() {return base::second();}
+ second_const_reference second() const {return base::second();}
+
+ void swap(compressed_pair& y) { base::swap(y); }
+};
+
+// JM
+// Partial specialisation for case where T1 == T2:
+//
+template <class T>
+class compressed_pair<T, T>
+ : private details::compressed_pair_imp<T, T,
+ ::boost::details::compressed_pair_switch<
+ T,
+ T,
+ ::boost::is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
+ ::boost::is_empty<T>::value,
+ ::boost::is_empty<T>::value>::value>
+{
+private:
+ typedef details::compressed_pair_imp<T, T,
+ ::boost::details::compressed_pair_switch<
+ T,
+ T,
+ ::boost::is_same<typename remove_cv<T>::type, typename remove_cv<T>::type>::value,
+ ::boost::is_empty<T>::value,
+ ::boost::is_empty<T>::value>::value> base;
+public:
+ typedef T first_type;
+ typedef T second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair() : base() {}
+ compressed_pair(first_param_type x, second_param_type y) : base(x, y) {}
+#if !(defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x530))
+ explicit
+#endif
+ compressed_pair(first_param_type x) : base(x) {}
+
+ first_reference first() {return base::first();}
+ first_const_reference first() const {return base::first();}
+
+ second_reference second() {return base::second();}
+ second_const_reference second() const {return base::second();}
+
+ void swap(::boost::compressed_pair<T,T>& y) { base::swap(y); }
+};
+
+template <class T1, class T2>
+inline
+void
+swap(compressed_pair<T1, T2>& x, compressed_pair<T1, T2>& y)
+{
+ x.swap(y);
+}
+
+} // boost
+
+#ifdef BOOST_MSVC
+# pragma warning(pop)
+#endif
+
+#endif // BOOST_DETAIL_COMPRESSED_PAIR_HPP
+
diff --git a/3rdParty/Boost/src/boost/detail/ob_compressed_pair.hpp b/3rdParty/Boost/src/boost/detail/ob_compressed_pair.hpp
new file mode 100644
index 0000000..727acab
--- /dev/null
+++ b/3rdParty/Boost/src/boost/detail/ob_compressed_pair.hpp
@@ -0,0 +1,510 @@
+// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000.
+// Use, modification and distribution are subject to 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/utility for most recent version including documentation.
+// see libs/utility/compressed_pair.hpp
+//
+/* Release notes:
+ 20 Jan 2001:
+ Fixed obvious bugs (David Abrahams)
+ 07 Oct 2000:
+ Added better single argument constructor support.
+ 03 Oct 2000:
+ Added VC6 support (JM).
+ 23rd July 2000:
+ Additional comments added. (JM)
+ Jan 2000:
+ Original version: this version crippled for use with crippled compilers
+ - John Maddock Jan 2000.
+*/
+
+
+#ifndef BOOST_OB_COMPRESSED_PAIR_HPP
+#define BOOST_OB_COMPRESSED_PAIR_HPP
+
+#include <algorithm>
+#ifndef BOOST_OBJECT_TYPE_TRAITS_HPP
+#include <boost/type_traits/object_traits.hpp>
+#endif
+#ifndef BOOST_SAME_TRAITS_HPP
+#include <boost/type_traits/same_traits.hpp>
+#endif
+#ifndef BOOST_CALL_TRAITS_HPP
+#include <boost/call_traits.hpp>
+#endif
+
+namespace boost
+{
+#ifdef BOOST_MSVC6_MEMBER_TEMPLATES
+//
+// use member templates to emulate
+// partial specialisation. Note that due to
+// problems with overload resolution with VC6
+// each of the compressed_pair versions that follow
+// have one template single-argument constructor
+// in place of two specific constructors:
+//
+
+template <class T1, class T2>
+class compressed_pair;
+
+namespace detail{
+
+template <class A, class T1, class T2>
+struct best_conversion_traits
+{
+ typedef char one;
+ typedef char (&two)[2];
+ static A a;
+ static one test(T1);
+ static two test(T2);
+
+ enum { value = sizeof(test(a)) };
+};
+
+template <int>
+struct init_one;
+
+template <>
+struct init_one<1>
+{
+ template <class A, class T1, class T2>
+ static void init(const A& a, T1* p1, T2*)
+ {
+ *p1 = a;
+ }
+};
+
+template <>
+struct init_one<2>
+{
+ template <class A, class T1, class T2>
+ static void init(const A& a, T1*, T2* p2)
+ {
+ *p2 = a;
+ }
+};
+
+
+// T1 != T2, both non-empty
+template <class T1, class T2>
+class compressed_pair_0
+{
+private:
+ T1 _first;
+ T2 _second;
+public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_0() : _first(), _second() {}
+ compressed_pair_0(first_param_type x, second_param_type y) : _first(x), _second(y) {}
+ template <class A>
+ explicit compressed_pair_0(const A& val)
+ {
+ init_one<best_conversion_traits<A, T1, T2>::value>::init(val, &_first, &_second);
+ }
+ compressed_pair_0(const ::boost::compressed_pair<T1,T2>& x)
+ : _first(x.first()), _second(x.second()) {}
+
+#if 0
+ compressed_pair_0& operator=(const compressed_pair_0& x) {
+ cout << "assigning compressed pair 0" << endl;
+ _first = x._first;
+ _second = x._second;
+ cout << "finished assigning compressed pair 0" << endl;
+ return *this;
+ }
+#endif
+
+ first_reference first() { return _first; }
+ first_const_reference first() const { return _first; }
+
+ second_reference second() { return _second; }
+ second_const_reference second() const { return _second; }
+
+ void swap(compressed_pair_0& y)
+ {
+ using std::swap;
+ swap(_first, y._first);
+ swap(_second, y._second);
+ }
+};
+
+// T1 != T2, T2 empty
+template <class T1, class T2>
+class compressed_pair_1 : T2
+{
+private:
+ T1 _first;
+public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_1() : T2(), _first() {}
+ compressed_pair_1(first_param_type x, second_param_type y) : T2(y), _first(x) {}
+
+ template <class A>
+ explicit compressed_pair_1(const A& val)
+ {
+ init_one<best_conversion_traits<A, T1, T2>::value>::init(val, &_first, static_cast<T2*>(this));
+ }
+
+ compressed_pair_1(const ::boost::compressed_pair<T1,T2>& x)
+ : T2(x.second()), _first(x.first()) {}
+
+#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
+ // Total weirdness. If the assignment to _first is moved after
+ // the call to the inherited operator=, then this breaks graph/test/graph.cpp
+ // by way of iterator_adaptor.
+ compressed_pair_1& operator=(const compressed_pair_1& x) {
+ _first = x._first;
+ T2::operator=(x);
+ return *this;
+ }
+#endif
+
+ first_reference first() { return _first; }
+ first_const_reference first() const { return _first; }
+
+ second_reference second() { return *this; }
+ second_const_reference second() const { return *this; }
+
+ void swap(compressed_pair_1& y)
+ {
+ // no need to swap empty base class:
+ using std::swap;
+ swap(_first, y._first);
+ }
+};
+
+// T1 != T2, T1 empty
+template <class T1, class T2>
+class compressed_pair_2 : T1
+{
+private:
+ T2 _second;
+public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_2() : T1(), _second() {}
+ compressed_pair_2(first_param_type x, second_param_type y) : T1(x), _second(y) {}
+ template <class A>
+ explicit compressed_pair_2(const A& val)
+ {
+ init_one<best_conversion_traits<A, T1, T2>::value>::init(val, static_cast<T1*>(this), &_second);
+ }
+ compressed_pair_2(const ::boost::compressed_pair<T1,T2>& x)
+ : T1(x.first()), _second(x.second()) {}
+
+#if 0
+ compressed_pair_2& operator=(const compressed_pair_2& x) {
+ cout << "assigning compressed pair 2" << endl;
+ T1::operator=(x);
+ _second = x._second;
+ cout << "finished assigning compressed pair 2" << endl;
+ return *this;
+ }
+#endif
+ first_reference first() { return *this; }
+ first_const_reference first() const { return *this; }
+
+ second_reference second() { return _second; }
+ second_const_reference second() const { return _second; }
+
+ void swap(compressed_pair_2& y)
+ {
+ // no need to swap empty base class:
+ using std::swap;
+ swap(_second, y._second);
+ }
+};
+
+// T1 != T2, both empty
+template <class T1, class T2>
+class compressed_pair_3 : T1, T2
+{
+public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_3() : T1(), T2() {}
+ compressed_pair_3(first_param_type x, second_param_type y) : T1(x), T2(y) {}
+ template <class A>
+ explicit compressed_pair_3(const A& val)
+ {
+ init_one<best_conversion_traits<A, T1, T2>::value>::init(val, static_cast<T1*>(this), static_cast<T2*>(this));
+ }
+ compressed_pair_3(const ::boost::compressed_pair<T1,T2>& x)
+ : T1(x.first()), T2(x.second()) {}
+
+ first_reference first() { return *this; }
+ first_const_reference first() const { return *this; }
+
+ second_reference second() { return *this; }
+ second_const_reference second() const { return *this; }
+
+ void swap(compressed_pair_3& y)
+ {
+ // no need to swap empty base classes:
+ }
+};
+
+// T1 == T2, and empty
+template <class T1, class T2>
+class compressed_pair_4 : T1
+{
+public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_4() : T1() {}
+ compressed_pair_4(first_param_type x, second_param_type y) : T1(x), m_second(y) {}
+ // only one single argument constructor since T1 == T2
+ explicit compressed_pair_4(first_param_type x) : T1(x), m_second(x) {}
+ compressed_pair_4(const ::boost::compressed_pair<T1,T2>& x)
+ : T1(x.first()), m_second(x.second()) {}
+
+ first_reference first() { return *this; }
+ first_const_reference first() const { return *this; }
+
+ second_reference second() { return m_second; }
+ second_const_reference second() const { return m_second; }
+
+ void swap(compressed_pair_4& y)
+ {
+ // no need to swap empty base classes:
+ }
+private:
+ T2 m_second;
+};
+
+// T1 == T2, not empty
+template <class T1, class T2>
+class compressed_pair_5
+{
+private:
+ T1 _first;
+ T2 _second;
+public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair_5() : _first(), _second() {}
+ compressed_pair_5(first_param_type x, second_param_type y) : _first(x), _second(y) {}
+ // only one single argument constructor since T1 == T2
+ explicit compressed_pair_5(first_param_type x) : _first(x), _second(x) {}
+ compressed_pair_5(const ::boost::compressed_pair<T1,T2>& c)
+ : _first(c.first()), _second(c.second()) {}
+
+ first_reference first() { return _first; }
+ first_const_reference first() const { return _first; }
+
+ second_reference second() { return _second; }
+ second_const_reference second() const { return _second; }
+
+ void swap(compressed_pair_5& y)
+ {
+ using std::swap;
+ swap(_first, y._first);
+ swap(_second, y._second);
+ }
+};
+
+template <bool e1, bool e2, bool same>
+struct compressed_pair_chooser
+{
+ template <class T1, class T2>
+ struct rebind
+ {
+ typedef compressed_pair_0<T1, T2> type;
+ };
+};
+
+template <>
+struct compressed_pair_chooser<false, true, false>
+{
+ template <class T1, class T2>
+ struct rebind
+ {
+ typedef compressed_pair_1<T1, T2> type;
+ };
+};
+
+template <>
+struct compressed_pair_chooser<true, false, false>
+{
+ template <class T1, class T2>
+ struct rebind
+ {
+ typedef compressed_pair_2<T1, T2> type;
+ };
+};
+
+template <>
+struct compressed_pair_chooser<true, true, false>
+{
+ template <class T1, class T2>
+ struct rebind
+ {
+ typedef compressed_pair_3<T1, T2> type;
+ };
+};
+
+template <>
+struct compressed_pair_chooser<true, true, true>
+{
+ template <class T1, class T2>
+ struct rebind
+ {
+ typedef compressed_pair_4<T1, T2> type;
+ };
+};
+
+template <>
+struct compressed_pair_chooser<false, false, true>
+{
+ template <class T1, class T2>
+ struct rebind
+ {
+ typedef compressed_pair_5<T1, T2> type;
+ };
+};
+
+template <class T1, class T2>
+struct compressed_pair_traits
+{
+private:
+ typedef compressed_pair_chooser<is_empty<T1>::value, is_empty<T2>::value, is_same<T1,T2>::value> chooser;
+ typedef typename chooser::template rebind<T1, T2> bound_type;
+public:
+ typedef typename bound_type::type type;
+};
+
+} // namespace detail
+
+template <class T1, class T2>
+class compressed_pair : public detail::compressed_pair_traits<T1, T2>::type
+{
+private:
+ typedef typename detail::compressed_pair_traits<T1, T2>::type base_type;
+public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair() : base_type() {}
+ compressed_pair(first_param_type x, second_param_type y) : base_type(x, y) {}
+ template <class A>
+ explicit compressed_pair(const A& x) : base_type(x){}
+
+ first_reference first() { return base_type::first(); }
+ first_const_reference first() const { return base_type::first(); }
+
+ second_reference second() { return base_type::second(); }
+ second_const_reference second() const { return base_type::second(); }
+};
+
+template <class T1, class T2>
+inline void swap(compressed_pair<T1, T2>& x, compressed_pair<T1, T2>& y)
+{
+ x.swap(y);
+}
+
+#else
+// no partial specialisation, no member templates:
+
+template <class T1, class T2>
+class compressed_pair
+{
+private:
+ T1 _first;
+ T2 _second;
+public:
+ typedef T1 first_type;
+ typedef T2 second_type;
+ typedef typename call_traits<first_type>::param_type first_param_type;
+ typedef typename call_traits<second_type>::param_type second_param_type;
+ typedef typename call_traits<first_type>::reference first_reference;
+ typedef typename call_traits<second_type>::reference second_reference;
+ typedef typename call_traits<first_type>::const_reference first_const_reference;
+ typedef typename call_traits<second_type>::const_reference second_const_reference;
+
+ compressed_pair() : _first(), _second() {}
+ compressed_pair(first_param_type x, second_param_type y) : _first(x), _second(y) {}
+ explicit compressed_pair(first_param_type x) : _first(x), _second() {}
+ // can't define this in case T1 == T2:
+ // explicit compressed_pair(second_param_type y) : _first(), _second(y) {}
+
+ first_reference first() { return _first; }
+ first_const_reference first() const { return _first; }
+
+ second_reference second() { return _second; }
+ second_const_reference second() const { return _second; }
+
+ void swap(compressed_pair& y)
+ {
+ using std::swap;
+ swap(_first, y._first);
+ swap(_second, y._second);
+ }
+};
+
+template <class T1, class T2>
+inline void swap(compressed_pair<T1, T2>& x, compressed_pair<T1, T2>& y)
+{
+ x.swap(y);
+}
+
+#endif
+
+} // boost
+
+#endif // BOOST_OB_COMPRESSED_PAIR_HPP
+
+
+