]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/units/static_constant.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / units / static_constant.hpp
1 // Boost.Units - A C++ library for zero-overhead dimensional analysis and
2 // unit/quantity manipulation and conversion
3 //
4 // Copyright (C) 2003-2008 Matthias Christian Schabel
5 // Copyright (C) 2008 Steven Watanabe
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See
8 // accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_UNITS_STATIC_CONSTANT_HPP
12 #define BOOST_UNITS_STATIC_CONSTANT_HPP
13
14 #include <boost/units/config.hpp>
15
16 /// A convenience macro that allows definition of static
17 /// constants in headers in an ODR-safe way.
18 #define BOOST_UNITS_STATIC_CONSTANT(name, type) \
19 template<bool b> \
20 struct name##_instance_t \
21 { \
22 static const type instance; \
23 }; \
24 \
25 namespace \
26 { \
27 static const type& name = name##_instance_t<true>::instance; \
28 } \
29 \
30 template<bool b> \
31 const type name##_instance_t<b>::instance
32
33 /// A convenience macro for static constants with auto
34 /// type deduction.
35 #if BOOST_UNITS_HAS_TYPEOF
36
37 #if BOOST_UNITS_HAS_BOOST_TYPEOF
38
39 #define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value) \
40 BOOST_TYPEOF_NESTED_TYPEDEF(name##_nested_t, value) \
41 BOOST_UNITS_STATIC_CONSTANT(name, name##_nested_t::type) = (value)
42
43 #elif BOOST_UNITS_HAS_MWERKS_TYPEOF
44
45 #define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value) \
46 BOOST_UNITS_STATIC_CONSTANT(name, __typeof__(value)) = (value)
47
48 #elif BOOST_UNITS_HAS_GNU_TYPEOF
49
50 #define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value) \
51 BOOST_UNITS_STATIC_CONSTANT(name, typeof(value)) = (value)
52
53 #endif // BOOST_UNITS_HAS_BOOST_TYPEOF
54
55 #endif // BOOST_UNITS_HAS_TYPEOF
56
57 #endif // BOOST_UNITS_STATIC_CONSTANT_HPP