]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/contract/detail/type_traits/optional.hpp
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / boost / boost / contract / detail / type_traits / optional.hpp
1
2 #ifndef BOOST_CONTRACT_DETAIL_OPTIONAL_HPP_
3 #define BOOST_CONTRACT_DETAIL_OPTIONAL_HPP_
4
5 // Copyright (C) 2008-2018 Lorenzo Caminiti
6 // Distributed under the Boost Software License, Version 1.0 (see accompanying
7 // file LICENSE_1_0.txt or a copy at http://www.boost.org/LICENSE_1_0.txt).
8 // See: http://www.boost.org/doc/libs/release/libs/contract/doc/html/index.html
9
10 #include <boost/optional.hpp>
11 #include <boost/type_traits/remove_reference.hpp>
12 #include <boost/type_traits/integral_constant.hpp>
13
14 namespace boost { namespace contract { namespace detail {
15
16 template<typename T>
17 struct is_optional : boost::false_type {};
18 template<typename T>
19 struct is_optional<boost::optional<T> > : boost::true_type {};
20
21 template<typename T>
22 struct optional_value_type { typedef T type; };
23 template<typename T>
24 struct optional_value_type<boost::optional<T> > { typedef T type; };
25
26 template<typename T>
27 struct remove_value_reference_if_optional { typedef T type; };
28 template<typename T>
29 struct remove_value_reference_if_optional<boost::optional<T> >
30 { typedef typename boost::remove_reference<T>::type type; };
31
32 template<typename T>
33 T& optional_get(T& x) { return x; }
34 template<typename T>
35 T& optional_get(boost::optional<T>& x) { return x.get(); }
36 template<typename T>
37 T& optional_get(boost::optional<T&>& x) { return x.get(); }
38
39 } } } // namespace
40
41 #endif // #include guard
42