From 21ab7cea4f12c37795224a81ce326797a7da44c0 Mon Sep 17 00:00:00 2001 From: Simon Brand Date: Sat, 21 Oct 2017 22:55:58 +0100 Subject: [PATCH] Comments --- optional.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/optional.hpp b/optional.hpp index affebb0..114b13f 100644 --- a/optional.hpp +++ b/optional.hpp @@ -53,6 +53,8 @@ template class optional; /// \exclude namespace detail { + +// C++14-style aliases for brevity template using remove_const_t = typename std::remove_const::type; template using remove_reference_t = typename std::remove_reference::type; @@ -62,21 +64,23 @@ using enable_if_t = typename std::enable_if::type; template using conditional_t = typename std::conditional::type; +// std::conjunction from C++17 template struct conjunction : std::true_type {}; template struct conjunction : B {}; template struct conjunction : std::conditional, B>::type {}; +// std::void_t from C++17 template struct voider { using type = void; }; template using void_t = typename voider::type; +// Trait for checking if a type is a tl::optional template struct is_optional_impl : std::false_type {}; - template struct is_optional_impl> : std::true_type {}; - template using is_optional = is_optional_impl>; +// std::invoke from C++17 // https://stackoverflow.com/questions/38288042/c11-14-invoke-workaround template >{}>, @@ -95,6 +99,7 @@ constexpr auto invoke(Fn &&f, Args &&... args) noexcept( return std::forward(f)(std::forward(args)...); } +// std::invoke_result from C++17 template struct invoke_result_impl; template @@ -110,6 +115,8 @@ using invoke_result = invoke_result_impl; template using invoke_result_t = typename invoke_result::type; + +// Change void to tl::monostate template using fixup_void = conditional_t::value, monostate, U>; @@ -129,6 +136,7 @@ using get_invoke_ret = typename conditional_t::value, template using get_map_return = optional>>; +// Check if invoking F for some Us returns void template using returns_void = std::is_void>;