2 #ifndef BOOST_CONTRACT_DETAIL_OPTIONAL_HPP_
3 #define BOOST_CONTRACT_DETAIL_OPTIONAL_HPP_
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
10 #include <boost/optional.hpp>
11 #include <boost/type_traits/remove_reference.hpp>
12 #include <boost/type_traits/integral_constant.hpp>
14 namespace boost { namespace contract { namespace detail {
17 struct is_optional : boost::false_type {};
19 struct is_optional<boost::optional<T> > : boost::true_type {};
22 struct optional_value_type { typedef T type; };
24 struct optional_value_type<boost::optional<T> > { typedef T type; };
27 struct remove_value_reference_if_optional { typedef T type; };
29 struct remove_value_reference_if_optional<boost::optional<T> >
30 { typedef typename boost::remove_reference<T>::type type; };
33 T& optional_get(T& x) { return x; }
35 T& optional_get(boost::optional<T>& x) { return x.get(); }
37 T& optional_get(boost::optional<T&>& x) { return x.get(); }
41 #endif // #include guard