From 2f642a5f0ecf2e04c533df9d99c9b3301abbdc83 Mon Sep 17 00:00:00 2001 From: Simon Brand Date: Tue, 19 Feb 2019 16:03:35 +0000 Subject: [PATCH] Remove whitespace changes --- tl/expected.hpp | 208 ++++++++++++++++++++++++------------------------ 1 file changed, 104 insertions(+), 104 deletions(-) diff --git a/tl/expected.hpp b/tl/expected.hpp index 359ef00..ad8dc81 100644 --- a/tl/expected.hpp +++ b/tl/expected.hpp @@ -71,31 +71,30 @@ #define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) \ std::is_trivially_destructible -// GCC 5 < v < 8 has a bug in is_trivially_copy_constructible which breaks -// std::vector for non-copyable types -#elif (defined(__GNUC__) && __GNUC__ < 8 && !defined(__clang__)) +// GCC 5 < v < 8 has a bug in is_trivially_copy_constructible which breaks std::vector +// for non-copyable types +#elif (defined(__GNUC__) && __GNUC__ < 8 && \ + !defined(__clang__)) #ifndef TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX #define TL_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX namespace tl { -namespace detail { -template -struct is_trivially_copy_constructible - : std::is_trivially_copy_constructible {}; + namespace detail { + template + struct is_trivially_copy_constructible : std::is_trivially_copy_constructible{}; #ifdef _GLIBCXX_VECTOR -template -struct is_trivially_copy_constructible> - : std::is_trivially_copy_constructible {}; + template + struct is_trivially_copy_constructible> + : std::is_trivially_copy_constructible{}; #endif -} // namespace detail -} // namespace tl + } +} #endif -#define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \ +#define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \ tl::detail::is_trivially_copy_constructible -#define TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \ +#define TL_EXPECTED_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \ std::is_trivially_copy_assignable -#define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) \ - std::is_trivially_destructible +#define TL_EXPECTED_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible #else /// \exclude #define TL_EXPECTED_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \ @@ -124,7 +123,7 @@ struct is_trivially_copy_constructible> /// \exclude #define TL_EXPECTED_11_CONSTEXPR #else - /// \exclude +/// \exclude #define TL_EXPECTED_11_CONSTEXPR constexpr #endif @@ -220,24 +219,23 @@ static constexpr unexpect_t unexpect{}; /// \exclude namespace detail { -template +template [[noreturn]] TL_EXPECTED_11_CONSTEXPR void throw_exception(E &&e) { #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED - throw std::forward(e); + throw std::forward(e); #else -#ifdef _MSC_VER - __assume(0); -#else - __builtin_unreachable(); -#endif + #ifdef _MSC_VER + __assume(0); + #else + __builtin_unreachable(); + #endif #endif } #ifndef TL_TRAITS_MUTEX #define TL_TRAITS_MUTEX // C++14-style aliases for brevity -template -using remove_const_t = typename std::remove_const::type; +template using remove_const_t = typename std::remove_const::type; template using remove_reference_t = typename std::remove_reference::type; template using decay_t = typename std::decay::type; @@ -277,11 +275,9 @@ template struct invoke_result_impl; template struct invoke_result_impl< - F, - decltype(detail::invoke(std::declval(), std::declval()...), void()), + F, decltype(detail::invoke(std::declval(), std::declval()...), void()), Us...> { - using type = - decltype(detail::invoke(std::declval(), std::declval()...)); + using type = decltype(detail::invoke(std::declval(), std::declval()...)); }; template @@ -402,10 +398,14 @@ using is_move_constructible_or_void = is_void_or>; template -using is_copy_assignable_or_void = is_void_or>; +using is_copy_assignable_or_void = + is_void_or>; + template -using is_move_assignable_or_void = is_void_or>; +using is_move_assignable_or_void = + is_void_or>; + } // namespace detail @@ -684,7 +684,7 @@ struct expected_operations_base : expected_storage_base { this->m_has_val = false; } -#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED + #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED // These assign overloads ensure that the most efficient assignment // implementation is used while maintaining the strong exception guarantee. @@ -776,7 +776,7 @@ struct expected_operations_base : expected_storage_base { } } -#else + #else // If exceptions are disabled then we can just copy-construct void assign(const expected_operations_base &rhs) noexcept { @@ -797,7 +797,7 @@ struct expected_operations_base : expected_storage_base { } } -#endif + #endif // The common part of move/copy assigning template void assign_common(Rhs &&rhs) { @@ -805,7 +805,7 @@ struct expected_operations_base : expected_storage_base { if (rhs.m_has_val) { get() = std::forward(rhs).get(); } else { - destroy_val(); + destroy_val(); construct_error(std::forward(rhs).geterr()); } } else { @@ -837,7 +837,9 @@ struct expected_operations_base : expected_storage_base { } #endif - constexpr void destroy_val() { get().~T(); } + constexpr void destroy_val() { + get().~T(); + } }; // This base class provides some handy member functions which can be used in @@ -891,7 +893,7 @@ struct expected_operations_base : expected_storage_base { #endif constexpr void destroy_val() { - // no-op + //no-op } }; @@ -1221,11 +1223,9 @@ class expected : private detail::expected_move_assign_base, static_assert(!std::is_reference::value, "E must not be a reference"); T *valptr() { return std::addressof(this->m_val); } - const T *valptr() const { return std::addressof(this->m_val); } + const T *valptr() const { return std::addressof(this->m_val); } unexpected *errptr() { return std::addressof(this->m_unexpect); } - const unexpected *errptr() const { - return std::addressof(this->m_unexpect); - } + const unexpected *errptr() const { return std::addressof(this->m_unexpect); } template ::value> * = nullptr> @@ -1381,8 +1381,8 @@ public: /// \group map /// \synopsis template constexpr auto map(F &&f) &&; template - TL_EXPECTED_11_CONSTEXPR decltype(expected_map_impl(std::declval(), - std::declval())) + TL_EXPECTED_11_CONSTEXPR decltype( + expected_map_impl(std::declval(), std::declval())) map(F &&f) && { return expected_map_impl(std::move(*this), std::forward(f)); } @@ -1494,8 +1494,8 @@ public: /// \requires `F` is invokable with `E`, and `std::invoke_result_t` /// must be void or convertible to `expcted`. /// \effects If `*this` has a value, returns `*this`. - /// Otherwise, if `f` returns `void`, calls `std::forward(f)(E)` and - /// returns `std::nullopt`. Otherwise, returns `std::forward(f)(E)`. + /// Otherwise, if `f` returns `void`, calls `std::forward(f)(E)` and returns + /// `std::nullopt`. Otherwise, returns `std::forward(f)(E)`. /// /// \group or_else template expected TL_EXPECTED_11_CONSTEXPR or_else(F &&f) & { @@ -1604,7 +1604,7 @@ public: if (rhs.has_value()) { this->construct(*rhs); } else { - this->construct_error(rhs.error()); + this->construct_error(rhs.error()); } } @@ -1620,8 +1620,8 @@ public: if (rhs.has_value()) { this->construct(*rhs); } else { - this->construct_error(rhs.error()); - } + this->construct_error(rhs.error()); + } } template < @@ -1634,8 +1634,8 @@ public: if (rhs.has_value()) { this->construct(std::move(*rhs)); } else { - this->construct_error(std::move(rhs.error())); - } + this->construct_error(std::move(rhs.error())); + } } /// \exclude @@ -1649,8 +1649,8 @@ public: if (rhs.has_value()) { this->construct(std::move(*rhs)); } else { - this->construct_error(std::move(rhs.error())); - } + this->construct_error(std::move(rhs.error())); + } } template < @@ -1712,7 +1712,7 @@ public: auto tmp = std::move(err()); err().~unexpected(); -#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED + #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED try { ::new (valptr()) T(std::forward(v)); this->m_has_val = true; @@ -1720,10 +1720,10 @@ public: err() = std::move(tmp); throw; } -#else - ::new (valptr()) T(std::forward(v)); - this->m_has_val = true; -#endif + #else + ::new (valptr()) T(std::forward(v)); + this->m_has_val = true; + #endif } return *this; @@ -1781,7 +1781,7 @@ public: auto tmp = std::move(err()); err().~unexpected(); -#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED + #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED try { ::new (valptr()) T(std::forward(args)...); this->m_has_val = true; @@ -1789,10 +1789,10 @@ public: err() = std::move(tmp); throw; } -#else + #else ::new (valptr()) T(std::forward(args)...); this->m_has_val = true; -#endif + #endif } } @@ -1822,7 +1822,7 @@ public: auto tmp = std::move(err()); err().~unexpected(); -#ifdef TL_EXPECTED_EXCEPTIONS_ENABLED + #ifdef TL_EXPECTED_EXCEPTIONS_ENABLED try { ::new (valptr()) T(il, std::forward(args)...); this->m_has_val = true; @@ -1830,10 +1830,10 @@ public: err() = std::move(tmp); throw; } -#else + #else ::new (valptr()) T(il, std::forward(args)...); this->m_has_val = true; -#endif + #endif } } @@ -1854,7 +1854,7 @@ private: swap(val(), rhs.val()); } - void swap_where_only_one_has_value(expected &rhs, t_is_void) noexcept ( + void swap_where_only_one_has_value(expected &rhs, t_is_void) noexcept( std::is_nothrow_move_constructible::value) { ::new (errptr()) unexpected_type(std::move(rhs.err())); rhs.err().~unexpected_type(); @@ -1863,8 +1863,8 @@ private: void swap_where_only_one_has_value(expected &rhs, t_is_not_void) { swap_where_only_one_has_value_and_t_is_not_void( - rhs, std::is_nothrow_move_constructible::type{}, - std::is_nothrow_move_constructible::type{}); + rhs, typename std::is_nothrow_move_constructible::type{}, + typename std::is_nothrow_move_constructible::type{}); } void swap_where_only_one_has_value_and_t_is_not_void( @@ -1922,11 +1922,11 @@ public: &&std::is_nothrow_move_constructible::value &&detail::is_nothrow_swappable::value) { if (has_value() && rhs.has_value()) { - swap_where_both_have_value(rhs, std::is_void::type{}); + swap_where_both_have_value(rhs, typename std::is_void::type{}); } else if (!has_value() && rhs.has_value()) { rhs.swap(*this); } else if (has_value()) { - swap_where_only_one_has_value(rhs, std::is_void::type{}); + swap_where_only_one_has_value(rhs, typename std::is_void::type{}); } else { using std::swap; swap(err(), rhs.err()); @@ -2092,7 +2092,7 @@ constexpr auto and_then_impl(Exp &&exp, F &&f) -> Ret { #ifdef TL_EXPECTED_CXX14 template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), *std::declval())), detail::enable_if_t::value> * = nullptr> @@ -2104,7 +2104,7 @@ constexpr auto expected_map_impl(Exp &&exp, F &&f) { } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), *std::declval())), detail::enable_if_t::value> * = nullptr> @@ -2129,7 +2129,7 @@ constexpr auto expected_map_impl(Exp &&exp, F &&f) { } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval())), detail::enable_if_t::value> * = nullptr> auto expected_map_impl(Exp &&exp, F &&f) { @@ -2140,10 +2140,10 @@ auto expected_map_impl(Exp &&exp, F &&f) { } return result(unexpect, std::forward(exp).error()); -} +} #else template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), *std::declval())), detail::enable_if_t::value> * = nullptr> @@ -2158,7 +2158,7 @@ constexpr auto expected_map_impl(Exp &&exp, F &&f) } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), *std::declval())), detail::enable_if_t::value> * = nullptr> @@ -2173,7 +2173,7 @@ auto expected_map_impl(Exp &&exp, F &&f) -> expected> { } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval())), detail::enable_if_t::value> * = nullptr> @@ -2186,7 +2186,7 @@ constexpr auto expected_map_impl(Exp &&exp, F &&f) } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval())), detail::enable_if_t::value> * = nullptr> @@ -2197,13 +2197,13 @@ auto expected_map_impl(Exp &&exp, F &&f) -> expected> { } return unexpected>(std::forward(exp).error()); -} +} #endif #if defined(TL_EXPECTED_CXX14) && !defined(TL_EXPECTED_GCC49) && \ !defined(TL_EXPECTED_GCC54) && !defined(TL_EXPECTED_GCC55) template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), detail::enable_if_t::value> * = nullptr> @@ -2215,7 +2215,7 @@ constexpr auto map_error_impl(Exp &&exp, F &&f) { std::forward(exp).error())); } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), detail::enable_if_t::value> * = nullptr> @@ -2229,7 +2229,7 @@ auto map_error_impl(Exp &&exp, F &&f) { return result(unexpect, monostate{}); } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), detail::enable_if_t::value> * = nullptr> @@ -2241,7 +2241,7 @@ constexpr auto map_error_impl(Exp &&exp, F &&f) { std::forward(exp).error())); } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), detail::enable_if_t::value> * = nullptr> @@ -2253,10 +2253,10 @@ auto map_error_impl(Exp &&exp, F &&f) { detail::invoke(std::forward(f), std::forward(exp).error()); return result(unexpect, monostate{}); -} +} #else template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), detail::enable_if_t::value> * = nullptr> @@ -2271,7 +2271,7 @@ constexpr auto map_error_impl(Exp &&exp, F &&f) } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), detail::enable_if_t::value> * = nullptr> @@ -2286,7 +2286,7 @@ auto map_error_impl(Exp &&exp, F &&f) -> expected, monostate> { } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), detail::enable_if_t::value> * = nullptr> @@ -2301,7 +2301,7 @@ constexpr auto map_error_impl(Exp &&exp, F &&f) } template >::value> * = nullptr, + detail::enable_if_t>::value> * = nullptr, class Ret = decltype(detail::invoke(std::declval(), std::declval().error())), detail::enable_if_t::value> * = nullptr> @@ -2313,7 +2313,7 @@ auto map_error_impl(Exp &&exp, F &&f) -> expected, monostate> { detail::invoke(std::forward(f), std::forward(exp).error()); return result(unexpect, monostate{}); -} +} #endif #ifdef TL_EXPECTED_CXX14 @@ -2323,9 +2323,9 @@ template ::value> * = nullptr> constexpr auto or_else_impl(Exp &&exp, F &&f) { static_assert(detail::is_expected::value, "F must return an expected"); - return exp.has_value() ? std::forward(exp) - : detail::invoke(std::forward(f), - std::forward(exp).error()); + return exp.has_value() + ? std::forward(exp) + : detail::invoke(std::forward(f), std::forward(exp).error()); } template ().error())), detail::enable_if_t::value> * = nullptr> detail::decay_t or_else_impl(Exp &&exp, F &&f) { - return exp.has_value() ? std::forward(exp) - : (detail::invoke(std::forward(f), - std::forward(exp).error()), - std::forward(exp)); + return exp.has_value() + ? std::forward(exp) + : (detail::invoke(std::forward(f), std::forward(exp).error()), + std::forward(exp)); } #else template (), std::declval().error())), - detail::enable_if_t::value> * = nullptr> + detail::enable_if_t::value> * = nullptr> auto or_else_impl(Exp &&exp, F &&f) -> Ret { static_assert(detail::is_expected::value, "F must return an expected"); - return exp.has_value() ? std::forward(exp) - : detail::invoke(std::forward(f), - std::forward(exp).error()); + return exp.has_value() + ? std::forward(exp) + : detail::invoke(std::forward(f), std::forward(exp).error()); } template (), std::declval().error())), - detail::enable_if_t::value> * = nullptr> + detail::enable_if_t::value> * = nullptr> detail::decay_t or_else_impl(Exp &&exp, F &&f) { - return exp.has_value() ? std::forward(exp) - : (detail::invoke(std::forward(f), - std::forward(exp).error()), - std::forward(exp)); + return exp.has_value() + ? std::forward(exp) + : (detail::invoke(std::forward(f), std::forward(exp).error()), + std::forward(exp)); } #endif } // namespace detail