Skip to content

Commit cc7d886

Browse files
committed
Bug#33302907 remove C++11 support from stdx/type_traits.h
Issue ===== mysql/harness/stdx/*.h contain several types and templates that look like their C++17 equivalents: - stdx::conjunction, stdx::disjunction, stdx::negation - stdx::void_t - stdx::in_place_t and stdx::in_place Change ====== - remove SUNPRO_CC specific defines from stdx::expected - replaced stdx::conjunction with std::conjunction - replaced stdx::disjunction with std::disjunction - replaced stdx::negation with std::negation - replaced stdx::in_place_t with std::in_place_t - replaced stdx::void_t with std::void_t - removed stdx::in_place_t - removed stdx::void_t RB: 26937
1 parent aabecff commit cc7d886

File tree

18 files changed

+54
-210
lines changed

18 files changed

+54
-210
lines changed

router/src/harness/include/mysql/harness/net_ts/buffer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ template <class T, class BufferType,
198198
std::declval<typename std::add_lvalue_reference<T>::type>()))>
199199
using buffer_sequence_requirements = std::integral_constant<
200200
bool,
201-
stdx::conjunction<
201+
std::conjunction<
202202
// check if buffer_sequence_begin(T &) and buffer_sequence_end(T &)
203203
// exist and return the same type
204204
std::is_same<Begin, End>,
@@ -212,7 +212,7 @@ struct is_buffer_sequence : std::false_type {};
212212

213213
template <class T, class BufferType>
214214
struct is_buffer_sequence<
215-
T, BufferType, stdx::void_t<buffer_sequence_requirements<T, BufferType>>>
215+
T, BufferType, std::void_t<buffer_sequence_requirements<T, BufferType>>>
216216
: std::true_type {};
217217

218218
template <class T>
@@ -246,7 +246,7 @@ struct is_dynamic_buffer : std::false_type {};
246246
template <class T, class U = std::remove_const_t<T>>
247247
auto dynamic_buffer_requirements(U *__x = nullptr, const U *__const_x = nullptr,
248248
size_t __n = 0)
249-
-> std::enable_if_t<stdx::conjunction<
249+
-> std::enable_if_t<std::conjunction<
250250
// is copy constructible
251251
std::is_copy_constructible<U>,
252252
// has a const_buffers_type that's a const_buffer_sequence

router/src/harness/include/mysql/harness/net_ts/executor.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939

4040
#include "my_compiler.h"
4141
#include "mysql/harness/net_ts/netfwd.h"
42-
#include "mysql/harness/stdx/type_traits.h" // conjunction, void_t
4342

4443
namespace net {
4544
enum class fork_event { prepare, parent, child };
@@ -102,7 +101,7 @@ using associated_allocator_t =
102101

103102
MY_COMPILER_DIAGNOSTIC_POP()
104103

105-
template <class T, class ProtoAllocator, typename = stdx::void_t<>>
104+
template <class T, class ProtoAllocator, typename = std::void_t<>>
106105
struct associated_allocator_impl {
107106
using type = ProtoAllocator;
108107

@@ -113,7 +112,7 @@ struct associated_allocator_impl {
113112

114113
template <class T, class ProtoAllocator>
115114
struct associated_allocator_impl<T, ProtoAllocator,
116-
stdx::void_t<typename T::allocator_type>> {
115+
std::void_t<typename T::allocator_type>> {
117116
using type = typename T::allocator_type;
118117

119118
static type __get(const T &t, const ProtoAllocator & /* a */) noexcept {
@@ -324,7 +323,7 @@ class execution_context::service {
324323
//
325324
namespace impl {
326325

327-
template <class T, class = stdx::void_t<>>
326+
template <class T, class = std::void_t<>>
328327
struct is_executor : std::false_type {};
329328

330329
// checker for the requirements of a executor
@@ -347,7 +346,7 @@ auto executor_requirements(U *__x = nullptr, const U *__const_x = nullptr,
347346
void (*f)() = nullptr,
348347
const std::allocator<int> &a = {})
349348
-> std::enable_if_t<
350-
stdx::conjunction<
349+
std::conjunction<
351350
std::is_copy_constructible<T>,
352351
// methods/operators must exist
353352
std::is_same<decltype(*__const_x == *__const_x), bool>,
@@ -359,7 +358,7 @@ auto executor_requirements(U *__x = nullptr, const U *__const_x = nullptr,
359358
std::is_void<decltype(__x->defer(std::move(f), a))>>::value,
360359

361360
// context() may either return execution_context & or E&
362-
stdx::void_t<decltype(__x->context()), void()>>;
361+
std::void_t<decltype(__x->context()), void()>>;
363362

364363
template <class T>
365364
struct is_executor<T, decltype(executor_requirements<T>())> : std::true_type {};
@@ -380,11 +379,11 @@ constexpr executor_arg_t executor_arg = executor_arg_t();
380379

381380
namespace impl {
382381

383-
template <class T, class Executor, typename = stdx::void_t<>>
382+
template <class T, class Executor, typename = std::void_t<>>
384383
struct uses_executor : std::false_type {};
385384

386385
template <class T, class Executor>
387-
struct uses_executor<T, Executor, stdx::void_t<typename T::executor_type>>
386+
struct uses_executor<T, Executor, std::void_t<typename T::executor_type>>
388387
: std::is_convertible<Executor, typename T::executor_type> {};
389388

390389
} // namespace impl
@@ -396,7 +395,7 @@ template <class T, class Executor>
396395
constexpr bool uses_executor_v = uses_executor<T, Executor>::value;
397396

398397
// 13.12 [async.assoc.exec]
399-
template <class T, class Executor, typename = stdx::void_t<>>
398+
template <class T, class Executor, typename = std::void_t<>>
400399
struct associated_executor_impl {
401400
using type = Executor;
402401

@@ -407,7 +406,7 @@ struct associated_executor_impl {
407406

408407
template <class T, class Executor>
409408
struct associated_executor_impl<T, Executor,
410-
stdx::void_t<typename T::executor_type>> {
409+
std::void_t<typename T::executor_type>> {
411410
using type = typename T::executor_type;
412411

413412
static type __get(const T &t, const Executor & /* a */) noexcept {

router/src/harness/include/mysql/harness/net_ts/impl/resolver.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242
#include "mysql/harness/net_ts/impl/socket_error.h" // socket::last_error_code
4343
#include "mysql/harness/stdx/expected.h"
44-
#include "mysql/harness/stdx/type_traits.h" // stdx::in_place
4544

4645
namespace net {
4746
namespace ip {
@@ -262,7 +261,7 @@ getaddrinfo(const char *node, const char *service,
262261
#endif
263262
}
264263

265-
return {stdx::in_place, ainfo, &::freeaddrinfo};
264+
return {std::in_place, ainfo, &::freeaddrinfo};
266265
}
267266

268267
inline stdx::expected<const char *, std::error_code> inetntop(int af,

router/src/harness/include/mysql/harness/net_ts/internet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ inline stdx::expected<address_v6, std::error_code> make_address_v6(
412412
inet_pton_res = ::inet_pton(AF_INET6, str, &ipv6_addr);
413413
}
414414
if (inet_pton_res == 1) {
415-
return {stdx::in_place_t(), ipv6_addr, scope_id};
415+
return {std::in_place, ipv6_addr, scope_id};
416416
} else if (inet_pton_res == 0) {
417417
// parse failed
418418
return stdx::make_unexpected(make_error_code(std::errc::invalid_argument));

router/src/harness/include/mysql/harness/net_ts/socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ class basic_socket_impl : public basic_socket_impl_base {
550550
endpoint_size);
551551
if (!res) return stdx::make_unexpected(res.error());
552552

553-
return {stdx::in_place, io_ctx, protocol_, std::move(res.value())};
553+
return {std::in_place, io_ctx, protocol_, std::move(res.value())};
554554
}
555555

556556
stdx::expected<socket_type, error_type> accept(io_context &io_ctx,

router/src/harness/include/mysql/harness/net_ts/win32_named_pipe.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,14 +598,14 @@ class basic_named_pipe_acceptor : public basic_named_pipe_impl<Protocol> {
598598
// ERROR_NO_DATA too, it just meands the pipe is already closed, but quite
599599
// likely readable.
600600
if (last_ec == ec_pipe_connected || last_ec == ec_no_data) {
601-
return {stdx::in_place, get_executor().context(), protocol,
601+
return {std::in_place, get_executor().context(), protocol,
602602
release().value()};
603603
}
604604

605605
return stdx::make_unexpected(last_ec);
606606
}
607607

608-
return {stdx::in_place, get_executor().context(), protocol,
608+
return {std::in_place, get_executor().context(), protocol,
609609
release().value()};
610610
}
611611

router/src/harness/include/mysql/harness/stdx/expected.h

Lines changed: 20 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
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

394393
template <class B>
395-
using not_ = stdx::negation<B>;
394+
using not_ = std::negation<B>;
396395

397396
template <class... B>
398-
using and_ = stdx::conjunction<B...>;
397+
using and_ = std::conjunction<B...>;
399398

400399
template <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
};

router/src/harness/include/mysql/harness/stdx/expected_ostream.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030
#include <ostream>
3131
#include <type_traits>
3232

33-
#include "mysql/harness/stdx/type_traits.h"
34-
3533
// operator<< for std::expected
3634
//
3735
// the functions are kept in a separate header as it
@@ -46,7 +44,7 @@ struct is_to_stream_writable : std::false_type {};
4644

4745
template <typename S, typename T>
4846
struct is_to_stream_writable<
49-
S, T, stdx::void_t<decltype(std::declval<S &>() << std::declval<T>())>>
47+
S, T, std::void_t<decltype(std::declval<S &>() << std::declval<T>())>>
5048
: std::true_type {};
5149

5250
} // namespace impl

0 commit comments

Comments
 (0)