]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/units/static_constant.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / units / static_constant.hpp
CommitLineData
7c673cae
FG
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
11fdf7f2 16#if defined(BOOST_NO_CXX11_CONSTEXPR) || defined(BOOST_UNITS_DOXYGEN)
7c673cae
FG
17/// A convenience macro that allows definition of static
18/// constants in headers in an ODR-safe way.
11fdf7f2 19# define BOOST_UNITS_STATIC_CONSTANT(name, type) \
7c673cae
FG
20template<bool b> \
21struct name##_instance_t \
22{ \
23 static const type instance; \
24}; \
25 \
26namespace \
27{ \
28 static const type& name = name##_instance_t<true>::instance; \
29} \
30 \
31template<bool b> \
32const type name##_instance_t<b>::instance
11fdf7f2
TL
33#else
34# define BOOST_UNITS_STATIC_CONSTANT(name, type) \
35BOOST_STATIC_CONSTEXPR type name
36#endif
7c673cae
FG
37
38/// A convenience macro for static constants with auto
39/// type deduction.
40#if BOOST_UNITS_HAS_TYPEOF
41
42#if BOOST_UNITS_HAS_BOOST_TYPEOF
43
44#define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value) \
45BOOST_TYPEOF_NESTED_TYPEDEF(name##_nested_t, value) \
46BOOST_UNITS_STATIC_CONSTANT(name, name##_nested_t::type) = (value)
47
48#elif BOOST_UNITS_HAS_MWERKS_TYPEOF
49
50#define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value) \
51BOOST_UNITS_STATIC_CONSTANT(name, __typeof__(value)) = (value)
52
53#elif BOOST_UNITS_HAS_GNU_TYPEOF
54
55#define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value) \
56BOOST_UNITS_STATIC_CONSTANT(name, typeof(value)) = (value)
57
58#endif // BOOST_UNITS_HAS_BOOST_TYPEOF
59
60#endif // BOOST_UNITS_HAS_TYPEOF
61
62#endif // BOOST_UNITS_STATIC_CONSTANT_HPP