Skip to content

Commit f05f234

Browse files
authored
Merge pull request #1015 from dimacurrentai/cpp14
Remove warnings in C++14 mode (i.e. w/o `-std=c++17`). Rationale: when playing with Rust-first builds, this C++ code is often build from within containers by various compilers, and almost everything but not quite everything works w/o `-std=c++17` — so I figured it's worthy of half an hour to make it all work w/o `-std=c++17`.'
2 parents d211034 + 4d50e89 commit f05f234

File tree

67 files changed

+423
-402
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+423
-402
lines changed

blocks/http/request.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ struct Request final {
9797

9898
// A shortcut to allow `[](Request r) { r("OK"); }` instead of `r.connection.SendHTTPResponse("OK")`.
9999
template <typename T, typename... TS>
100-
std::enable_if_t<!std::is_base_of_v<IHasDoRespondViaHTTP, current::decay_t<T>>> operator()(T&& arg, TS&&... args) {
100+
std::enable_if_t<!std::is_base_of<IHasDoRespondViaHTTP, current::decay_t<T>>::value> operator()(T&& arg, TS&&... args) {
101101
if (!unique_connection) {
102102
CURRENT_THROW(net::AttemptedToSendHTTPResponseMoreThanOnce());
103103
}
@@ -106,7 +106,7 @@ struct Request final {
106106

107107
// Support `Response`, as well as custom objects with user-defined HTTP response handlers.
108108
template <class T>
109-
std::enable_if_t<std::is_base_of_v<IHasDoRespondViaHTTP, current::decay_t<T>>> operator()(T&& response) {
109+
std::enable_if_t<std::is_base_of<IHasDoRespondViaHTTP, current::decay_t<T>>::value> operator()(T&& response) {
110110
if (!unique_connection) {
111111
CURRENT_THROW(net::AttemptedToSendHTTPResponseMoreThanOnce());
112112
}

blocks/http/response.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct Response final : IHasDoRespondViaHTTP {
8585
Response& operator=(const Response&) = default;
8686
Response& operator=(Response&&) = default;
8787

88-
template <typename ARG, typename... ARGS, class = std::enable_if_t<!std::is_same_v<Response, current::decay_t<ARG>>>>
88+
template <typename ARG, typename... ARGS, class = std::enable_if_t<!std::is_same<Response, current::decay_t<ARG>>::value>>
8989
Response(ARG&& arg, ARGS&&... args) : initialized(true) {
9090
Construct(std::forward<ARG>(arg), std::forward<ARGS>(args)...);
9191
}

blocks/ss/persister.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ class EntryPersister : public GenericEntryPersister<ENTRY>, public IMPL {
153153
// For `static_assert`-s.
154154
template <typename T>
155155
struct IsPersister {
156-
static constexpr bool value = std::is_base_of_v<GenericPersister, T>;
156+
static constexpr bool value = std::is_base_of<GenericPersister, T>::value;
157157
};
158158

159159
template <typename T, typename E>
160160
struct IsEntryPersister {
161-
static constexpr bool value = std::is_base_of_v<GenericEntryPersister<E>, T>;
161+
static constexpr bool value = std::is_base_of<GenericEntryPersister<E>, T>::value;
162162
};
163163

164164
} // namespace ss

blocks/ss/pubsub.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,17 @@ class StreamPublisher : public GenericStreamPublisher<ENTRY>, public EntryPublis
107107
// TODO(dkorolev): `Variant` stream types, and publishing those?
108108
template <typename T>
109109
struct IsPublisher {
110-
static constexpr bool value = std::is_base_of_v<GenericPublisher, current::decay_t<T>>;
110+
static constexpr bool value = std::is_base_of<GenericPublisher, current::decay_t<T>>::value;
111111
};
112112

113113
template <typename T, typename E>
114114
struct IsEntryPublisher {
115-
static constexpr bool value = std::is_base_of_v<GenericEntryPublisher<current::decay_t<E>>, current::decay_t<T>>;
115+
static constexpr bool value = std::is_base_of<GenericEntryPublisher<current::decay_t<E>>, current::decay_t<T>>::value;
116116
};
117117

118118
template <typename T, typename E>
119119
struct IsStreamPublisher {
120-
static constexpr bool value = std::is_base_of_v<GenericStreamPublisher<current::decay_t<E>>, current::decay_t<T>>;
120+
static constexpr bool value = std::is_base_of<GenericStreamPublisher<current::decay_t<E>>, current::decay_t<T>>::value;
121121
};
122122

123123
enum class EntryResponse { Done = 0, More = 1 };
@@ -162,17 +162,17 @@ class StreamSubscriber : public GenericStreamSubscriber<ENTRY>, public EntrySubs
162162
// For `static_assert`-s. Must `decay_t<>` for template xvalue references support.
163163
template <typename T>
164164
struct IsSubscriber {
165-
static constexpr bool value = std::is_base_of_v<GenericSubscriber, current::decay_t<T>>;
165+
static constexpr bool value = std::is_base_of<GenericSubscriber, current::decay_t<T>>::value;
166166
};
167167

168168
template <typename T, typename E>
169169
struct IsEntrySubscriber {
170-
static constexpr bool value = std::is_base_of_v<GenericEntrySubscriber<current::decay_t<E>>, current::decay_t<T>>;
170+
static constexpr bool value = std::is_base_of<GenericEntrySubscriber<current::decay_t<E>>, current::decay_t<T>>::value;
171171
};
172172

173173
template <typename T, typename E>
174174
struct IsStreamSubscriber {
175-
static constexpr bool value = std::is_base_of_v<GenericStreamSubscriber<current::decay_t<E>>, current::decay_t<T>>;
175+
static constexpr bool value = std::is_base_of<GenericStreamSubscriber<current::decay_t<E>>, current::decay_t<T>>::value;
176176
};
177177

178178
namespace impl {

blocks/ss/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ template <typename ENTRY, typename STREAM_ENTRY>
3737
#ifndef CURRENT_FOR_CPP14
3838
inline
3939
#endif // CURRENT_FOR_CPP14
40-
constexpr bool can_publish_v = std::is_constructible_v<STREAM_ENTRY, ENTRY>;
40+
constexpr bool can_publish_v = std::is_constructible<STREAM_ENTRY, ENTRY>::value;
4141

4242
} // namespace ss
4343
} // namespace current

blocks/xterm/progress.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class ProgressLine final {
101101
}
102102

103103
// The `std::enable_if_t` is necessary, as well as `current::decay`, because of `vt100::Color`. -- D.K.
104-
template <typename T, class = std::enable_if_t<!std::is_base_of_v<vt100::E, current::decay_t<T>>>>
104+
template <typename T, class = std::enable_if_t<!std::is_base_of<vt100::E, current::decay_t<T>>::value>>
105105
Status& operator<<(T&& whatever) {
106106
oss_text << whatever;
107107
oss_text_with_no_vt100_escape_sequences << whatever;

bricks/dflags/dflags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ class FlagRegisterer : public FlagRegistererBase {
273273
}
274274
}
275275

276-
bool IsBooleanFlag() const override { return std::is_same_v<FLAG_TYPE, bool>; }
276+
bool IsBooleanFlag() const override { return std::is_same<FLAG_TYPE, bool>::value; }
277277

278278
std::string TypeAsString() const override { return type_; }
279279

bricks/dflags/test.cc

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ SOFTWARE.
3535
#include <string>
3636
#include <sstream>
3737

38+
template <typename A, typename B>
39+
constexpr bool is_same_v = std::is_same<A, B>::value;
40+
3841
TEST(DFlags, DefinesAFlag) {
3942
::dflags::FlagsManager::DefaultRegisterer local_registerer;
4043
auto local_registerer_scope = ::dflags::FlagsManager::ScopedSingletonInjector(local_registerer);
4144
DEFINE_int8(foo, 42, "");
4245
DEFINE_uint8(bar, 42, "");
43-
static_assert(std::is_same_v<decltype(FLAGS_foo), int8_t>, "");
44-
static_assert(std::is_same_v<decltype(FLAGS_bar), uint8_t>, "");
46+
static_assert(is_same_v<decltype(FLAGS_foo), int8_t>, "");
47+
static_assert(is_same_v<decltype(FLAGS_bar), uint8_t>, "");
4548
EXPECT_EQ(42, FLAGS_foo);
4649
EXPECT_EQ(42, FLAGS_bar);
4750
FLAGS_foo = -1;
@@ -56,7 +59,7 @@ TEST(DFlags, ParsesAFlagUsingSingleDash) {
5659
::dflags::FlagsManager::DefaultRegisterer local_registerer;
5760
auto local_registerer_scope = ::dflags::FlagsManager::ScopedSingletonInjector(local_registerer);
5861
DEFINE_int16(foo, 1, "");
59-
static_assert(std::is_same_v<decltype(FLAGS_foo), int16_t>, "");
62+
static_assert(is_same_v<decltype(FLAGS_foo), int16_t>, "");
6063
EXPECT_EQ(1, FLAGS_foo);
6164
int argc = 3;
6265
char p1[] = "./ParsesAFlagUsingSingleDash";
@@ -74,7 +77,7 @@ TEST(DFlags, ParsesAFlagUsingDoubleDash) {
7477
::dflags::FlagsManager::DefaultRegisterer local_registerer;
7578
auto local_registerer_scope = ::dflags::FlagsManager::ScopedSingletonInjector(local_registerer);
7679
DEFINE_uint16(bar, 1, "");
77-
static_assert(std::is_same_v<decltype(FLAGS_bar), uint16_t>, "");
80+
static_assert(is_same_v<decltype(FLAGS_bar), uint16_t>, "");
7881
EXPECT_EQ(1, FLAGS_bar);
7982
int argc = 3;
8083
char p1[] = "./ParsesAFlagUsingDoubleDash";
@@ -92,7 +95,7 @@ TEST(DFlags, ParsesAFlagUsingSingleDashEquals) {
9295
::dflags::FlagsManager::DefaultRegisterer local_registerer;
9396
auto local_registerer_scope = ::dflags::FlagsManager::ScopedSingletonInjector(local_registerer);
9497
DEFINE_int32(baz, 1, "");
95-
static_assert(std::is_same_v<decltype(FLAGS_baz), int32_t>, "");
98+
static_assert(is_same_v<decltype(FLAGS_baz), int32_t>, "");
9699
EXPECT_EQ(1, FLAGS_baz);
97100
int argc = 2;
98101
char p1[] = "./ParsesAFlagUsingSingleDashEquals";
@@ -109,7 +112,7 @@ TEST(DFlags, ParsesAFlagUsingDoubleDashEquals) {
109112
::dflags::FlagsManager::DefaultRegisterer local_registerer;
110113
auto local_registerer_scope = ::dflags::FlagsManager::ScopedSingletonInjector(local_registerer);
111114
DEFINE_uint32(meh, 1, "");
112-
static_assert(std::is_same_v<decltype(FLAGS_meh), uint32_t>, "");
115+
static_assert(is_same_v<decltype(FLAGS_meh), uint32_t>, "");
113116
EXPECT_EQ(1u, FLAGS_meh);
114117
int argc = 2;
115118
char p1[] = "./ParsesAFlagUsingDoubleDashEquals";
@@ -142,12 +145,12 @@ TEST(DFlags, ParsesMultipleFlags) {
142145
DEFINE_int64(flag_int64, 0, "");
143146
DEFINE_uint64(flag_uint64, 0u, "");
144147
DEFINE_size_t(flag_size_t, 0u, "");
145-
static_assert(std::is_same_v<decltype(FLAGS_flag_string), std::string>, "");
146-
static_assert(std::is_same_v<decltype(FLAGS_flag_bool1), bool>, "");
147-
static_assert(std::is_same_v<decltype(FLAGS_flag_bool2), bool>, "");
148-
static_assert(std::is_same_v<decltype(FLAGS_flag_int64), int64_t>, "");
149-
static_assert(std::is_same_v<decltype(FLAGS_flag_uint64), uint64_t>, "");
150-
static_assert(std::is_same_v<decltype(FLAGS_flag_size_t), size_t>, "");
148+
static_assert(is_same_v<decltype(FLAGS_flag_string), std::string>, "");
149+
static_assert(is_same_v<decltype(FLAGS_flag_bool1), bool>, "");
150+
static_assert(is_same_v<decltype(FLAGS_flag_bool2), bool>, "");
151+
static_assert(is_same_v<decltype(FLAGS_flag_int64), int64_t>, "");
152+
static_assert(is_same_v<decltype(FLAGS_flag_uint64), uint64_t>, "");
153+
static_assert(is_same_v<decltype(FLAGS_flag_size_t), size_t>, "");
151154
EXPECT_EQ("", FLAGS_flag_string);
152155
EXPECT_FALSE(FLAGS_flag_bool1);
153156
EXPECT_TRUE(FLAGS_flag_bool2);
@@ -182,7 +185,7 @@ TEST(DFlags, ParsesEmptyString) {
182185
::dflags::FlagsManager::DefaultRegisterer local_registerer;
183186
auto local_registerer_scope = ::dflags::FlagsManager::ScopedSingletonInjector(local_registerer);
184187
DEFINE_string(empty_string, "not yet", "");
185-
static_assert(std::is_same_v<decltype(FLAGS_empty_string), std::string>, "");
188+
static_assert(is_same_v<decltype(FLAGS_empty_string), std::string>, "");
186189
EXPECT_EQ("not yet", FLAGS_empty_string);
187190
int argc = 3;
188191
char p1[] = "./ParsesEmptyString";
@@ -198,7 +201,7 @@ TEST(DFlags, ParsesEmptyStringUsingEquals) {
198201
::dflags::FlagsManager::DefaultRegisterer local_registerer;
199202
auto local_registerer_scope = ::dflags::FlagsManager::ScopedSingletonInjector(local_registerer);
200203
DEFINE_string(empty_string, "not yet", "");
201-
static_assert(std::is_same_v<decltype(FLAGS_empty_string), std::string>, "");
204+
static_assert(is_same_v<decltype(FLAGS_empty_string), std::string>, "");
202205
EXPECT_EQ("not yet", FLAGS_empty_string);
203206
int argc = 2;
204207
char p1[] = "./ParsesEmptyStringUsingEquals";

bricks/distributed/test.cc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,26 @@ SOFTWARE.
3030
using namespace std::chrono_literals;
3131

3232
TEST(VectorClock, SmokeTest) {
33-
auto v = VectorClock();
33+
auto v = VectorClock<>();
3434
v.Step();
3535

3636
auto data = DiscreteClocks(1);
3737
EXPECT_FALSE(v.AdvanceTo(data)) << "Merge from future should return false.";
3838
EXPECT_EQ(v.State().size(), static_cast<size_t>(1));
3939

40-
auto v2 = VectorClock(data, 0);
40+
auto v2 = VectorClock<>(data, 0);
4141
EXPECT_TRUE(v2.AdvanceTo(data)) << "Test lte t==t'.";
4242
}
4343

4444
TEST(VectorClock, ToString) {
4545
DiscreteClocks c1 = {1, 2};
46-
auto v = VectorClock(c1, 0);
46+
auto v = VectorClock<>(c1, 0);
4747
EXPECT_EQ(v.ToString(), "VCLOCK ID=0: [1, 2]");
4848
}
4949

5050
TEST(VectorClock, Merge) {
51-
auto base_time = current::time::Now();
5251
DiscreteClocks c1 = {1, 2};
53-
auto v = VectorClock(c1, 0);
52+
auto v = VectorClock<>(c1, 0);
5453

5554
// Merge correct update
5655
DiscreteClocks c2 = {2, 3};
@@ -65,14 +64,14 @@ TEST(VectorClock, Merge) {
6564
EXPECT_EQ(v.State()[1], cur_state[1]);
6665

6766
// Merge partially equals using lte validation
68-
v = VectorClock(c1, 0);
67+
v = VectorClock<>(c1, 0);
6968
c2 = {1, 3};
7069
EXPECT_TRUE(v.AdvanceTo(c2)) << "0 is equals, 1 is greater - ok to merge.";
7170
cur_state = v.State();
7271
EXPECT_GT(cur_state[0], c2[0]) << "Local time should be updated after merge.";
7372
EXPECT_EQ(c2[1], cur_state[1]) << "Merged time should be equal c2[1].";
7473

75-
v = VectorClock(c1, 0);
74+
v = VectorClock<>(c1, 0);
7675
cur_state = v.State();
7776
c2 = DiscreteClocks({1, 0});
7877
EXPECT_FALSE(v.AdvanceTo(c2)) << "Merge partially incorrect.";
@@ -96,7 +95,6 @@ TEST(VectorClock, ContinuousTime) {
9695
}
9796

9897
TEST(VectorClock, StrictMerge) {
99-
auto base_time = current::time::Now();
10098
DiscreteClocks c1 = {1, 2};
10199
auto v = VectorClock<DiscreteClocks, StrictMergeStrategy>(c1, 0);
102100

bricks/net/http/impl/server.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,9 @@ class GenericHTTPServerConnection final : public HTTPResponder {
820820

821821
// Only support STL containers of chars and bytes, this does not yet cover std::string.
822822
template <typename T>
823-
inline std::enable_if_t<std::is_same_v<typename T::value_type, char> ||
824-
std::is_same_v<typename T::value_type, uint8_t> ||
825-
std::is_same_v<typename T::value_type, int8_t>>
823+
inline std::enable_if_t<std::is_same<typename T::value_type, char>::value ||
824+
std::is_same<typename T::value_type, uint8_t>::value ||
825+
std::is_same<typename T::value_type, int8_t>::value>
826826
Send(T&& data, ChunkFlush flush) {
827827
SendImpl(std::forward<T>(data), flush);
828828
}

0 commit comments

Comments
 (0)