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>
37 template <class T, unsigned V>
39 : public dtl::integral_constant<unsigned, V>
47 struct extract_version
49 typedef typename T::version type;
56 struct two {char _[2];};
57 template <class U> static two test(...);
58 template <class U> static char test(const typename U::version*);
60 static const bool value = sizeof(test<T>(0)) == 1;
64 template <class T, bool = has_version<T>::value>
67 static const unsigned value = 1;
71 struct version<T, true>
73 static const unsigned value = extract_version<T>::type::value;
80 : public dtl::integral_constant<unsigned, impl::version<T>::value>
83 template<class T, unsigned N>
86 static const bool value =
87 is_same< typename version<T>::type, integral_constant<unsigned, N> >::value;
92 typedef dtl::integral_constant<unsigned, 0> version_0;
93 typedef dtl::integral_constant<unsigned, 1> version_1;
94 typedef dtl::integral_constant<unsigned, 2> version_2;
96 } //namespace container {
99 #include <boost/container/detail/config_end.hpp>
101 #endif //#define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP