OZO 「お象」
Boost.Asio and libpq based asynchronous PostgreSQL unofficial header-only C++17 client library.
unwrap.h
1 #pragma once
2 
3 #include <ozo/core/nullable.h>
4 #include <ozo/core/concept.h>
5 #include <ozo/detail/functional.h>
6 
7 #include <boost/hana/core/when.hpp>
8 
9 namespace ozo {
10 
11 namespace hana = boost::hana;
12 
38 template <typename T, typename When = hana::when<true>>
39 struct unwrap_impl : detail::functional::forward {};
40 
56 template <typename T>
57 constexpr decltype(auto) unwrap(T&& v) noexcept(
58  noexcept(unwrap_impl<std::decay_t<T>>::apply(std::forward<T>(v)))) {
59  return unwrap_impl<std::decay_t<T>>::apply(std::forward<T>(v));
60 }
61 
62 template <typename T>
63 struct unwrap_impl<std::reference_wrapper<T>> {
64  template <typename Ref>
65  constexpr static decltype(auto) apply(Ref&& v) noexcept {
66  return v.get();
67  }
68 };
69 
91 template <typename T>
93 #ifdef OZO_DOCUMENTATION
94  using type = <unwrapped type>;
95 #else
96  using type = std::decay_t<decltype(ozo::unwrap(std::declval<T>()))>;
97 #endif
98 };
99 
106 template <typename T>
108 
109 } // namespace ozo
ozo::unwrap
constexpr decltype(auto) unwrap(T &&v) noexcept(noexcept(unwrap_impl< std::decay_t< T >>::apply(std::forward< T >(v))))
Unwraps argument underlying value or forwards the argument.
Definition: unwrap.h:57
ozo::get_unwrapped_type
Unwraps nullable or reference wrapped type.
Definition: unwrap.h:92
ozo::get_unwrapped_type::type
< unwrapped type > type
Unwrapped type.
Definition: unwrap.h:94
ozo::unwrap_type
typename get_unwrapped_type< T >::type unwrap_type
Shortcut for ozo::get_unwrapped_type.
Definition: unwrap.h:107
ozo::unwrap_impl
Default implementation of ozo::unwrap()
Definition: unwrap.h:39