1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/libs/container for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 // This code comes from N1953 document by Howard E. Hinnant
13 //////////////////////////////////////////////////////////////////////////////
16 #ifndef BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP
17 #define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP
19 #ifndef BOOST_CONFIG_HPP
20 # include <boost/config.hpp>
23 #if defined(BOOST_HAS_PRAGMA_ONCE)
27 #include <boost/container/detail/config_begin.hpp>
28 #include <boost/container/detail/workaround.hpp>
30 #include <boost/container/detail/mpl.hpp>
31 #include <boost/container/detail/type_traits.hpp>
35 namespace container_detail {
37 template <class T, unsigned V>
39 : public container_detail::integral_constant<unsigned, V>
43 version_type(const version_type<T, 0>&);
49 bool = container_detail::is_convertible<version_type<T, 0>, typename T::version>::value>
50 struct extract_version
52 static const unsigned value = 1;
56 struct extract_version<T, true>
58 static const unsigned value = T::version::value;
65 struct two {char _[2];};
66 template <class U> static two test(...);
67 template <class U> static char test(const typename U::version*);
69 static const bool value = sizeof(test<T>(0)) == 1;
73 template <class T, bool = has_version<T>::value>
76 static const unsigned value = 1;
80 struct version<T, true>
82 static const unsigned value = extract_version<T>::value;
89 : public container_detail::integral_constant<unsigned, impl::version<T>::value>
92 template<class T, unsigned N>
95 static const bool value =
96 is_same< typename version<T>::type, integral_constant<unsigned, N> >::value;
99 } //namespace container_detail {
101 typedef container_detail::integral_constant<unsigned, 0> version_0;
102 typedef container_detail::integral_constant<unsigned, 1> version_1;
103 typedef container_detail::integral_constant<unsigned, 2> version_2;
105 } //namespace container {
108 #include <boost/container/detail/config_end.hpp>
110 #endif //#define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP