]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/multiprecision/detail/empty_value.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / multiprecision / detail / empty_value.hpp
1 /////////////////////////////////////////////////////////////////////
2 // Copyright 2018 Glen Joseph Fernandes.
3 // Copyright 2021 Matt Borland. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
6
7 #ifndef BOOST_MP_DETAIL_EMPTY_VALUE_HPP
8 #define BOOST_MP_DETAIL_EMPTY_VALUE_HPP
9
10 #include <utility>
11 #include <boost/multiprecision/detail/standalone_config.hpp>
12
13 #if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 40700)
14 #define BOOST_DETAIL_EMPTY_VALUE_BASE
15 #elif defined(BOOST_INTEL) && defined(_MSC_VER) && (_MSC_VER >= 1800)
16 #define BOOST_DETAIL_EMPTY_VALUE_BASE
17 #elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1800)
18 #define BOOST_DETAIL_EMPTY_VALUE_BASE
19 #elif defined(BOOST_CLANG) && !defined(__CUDACC__)
20 #if __has_feature(is_empty) && __has_feature(is_final)
21 #define BOOST_DETAIL_EMPTY_VALUE_BASE
22 #endif
23 #endif
24
25 namespace boost { namespace multiprecision { namespace detail {
26
27 template <typename T>
28 struct use_empty_value_base
29 {
30 #if defined(BOOST_DETAIL_EMPTY_VALUE_BASE)
31 static constexpr bool value = __is_empty(T) && !__is_final(T);
32 #else
33 static constexpr bool value = false;
34 #endif
35 };
36
37 struct empty_init_t {};
38
39 namespace empty_impl {
40
41 template <typename T, unsigned N = 0,
42 bool E = boost::multiprecision::detail::use_empty_value_base<T>::value>
43 class empty_value
44 {
45 private:
46 T value_;
47
48 public:
49 using type = T;
50
51 empty_value() = default;
52 explicit empty_value(boost::multiprecision::detail::empty_init_t) : value_ {} {}
53
54 template <typename U, typename... Args>
55 empty_value(boost::multiprecision::detail::empty_init_t, U&& value, Args&&... args) :
56 value_ {std::forward<U>(value), std::forward<Args>(args)...} {}
57
58 const T& get() const noexcept { return value_; }
59 T& get() noexcept { return value_; }
60 };
61
62 template <typename T, unsigned N>
63 class empty_value<T, N, true> : T
64 {
65 public:
66 using type = T;
67
68 empty_value() = default;
69 explicit empty_value(boost::multiprecision::detail::empty_init_t) : T{} {}
70
71 template <typename U, typename... Args>
72 empty_value(boost::multiprecision::detail::empty_init_t, U&& value, Args&&... args) :
73 T{std::forward<U>(value), std::forward<Args>(args)...} {}
74
75 const T& get() const noexcept { return *this; }
76 T& get() noexcept { return *this; }
77 };
78
79 } // Namespace empty impl
80
81 using empty_impl::empty_value;
82
83 BOOST_INLINE_CONSTEXPR empty_init_t empty_init = empty_init_t();
84
85 }}} // Namespaces
86
87 #endif // BOOST_MP_DETAIL_EMPTY_VALUE_HPP