]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/container/detail/version_type.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / container / detail / version_type.hpp
CommitLineData
7c673cae
FG
1//////////////////////////////////////////////////////////////////////////////
2//
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)
6//
7// See http://www.boost.org/libs/container for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
10//
11// This code comes from N1953 document by Howard E. Hinnant
12//
13//////////////////////////////////////////////////////////////////////////////
14
15
16#ifndef BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP
17#define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP
18
19#ifndef BOOST_CONFIG_HPP
20# include <boost/config.hpp>
21#endif
22
23#if defined(BOOST_HAS_PRAGMA_ONCE)
24# pragma once
25#endif
26
27#include <boost/container/detail/config_begin.hpp>
28#include <boost/container/detail/workaround.hpp>
29
30#include <boost/container/detail/mpl.hpp>
31#include <boost/container/detail/type_traits.hpp>
32
33namespace boost{
34namespace container {
11fdf7f2 35namespace dtl {
7c673cae
FG
36
37template <class T, unsigned V>
38struct version_type
11fdf7f2 39 : public dtl::integral_constant<unsigned, V>
7c673cae
FG
40{
41 typedef T type;
7c673cae
FG
42};
43
44namespace impl{
45
7c673cae 46template <class T>
92f5a8d4 47struct extract_version
7c673cae 48{
92f5a8d4 49 typedef typename T::version type;
7c673cae
FG
50};
51
52template <class T>
53struct has_version
54{
55 private:
56 struct two {char _[2];};
57 template <class U> static two test(...);
58 template <class U> static char test(const typename U::version*);
59 public:
60 static const bool value = sizeof(test<T>(0)) == 1;
61 void dummy(){}
62};
63
64template <class T, bool = has_version<T>::value>
65struct version
66{
67 static const unsigned value = 1;
68};
69
70template <class T>
71struct version<T, true>
72{
92f5a8d4 73 static const unsigned value = extract_version<T>::type::value;
7c673cae
FG
74};
75
76} //namespace impl
77
78template <class T>
79struct version
11fdf7f2 80 : public dtl::integral_constant<unsigned, impl::version<T>::value>
7c673cae
FG
81{};
82
83template<class T, unsigned N>
84struct is_version
85{
86 static const bool value =
87 is_same< typename version<T>::type, integral_constant<unsigned, N> >::value;
88};
89
11fdf7f2 90} //namespace dtl {
7c673cae 91
11fdf7f2
TL
92typedef dtl::integral_constant<unsigned, 0> version_0;
93typedef dtl::integral_constant<unsigned, 1> version_1;
94typedef dtl::integral_constant<unsigned, 2> version_2;
7c673cae
FG
95
96} //namespace container {
97} //namespace boost{
98
99#include <boost/container/detail/config_end.hpp>
100
101#endif //#define BOOST_CONTAINER_DETAIL_VERSION_TYPE_HPP