diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-28 14:27:03 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-06-28 14:27:03 +0200 |
commit | b5545e98eb4ecc39eb390d916cf7d909b9d69e4b (patch) | |
tree | 091f388a38c22a25919dd34a8cb5839270866eed | |
parent | b204bd9321a2d2bd0d69fa3a8c99eef921ad5894 (diff) |
More optional constexpr workarounds
-rw-r--r-- | libbutl/optional.mxx | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/libbutl/optional.mxx b/libbutl/optional.mxx index 9140432..de56d05 100644 --- a/libbutl/optional.mxx +++ b/libbutl/optional.mxx @@ -57,15 +57,18 @@ LIBBUTL_MODEXPORT namespace butl constexpr optional_data (nullopt_t): e_ (), v_ (false) {} constexpr optional_data (const T& v): d_ (v), v_ (true) {} constexpr optional_data (T&& v): d_ (std::move (v)), v_ (true) {} - - constexpr optional_data (const optional_data& o): v_ (o.v_) {if (v_) new (&d_) T (o.d_);} - constexpr optional_data (optional_data&& o): v_ (o.v_) {if (v_) new (&d_) T (std::move (o.d_));} #else optional_data (): e_ (), v_ (false) {} optional_data (nullopt_t): e_ (), v_ (false) {} optional_data (const T& v): d_ (v), v_ (true) {} optional_data (T&& v): d_ (std::move (v)), v_ (true) {} +#endif +#if (!defined(_MSC_VER) || _MSC_VER > 1900) && \ + (!defined(__GNUC__) || __GNUC__ >= 5) + constexpr optional_data (const optional_data& o): v_ (o.v_) {if (v_) new (&d_) T (o.d_);} + constexpr optional_data (optional_data&& o): v_ (o.v_) {if (v_) new (&d_) T (std::move (o.d_));} +#else optional_data (const optional_data& o): v_ (o.v_) {if (v_) new (&d_) T (o.d_);} optional_data (optional_data&& o): v_ (o.v_) {if (v_) new (&d_) T (std::move (o.d_));} #endif @@ -97,15 +100,18 @@ LIBBUTL_MODEXPORT namespace butl constexpr optional_data (nullopt_t): e_ (), v_ (false) {} constexpr optional_data (const T& v): d_ (v), v_ (true) {} constexpr optional_data (T&& v): d_ (std::move (v)), v_ (true) {} - - constexpr optional_data (const optional_data& o): v_ (o.v_) {if (v_) new (&d_) T (o.d_);} - constexpr optional_data (optional_data&& o): v_ (o.v_) {if (v_) new (&d_) T (std::move (o.d_));} #else optional_data (): e_ (), v_ (false) {} optional_data (nullopt_t): e_ (), v_ (false) {} optional_data (const T& v): d_ (v), v_ (true) {} optional_data (T&& v): d_ (std::move (v)), v_ (true) {} +#endif +#if (!defined(_MSC_VER) || _MSC_VER > 1900) && \ + (!defined(__GNUC__) || __GNUC__ >= 5) + constexpr optional_data (const optional_data& o): v_ (o.v_) {if (v_) new (&d_) T (o.d_);} + constexpr optional_data (optional_data&& o): v_ (o.v_) {if (v_) new (&d_) T (std::move (o.d_));} +#else optional_data (const optional_data& o): v_ (o.v_) {if (v_) new (&d_) T (o.d_);} optional_data (optional_data&& o): v_ (o.v_) {if (v_) new (&d_) T (std::move (o.d_));} #endif @@ -132,15 +138,18 @@ LIBBUTL_MODEXPORT namespace butl constexpr optional (nullopt_t) {} constexpr optional (const T& v): base (v) {} constexpr optional (T&& v): base (std::move (v)) {} - - constexpr optional (const optional&) = default; - constexpr optional (optional&&) = default; #else optional () {} optional (nullopt_t) {} optional (const T& v): base (v) {} optional (T&& v): base (std::move (v)) {} +#endif +#if (!defined(_MSC_VER) || _MSC_VER > 1900) && \ + (!defined(__GNUC__) || __GNUC__ >= 5) + constexpr optional (const optional&) = default; + constexpr optional (optional&&) = default; +#else optional (const optional&) = default; optional (optional&&) = default; #endif |