Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:14

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2005-2013. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/container for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 //
0011 //       This code comes from N1953 document by Howard E. Hinnant
0012 //
0013 //////////////////////////////////////////////////////////////////////////////
0014 
0015 
0016 #ifndef BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP
0017 #define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP
0018 
0019 #ifndef BOOST_CONFIG_HPP
0020 #  include <boost/config.hpp>
0021 #endif
0022 
0023 #if defined(BOOST_HAS_PRAGMA_ONCE)
0024 #  pragma once
0025 #endif
0026 
0027 #include <boost/container/detail/config_begin.hpp>
0028 #include <boost/container/detail/workaround.hpp>
0029 
0030 #include <boost/container/detail/mpl.hpp>
0031 #include <boost/container/detail/type_traits.hpp>
0032 
0033 namespace boost{
0034 namespace container {
0035 namespace dtl {
0036 
0037 template <class T, unsigned V>
0038 struct version_type
0039     : public dtl::integral_constant<unsigned, V>
0040 {
0041     typedef T type;
0042 };
0043 
0044 namespace impl{
0045 
0046 template <class T>
0047 struct extract_version
0048 {
0049    typedef typename T::version type;
0050 };
0051 
0052 template <class T>
0053 struct has_version
0054 {
0055    private:
0056    struct two {char _[2];};
0057    template <class U> static two test(...);
0058    template <class U> static char test(const typename U::version*);
0059    public:
0060    static const bool value = sizeof(test<T>(0)) == 1;
0061    void dummy(){}
0062 };
0063 
0064 template <class T, bool = has_version<T>::value>
0065 struct version
0066 {
0067    static const unsigned value = 1;
0068 };
0069 
0070 template <class T>
0071 struct version<T, true>
0072 {
0073    static const unsigned value = extract_version<T>::type::value;
0074 };
0075 
0076 }  //namespace impl
0077 
0078 template <class T>
0079 struct version
0080    : public dtl::integral_constant<unsigned, impl::version<T>::value>
0081 {};
0082 
0083 template<class T, unsigned N>
0084 struct is_version
0085 {
0086    static const bool value =
0087       is_same< typename version<T>::type, integral_constant<unsigned, N> >::value;
0088 };
0089 
0090 }  //namespace dtl {
0091 
0092 typedef dtl::integral_constant<unsigned, 0> version_0;
0093 typedef dtl::integral_constant<unsigned, 1> version_1;
0094 typedef dtl::integral_constant<unsigned, 2> version_2;
0095 
0096 }  //namespace container {
0097 }  //namespace boost{
0098 
0099 #include <boost/container/detail/config_end.hpp>
0100 
0101 #endif   //#define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP