Skip to content

Commit c85a2a3

Browse files
committed
Convert all uses of fly::any_same trait to fly::SameAsAny concept
Similarly, convert fly::all_same to fly::SameAsAll.
1 parent 153904f commit c85a2a3

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

fly/traits/concepts.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include "fly/traits/traits.hpp"
4-
53
#include <concepts>
64
#include <type_traits>
75

fly/types/json/detail/json_iterator.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "fly/traits/traits.hpp"
3+
#include "fly/traits/concepts.hpp"
44
#include "fly/types/json/json_concepts.hpp"
55
#include "fly/types/json/json_exception.hpp"
66
#include "fly/types/string/string.hpp"
@@ -57,7 +57,7 @@ template <typename JsonType>
5757
class JsonIterator
5858
{
5959
static_assert(
60-
std::is_same_v<Json, typename std::remove_const_t<JsonType>>,
60+
fly::SameAs<Json, JsonType>,
6161
"JsonIterator must only be declared for a Json type");
6262

6363
static constexpr bool is_const_iterator = std::is_const_v<JsonType>;
@@ -430,13 +430,13 @@ class JsonIterator
430430
* A trait for testing if all types Ts are object iterators.
431431
*/
432432
template <typename... Ts>
433-
inline static constexpr bool is_object_iterator = all_same_v<object_iterator_type, Ts...>;
433+
static constexpr inline bool is_object_iterator = fly::SameAsAll<object_iterator_type, Ts...>;
434434

435435
/**
436436
* A trait for testing if all types Ts are array iterators.
437437
*/
438438
template <typename... Ts>
439-
inline static constexpr bool is_array_iterator = all_same_v<array_iterator_type, Ts...>;
439+
static constexpr inline bool is_array_iterator = fly::SameAsAll<array_iterator_type, Ts...>;
440440

441441
/**
442442
* Verify that this iterator is not empty.

test/logger/styler.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "test/util/capture_stream.hpp"
44

55
#include "fly/fly.hpp"
6-
#include "fly/traits/traits.hpp"
6+
#include "fly/traits/concepts.hpp"
77
#include "fly/types/string/string.hpp"
88

99
#include "catch2/catch_test_macros.hpp"
@@ -19,9 +19,9 @@ using namespace fly::literals::styler_literals;
1919
template <typename... Modifiers>
2020
void test_styler(std::string &&expected_escape, Modifiers &&...modifiers)
2121
{
22-
constexpr bool style_or_color = fly::any_same_v<fly::logger::Style, Modifiers...> ||
23-
fly::any_same_v<fly::logger::Color, Modifiers...> ||
24-
fly::any_same_v<fly::logger::Color::StandardColor, Modifiers...>;
22+
constexpr bool style_or_color = fly::SameAsAny<fly::logger::Style, Modifiers...> ||
23+
fly::SameAsAny<fly::logger::Color, Modifiers...> ||
24+
fly::SameAsAny<fly::logger::Color::StandardColor, Modifiers...>;
2525

2626
{
2727
fly::test::CaptureStream capture(fly::test::CaptureStream::Stream::Stdout);

test/types/json/json_accessors.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "test/types/json/json_helpers.hpp"
22

3+
#include "fly/traits/concepts.hpp"
34
#include "fly/types/json/json.hpp"
45

56
#include "catch2/catch_test_macros.hpp"
@@ -181,7 +182,7 @@ CATCH_JSON_TEST_CASE("JsonAccessors")
181182
CATCH_SECTION("Change the size of a JSON instance")
182183
{
183184
constexpr bool is_string_or_array =
184-
fly::any_same_v<json_type, fly::json_string_type, fly::json_array_type>;
185+
fly::SameAsAny<json_type, fly::json_string_type, fly::json_array_type>;
185186

186187
if constexpr (is_string_or_array)
187188
{
@@ -205,7 +206,7 @@ CATCH_JSON_TEST_CASE("JsonAccessors")
205206
CATCH_SECTION("Check the capacity of a JSON instance")
206207
{
207208
constexpr bool is_string_or_array =
208-
fly::any_same_v<json_type, fly::json_string_type, fly::json_array_type>;
209+
fly::SameAsAny<json_type, fly::json_string_type, fly::json_array_type>;
209210

210211
if constexpr (std::is_same_v<json_type, fly::json_null_type>)
211212
{
@@ -234,7 +235,7 @@ CATCH_JSON_TEST_CASE("JsonAccessors")
234235
CATCH_SECTION("Change the capacity of a JSON instance")
235236
{
236237
constexpr bool is_string_or_array =
237-
fly::any_same_v<json_type, fly::json_string_type, fly::json_array_type>;
238+
fly::SameAsAny<json_type, fly::json_string_type, fly::json_array_type>;
238239

239240
if constexpr (is_string_or_array)
240241
{

test/types/json/json_helpers.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include "fly/traits/traits.hpp"
3+
#include "fly/traits/concepts.hpp"
44
#include "fly/types/json/json.hpp"
55
#include "fly/types/json/json_exception.hpp"
66
#include "fly/types/string/string.hpp"
@@ -141,11 +141,11 @@ namespace fly::test {
141141
template <typename T>
142142
// NOLINTNEXTLINE(readability-identifier-naming)
143143
constexpr inline bool is_object_or_array_or_string_v =
144-
fly::any_same_v<T, fly::json_string_type, fly::json_object_type, fly::json_array_type>;
144+
fly::SameAsAny<T, fly::json_string_type, fly::json_object_type, fly::json_array_type>;
145145

146146
template <typename T, typename Other>
147147
// NOLINTNEXTLINE(readability-identifier-naming)
148-
constexpr inline bool is_null_or_other_type_v = fly::any_same_v<T, fly::json_null_type, Other>;
148+
constexpr inline bool is_null_or_other_type_v = fly::SameAsAny<T, fly::json_null_type, Other>;
149149

150150
template <typename T, typename StringType = fly::json_string_type>
151151
fly::Json create_json()

0 commit comments

Comments
 (0)