32
32
#include < new> // ::operator new
33
33
#include < utility> // std::forward
34
34
35
- #include " mysql/harness/stdx/type_traits.h"
36
- #if defined(__GNUC__) || defined(__clang__) || defined(__SUNPRO_CC)
35
+ #if defined(__GNUC__) || defined(__clang__)
37
36
#define RESO_ASSUME (x ) \
38
37
if (!(x)) __builtin_unreachable();
39
38
#elif defined(_MSC_VER)
@@ -133,7 +132,7 @@ union storage_t {
133
132
template <class ... Args,
134
133
typename std::enable_if_t <
135
134
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) {
137
136
new (&value_) value_type (std::forward<Args>(args)...);
138
137
}
139
138
@@ -147,7 +146,7 @@ union storage_t {
147
146
// enable inplace construction of error, if the E supports it
148
147
template <class ... Args, typename std::enable_if_t <std::is_constructible<
149
148
E, Args &&...>::value> * = nullptr >
150
- void construct_error (in_place_t , Args &&... args) {
149
+ void construct_error (std:: in_place_t , Args &&... args) {
151
150
new (&error_) error_type (std::forward<Args>(args)...);
152
151
}
153
152
@@ -201,7 +200,7 @@ union storage_t<T, void> {
201
200
template <class ... Args,
202
201
typename std::enable_if_t <
203
202
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) {
205
204
new (&value_) value_type (std::forward<Args>(args)...);
206
205
}
207
206
@@ -243,7 +242,7 @@ union storage_t<void, E> {
243
242
template <
244
243
class ... Args,
245
244
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) {
247
246
new (&error_) error_type (std::forward<Args>(args)...);
248
247
}
249
248
@@ -392,13 +391,13 @@ struct assign_base<member_policy::copy | member_policy::move> {
392
391
};
393
392
394
393
template <class B >
395
- using not_ = stdx ::negation<B>;
394
+ using not_ = std ::negation<B>;
396
395
397
396
template <class ... B>
398
- using and_ = stdx ::conjunction<B...>;
397
+ using and_ = std ::conjunction<B...>;
399
398
400
399
template <class ... B>
401
- using or_ = stdx ::disjunction<B...>;
400
+ using or_ = std ::disjunction<B...>;
402
401
403
402
// enable copy constructor if T and E are copy-constructible or void
404
403
// enable move constructor if T and E are move-constructible or void
@@ -472,38 +471,11 @@ class ExpectedImpl : public ExpectedImplBase {
472
471
}
473
472
474
473
// 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)...);
507
479
}
508
480
509
481
constexpr ExpectedImpl (const ExpectedImpl &other)
@@ -798,17 +770,11 @@ class ExpectedImpl<T, void> : public ExpectedImplBase {
798
770
}
799
771
800
772
// 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)...);
812
778
}
813
779
814
780
constexpr ExpectedImpl (const ExpectedImpl &other)
@@ -993,74 +959,12 @@ class expected : public ExpectedImpl<T, E>,
993
959
private base::select_ctor_base<T, E> {
994
960
public:
995
961
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" );
998
964
static_assert (!std::is_same<T, std::remove_cv<unexpected<E>>>::value,
999
965
" T must not be unexpected<E>" );
1000
966
static_assert (!std::is_reference<E>::value, " E must not be a reference" );
1001
967
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
-
1064
968
// inherit all the constructors of our base
1065
969
using ExpectedImpl<T, E>::ExpectedImpl;
1066
970
};
0 commit comments