Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:09:56

0001 // Boost.Units - A C++ library for zero-overhead dimensional analysis and 
0002 // unit/quantity manipulation and conversion
0003 //
0004 // Copyright (C) 2003-2008 Matthias Christian Schabel
0005 // Copyright (C) 2008 Steven Watanabe
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See
0008 // accompanying file LICENSE_1_0.txt or copy at
0009 // http://www.boost.org/LICENSE_1_0.txt)
0010 
0011 #ifndef BOOST_UNITS_STATIC_CONSTANT_HPP
0012 #define BOOST_UNITS_STATIC_CONSTANT_HPP
0013 
0014 #include <boost/units/config.hpp>
0015 
0016 #if defined(BOOST_NO_CXX11_CONSTEXPR) || defined(BOOST_UNITS_DOXYGEN)
0017 /// A convenience macro that allows definition of static
0018 /// constants in headers in an ODR-safe way.
0019 # define BOOST_UNITS_STATIC_CONSTANT(name, type)            \
0020 template<bool b>                                            \
0021 struct name##_instance_t                                    \
0022 {                                                           \
0023     static const type instance;                             \
0024 };                                                          \
0025                                                             \
0026 namespace                                                   \
0027 {                                                           \
0028     static const type& name = name##_instance_t<true>::instance;   \
0029 }                                                           \
0030                                                             \
0031 template<bool b>                                            \
0032 const type name##_instance_t<b>::instance
0033 #else
0034 # define BOOST_UNITS_STATIC_CONSTANT(name, type)            \
0035 BOOST_STATIC_CONSTEXPR type name
0036 #endif
0037 
0038 /// A convenience macro for static constants with auto 
0039 /// type deduction. 
0040 #if BOOST_UNITS_HAS_TYPEOF
0041 
0042 #if BOOST_UNITS_HAS_BOOST_TYPEOF
0043 
0044 #define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value)               \
0045 BOOST_TYPEOF_NESTED_TYPEDEF(name##_nested_t, value)                 \
0046 BOOST_UNITS_STATIC_CONSTANT(name, name##_nested_t::type) = (value)
0047 
0048 #elif BOOST_UNITS_HAS_MWERKS_TYPEOF
0049 
0050 #define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value)               \
0051 BOOST_UNITS_STATIC_CONSTANT(name, __typeof__(value)) = (value)
0052 
0053 #elif BOOST_UNITS_HAS_GNU_TYPEOF
0054 
0055 #define BOOST_UNITS_AUTO_STATIC_CONSTANT(name, value)               \
0056 BOOST_UNITS_STATIC_CONSTANT(name, typeof(value)) = (value)
0057 
0058 #endif // BOOST_UNITS_HAS_BOOST_TYPEOF
0059 
0060 #endif // BOOST_UNITS_HAS_TYPEOF
0061 
0062 #endif // BOOST_UNITS_STATIC_CONSTANT_HPP