3232#include < new> // ::operator new
3333#include < utility> // std::forward
3434
35- #include " mysql/harness/stdx/type_traits.h"
36- #if defined(__GNUC__) || defined(__clang__) || defined(__SUNPRO_CC)
35+ #if defined(__GNUC__) || defined(__clang__)
3736#define RESO_ASSUME (x ) \
3837 if (!(x)) __builtin_unreachable();
3938#elif defined(_MSC_VER)
@@ -133,7 +132,7 @@ union storage_t {
133132 template <class ... Args,
134133 typename std::enable_if_t <
135134 std::is_constructible<T, Args &&...>::value, void *> = nullptr >
136- void construct_value (in_place_t , Args &&... args) {
135+ void construct_value (std:: in_place_t , Args &&... args) {
137136 new (&value_) value_type (std::forward<Args>(args)...);
138137 }
139138
@@ -147,7 +146,7 @@ union storage_t {
147146 // enable inplace construction of error, if the E supports it
148147 template <class ... Args, typename std::enable_if_t <std::is_constructible<
149148 E, Args &&...>::value> * = nullptr >
150- void construct_error (in_place_t , Args &&... args) {
149+ void construct_error (std:: in_place_t , Args &&... args) {
151150 new (&error_) error_type (std::forward<Args>(args)...);
152151 }
153152
@@ -201,7 +200,7 @@ union storage_t<T, void> {
201200 template <class ... Args,
202201 typename std::enable_if_t <
203202 std::is_constructible<T, Args &&...>::value, void *> = nullptr >
204- void construct_value (in_place_t , Args &&... args) {
203+ void construct_value (std:: in_place_t , Args &&... args) {
205204 new (&value_) value_type (std::forward<Args>(args)...);
206205 }
207206
@@ -243,7 +242,7 @@ union storage_t<void, E> {
243242 template <
244243 class ... Args,
245244 std::enable_if_t <std::is_constructible<E, Args &&...>::value> * = nullptr >
246- void construct_error (in_place_t , Args &&... args) {
245+ void construct_error (std:: in_place_t , Args &&... args) {
247246 new (&error_) error_type (std::forward<Args>(args)...);
248247 }
249248
@@ -392,13 +391,13 @@ struct assign_base<member_policy::copy | member_policy::move> {
392391};
393392
394393template <class B >
395- using not_ = stdx ::negation<B>;
394+ using not_ = std ::negation<B>;
396395
397396template <class ... B>
398- using and_ = stdx ::conjunction<B...>;
397+ using and_ = std ::conjunction<B...>;
399398
400399template <class ... B>
401- using or_ = stdx ::disjunction<B...>;
400+ using or_ = std ::disjunction<B...>;
402401
403402// enable copy constructor if T and E are copy-constructible or void
404403// enable move constructor if T and E are move-constructible or void
@@ -472,38 +471,11 @@ class ExpectedImpl : public ExpectedImplBase {
472471 }
473472
474473 // enable inplace construction of value_type, if the T supports it
475- template <
476- class ... Args
477- #if !defined(__SUNPRO_CC)
478- // disabled the 'is_constructible' check as it triggers:
479- //
480- // >> Assertion: (../lnk/substitute.cc, line 1131)
481- // while processing ./test_expected.cc at line 4.
482- //
483- // with devstudio-12.6's CC
484- //
485- // That means:
486- //
487- // stdx::expected<std::string, void> res(stdx::in_place, 1.0); will report
488- // the error for:
489- //
490- // Could not find a match for stdx::base::storage_t<std::string,
491- // double>::construct_value(const stdx::in_place_t, double)
492- //
493- // Instead for
494- //
495- // Could not find a match for stdx::base::ExpectedImpl<std::string,
496- // double>::ExpectedImpl(const stdx::in_place_t, double)
497- //
498- // as the same check is done in construct_value() and does not trigger
499- // the assertion.
500- ,
501- typename std::enable_if_t <std::is_constructible<T, Args &&...>::value> * =
502- nullptr
503- #endif
504- >
505- constexpr ExpectedImpl (in_place_t , Args &&... args) : ExpectedImplBase{true } {
506- storage_.construct_value (stdx::in_place, std::forward<Args>(args)...);
474+ template <class ... Args, typename std::enable_if_t <std::is_constructible<
475+ T, Args &&...>::value> * = nullptr >
476+ constexpr ExpectedImpl (std::in_place_t , Args &&... args)
477+ : ExpectedImplBase{true } {
478+ storage_.construct_value (std::in_place, std::forward<Args>(args)...);
507479 }
508480
509481 constexpr ExpectedImpl (const ExpectedImpl &other)
@@ -798,17 +770,11 @@ class ExpectedImpl<T, void> : public ExpectedImplBase {
798770 }
799771
800772 // enable inplace construction of value_type, if the T supports it
801- template <class ... Args
802- #if !defined(__SUNPRO_CC)
803- // see the generic ExpectedImpl(in_place_t, ...) why this check is
804- // disabled.
805- ,
806- typename std::enable_if_t <
807- std::is_constructible<T, Args &&...>::value> * = nullptr
808- #endif
809- >
810- constexpr ExpectedImpl (in_place_t , Args &&... args) : ExpectedImplBase{true } {
811- storage_.construct_value (stdx::in_place, std::forward<Args>(args)...);
773+ template <class ... Args, typename std::enable_if_t <std::is_constructible<
774+ T, Args &&...>::value> * = nullptr >
775+ constexpr ExpectedImpl (std::in_place_t , Args &&... args)
776+ : ExpectedImplBase{true } {
777+ storage_.construct_value (std::in_place, std::forward<Args>(args)...);
812778 }
813779
814780 constexpr ExpectedImpl (const ExpectedImpl &other)
@@ -993,74 +959,12 @@ class expected : public ExpectedImpl<T, E>,
993959 private base::select_ctor_base<T, E> {
994960 public:
995961 static_assert (!std::is_reference<T>::value, " T must not be a reference" );
996- static_assert (!std::is_same<T, std::remove_cv<in_place_t >>::value,
997- " T must not be in_place_t" );
962+ static_assert (!std::is_same<T, std::remove_cv<std:: in_place_t >>::value,
963+ " T must not be std:: in_place_t" );
998964 static_assert (!std::is_same<T, std::remove_cv<unexpected<E>>>::value,
999965 " T must not be unexpected<E>" );
1000966 static_assert (!std::is_reference<E>::value, " E must not be a reference" );
1001967
1002- #if defined(__SUNPRO_CC)
1003- // sunpro generates a wrong default assign-move which forces use
1004- // to declare all the implicit constructors/assign-ops explicitly
1005- // as default which leads to slightly worse error-messages:
1006- //
1007- // clang:
1008- //
1009- // call to implicitly-deleted default constructor of
1010- // 'stdx::expected<no_default_construct, void>'
1011- //
1012- // note: default constructor of
1013- // 'expected<no_default_construct, void>' is implicitly deleted
1014- // because base class 'ExpectedImpl<no_default_construct, void>' has no
1015- // default constructor
1016- //
1017- // vs.
1018- //
1019- // call to implicitly-deleted default constructor of
1020- // 'stdx::expected<no_default_construct, void>'
1021- //
1022- // explicitly defaulted function was implicitly deleted here
1023- // expected() = default;
1024- //
1025- // note: default constructor of
1026- // 'expected<no_default_construct, void>' is implicitly deleted
1027- // because base class 'ExpectedImpl<no_default_construct, void>' has no
1028- // default constructor
1029- //
1030- expected () = default;
1031-
1032- expected (const expected &) = default;
1033- expected &operator =(const expected &) = default ;
1034-
1035- // sunpro generates the default move-assign, move-construct which:
1036- //
1037- // 1. ExpectedImpl<T, E>::operator=(std::move(other))
1038- // 2. memmove(this, &other, sizeof(other));
1039- //
1040- // where the memmove trashes the just moved value
1041-
1042- #if 0
1043- // this constructor should be only visible if T and E and move-constructible
1044- // but with sunpro it leads to
1045- //
1046- // CC: Fatal error in .../developerstudio12.6/lib/compilers/bin/ccfe : Signal number = 139
1047- //
1048- // Therefore, it is left unconditionally enabled which makes this type
1049- // look move-constructible even though it may not be.
1050- template <
1051- bool B = std::is_move_constructible<base::select_ctor_base<T, E>>::value,
1052- std::enable_if_t<B> * = nullptr>
1053- #endif
1054- expected (expected &&other) : ExpectedImpl<T, E>{std::move (other)} {}
1055-
1056- template <bool B = std::is_move_assignable<T>::value,
1057- std::enable_if_t <B> * = nullptr >
1058- expected &operator =(expected &&other) {
1059- ExpectedImpl<T, E>::operator =(std::move (other));
1060- return *this ;
1061- }
1062- #endif
1063-
1064968 // inherit all the constructors of our base
1065969 using ExpectedImpl<T, E>::ExpectedImpl;
1066970};
0 commit comments