2 Copyright 2018 Glen Joseph Fernandes
5 Distributed under the Boost Software License, Version 1.0.
6 (http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_CORE_EMPTY_VALUE_HPP
9 #define BOOST_CORE_EMPTY_VALUE_HPP
11 #include <boost/config.hpp>
12 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
16 #if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40700)
17 #define BOOST_DETAIL_EMPTY_VALUE_BASE
18 #elif defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1800)
19 #define BOOST_DETAIL_EMPTY_VALUE_BASE
20 #elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1800)
21 #define BOOST_DETAIL_EMPTY_VALUE_BASE
22 #elif defined(BOOST_CLANG) && !defined(__CUDACC__)
23 #if __has_feature(is_empty) && __has_feature(is_final)
24 #define BOOST_DETAIL_EMPTY_VALUE_BASE
31 struct use_empty_value_base {
33 #if defined(BOOST_DETAIL_EMPTY_VALUE_BASE)
34 value = __is_empty(T) && !__is_final(T)
41 struct empty_init_t { };
45 template<class T, unsigned N = 0,
46 bool E = boost::use_empty_value_base<T>::value>
51 #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
52 empty_value() = default;
57 empty_value(boost::empty_init_t)
60 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
61 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
62 template<class... Args>
63 explicit empty_value(boost::empty_init_t, Args&&... args)
64 : value_(std::forward<Args>(args)...) { }
67 empty_value(boost::empty_init_t, U&& value)
68 : value_(std::forward<U>(value)) { }
72 empty_value(boost::empty_init_t, const U& value)
76 empty_value(boost::empty_init_t, U& value)
80 const T& get() const BOOST_NOEXCEPT {
84 T& get() BOOST_NOEXCEPT {
92 #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
93 template<class T, unsigned N>
94 class empty_value<T, N, true>
99 #if !defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
100 empty_value() = default;
105 empty_value(boost::empty_init_t)
108 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
109 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
110 template<class... Args>
111 explicit empty_value(boost::empty_init_t, Args&&... args)
112 : T(std::forward<Args>(args)...) { }
115 empty_value(boost::empty_init_t, U&& value)
116 : T(std::forward<U>(value)) { }
120 empty_value(boost::empty_init_t, const U& value)
124 empty_value(boost::empty_init_t, U& value)
128 const T& get() const BOOST_NOEXCEPT {
132 T& get() BOOST_NOEXCEPT {
140 using empty_::empty_value;