From 874026e26b56d10b0bb9540180b564b36e685a17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 26 Jun 2020 15:29:41 +0200 Subject: Fix --- libbutl/optional.mxx | 83 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 6 deletions(-) (limited to 'libbutl/optional.mxx') diff --git a/libbutl/optional.mxx b/libbutl/optional.mxx index fe533c5..d32e14b 100644 --- a/libbutl/optional.mxx +++ b/libbutl/optional.mxx @@ -60,7 +60,7 @@ #else # include // move() # include // hash -# include // is_trivially_destructible +# include // is_* #endif #endif @@ -91,9 +91,6 @@ LIBBUTL_MODEXPORT namespace butl // Simple optional class template while waiting for std::optional. // struct nullopt_t {constexpr explicit nullopt_t (int) {}}; -#if defined(__cpp_modules_ts) && defined(__clang__) //@@ MOD Clang duplicate sym. - inline -#endif constexpr nullopt_t nullopt (1); namespace details @@ -184,12 +181,86 @@ LIBBUTL_MODEXPORT namespace butl optional_data& operator= (const optional_data&); optional_data& operator= (optional_data&&); }; + + template ::value, + bool = std::is_move_constructible::value> + struct optional_ctors: optional_data + { + using optional_data::optional_data; + }; + + template + struct optional_ctors: optional_ctors + { + using optional_ctors::optional_ctors; + +#if !defined(_MSC_VER) || _MSC_VER > 1900 + constexpr optional_ctors () = default; +#else + optional_ctors () = default; +#endif + + optional_ctors (const optional_ctors&) = delete; + +#if (!defined(_MSC_VER) || _MSC_VER > 1900) && \ + (!defined(__GNUC__) || __GNUC__ > 4 || defined(__clang__)) + constexpr optional_ctors (optional_ctors&&) = default; +#else + optional_ctors (optional_ctors&&) = default; +#endif + + optional_ctors& operator= (const optional_ctors&) = default; + optional_ctors& operator= (optional_ctors&&) = default; + }; + + template + struct optional_ctors: optional_ctors + { + using optional_ctors::optional_ctors; + +#if !defined(_MSC_VER) || _MSC_VER > 1900 + constexpr optional_ctors () = default; +#else + optional_ctors () = default; +#endif + +#if (!defined(_MSC_VER) || _MSC_VER > 1900) && \ + (!defined(__GNUC__) || __GNUC__ > 4 || defined(__clang__)) + constexpr optional_ctors (const optional_ctors&) = default; +#else + optional_ctors (const optional_ctors&) = default; +#endif + + optional_ctors (optional_ctors&&) = delete; + + optional_ctors& operator= (const optional_ctors&) = default; + optional_ctors& operator= (optional_ctors&&) = default; + }; + + template + struct optional_ctors: optional_ctors + { + using optional_ctors::optional_ctors; + +#if !defined(_MSC_VER) || _MSC_VER > 1900 + constexpr optional_ctors () = default; +#else + optional_ctors () = default; +#endif + + optional_ctors (const optional_ctors&) = delete; + optional_ctors (optional_ctors&&) = delete; + + optional_ctors& operator= (const optional_ctors&) = default; + optional_ctors& operator= (optional_ctors&&) = default; + }; } template - class optional: private details::optional_data + class optional: private details::optional_ctors { - using base = details::optional_data; + using base = details::optional_ctors; public: using value_type = T; -- cgit v1.1