Skip to content

Commit 8d408c6

Browse files
committed
Use fly::SameAs where able to automatically remove cv-qualifiers
1 parent 1ccfc5a commit 8d408c6

File tree

9 files changed

+20
-28
lines changed

9 files changed

+20
-28
lines changed

fly/types/bit_stream/detail/bit_stream_concepts.hpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
#include "fly/traits/concepts.hpp"
44
#include "fly/types/bit_stream/bit_stream_types.hpp"
55

6-
#include <concepts>
7-
#include <type_traits>
8-
96
namespace fly::detail {
107

118
/**
@@ -18,6 +15,6 @@ concept BitStreamInteger = fly::UnsignedIntegral<T>;
1815
* Concept that is satisfied if the given type is the bit stream buffer type.
1916
*/
2017
template <typename T>
21-
concept BitStreamBuffer = std::same_as<std::remove_cvref_t<T>, buffer_type>;
18+
concept BitStreamBuffer = fly::SameAs<T, buffer_type>;
2219

2320
} // namespace fly::detail

fly/types/json/json.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ bool operator==(Json::const_reference json1, Json::const_reference json2)
758758
{
759759
return value1 == static_cast<S1>(value2);
760760
}
761-
else if constexpr (fly::SameAsAny<S1, S2>)
761+
else if constexpr (fly::SameAs<S1, S2>)
762762
{
763763
return value1 == value2;
764764
}
@@ -801,7 +801,7 @@ bool operator<(Json::const_reference json1, Json::const_reference json2)
801801
{
802802
return value1 < static_cast<S1>(value2);
803803
}
804-
else if constexpr (fly::SameAsAny<S1, S2>)
804+
else if constexpr (fly::SameAs<S1, S2>)
805805
{
806806
return value1 < value2;
807807
}

fly/types/json/json.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ Json::operator T() const &noexcept(false)
16431643

16441644
if constexpr (JsonString<S>)
16451645
{
1646-
if constexpr (fly::SameAsAny<T, json_string_type>)
1646+
if constexpr (fly::SameAs<T, json_string_type>)
16471647
{
16481648
return storage;
16491649
}
@@ -2002,7 +2002,7 @@ json_string_type Json::convert_to_string(T value)
20022002
{
20032003
using StringType = BasicString<typename detail::is_like_supported_string_t<T>::value_type>;
20042004

2005-
if constexpr (fly::SameAsAny<typename StringType::string_type, json_string_type>)
2005+
if constexpr (fly::SameAs<typename StringType::string_type, json_string_type>)
20062006
{
20072007
if (StringType::validate(value))
20082008
{
@@ -2128,7 +2128,7 @@ struct fly::Formatter<fly::Json, CharType> :
21282128
template <typename FormatContext>
21292129
void format(const fly::Json &json, FormatContext &context)
21302130
{
2131-
if constexpr (fly::SameAsAny<CharType, fly::json_char_type>)
2131+
if constexpr (fly::SameAs<CharType, fly::json_char_type>)
21322132
{
21332133
fly::Formatter<string_type, CharType>::format(json.serialize(), context);
21342134
}

fly/types/json/json_concepts.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "fly/types/string/detail/string_traits.hpp"
66

77
#include <array>
8-
#include <concepts>
98
#include <deque>
109
#include <forward_list>
1110
#include <list>
@@ -52,7 +51,7 @@ namespace detail {
5251
* Concept that is satisfied when the given type is a JSON null type.
5352
*/
5453
template <typename T>
55-
concept JsonNull = std::same_as<std::remove_cvref_t<T>, json_null_type>;
54+
concept JsonNull = fly::SameAs<T, json_null_type>;
5655

5756
/**
5857
* Concept that is satisfied when the given type is a supported JSON string type.
@@ -115,7 +114,7 @@ concept JsonContainer = JsonString<T> || JsonObject<T> || JsonArray<T>;
115114
* Concept that is satisfied when the given type is a JSON Boolean type.
116115
*/
117116
template <typename T>
118-
concept JsonBoolean = std::same_as<std::remove_cvref_t<T>, json_boolean_type>;
117+
concept JsonBoolean = fly::SameAs<T, json_boolean_type>;
119118

120119
/**
121120
* Concept that is satisfied when the given type is a signed JSON number type.

fly/types/numeric/detail/endian_concepts.hpp

-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
#include "fly/traits/concepts.hpp"
44

5-
#include <concepts>
6-
#include <type_traits>
7-
85
namespace fly::detail {
96

107
/**

fly/types/string/detail/format_parameters.hpp

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

3+
#include "fly/traits/concepts.hpp"
34
#include "fly/types/string/detail/classifier.hpp"
45
#include "fly/types/string/detail/format_parse_context.hpp"
56
#include "fly/types/string/detail/format_specifier.hpp"
@@ -8,7 +9,6 @@
89
#include "fly/types/string/formatters.hpp"
910

1011
#include <array>
11-
#include <concepts>
1212
#include <cstdint>
1313
#include <string_view>
1414
#include <type_traits>
@@ -373,19 +373,19 @@ inline void format_standard_value(
373373
formatter.format(static_cast<T>(const_cast<void *>(value.m_pointer)), context);
374374
}
375375
}
376-
else if constexpr (std::same_as<T, float>)
376+
else if constexpr (fly::SameAs<T, float>)
377377
{
378378
formatter.format(value.m_float, context);
379379
}
380-
else if constexpr (std::same_as<T, double>)
380+
else if constexpr (fly::SameAs<T, double>)
381381
{
382382
formatter.format(value.m_double, context);
383383
}
384-
else if constexpr (std::same_as<T, long double>)
384+
else if constexpr (fly::SameAs<T, long double>)
385385
{
386386
formatter.format(value.m_long_double, context);
387387
}
388-
else if constexpr (std::same_as<T, bool>)
388+
else if constexpr (fly::SameAs<T, bool>)
389389
{
390390
formatter.format(value.m_bool, context);
391391
}

fly/types/string/detail/string_concepts.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "fly/traits/concepts.hpp"
44
#include "fly/types/string/detail/string_traits.hpp"
55

6-
#include <concepts>
76
#include <type_traits>
87

98
namespace fly::detail {
@@ -58,7 +57,7 @@ concept FormattablePointer = requires
5857
* Concept that is satisfied when the given type is a formattable boolean type.
5958
*/
6059
template <typename T>
61-
concept FormattableBoolean = std::same_as<bool, std::remove_cvref_t<T>>;
60+
concept FormattableBoolean = fly::SameAs<T, bool>;
6261

6362
/**
6463
* Concept that is satisfied when the given type is a formattable integral type, excluding boolean

fly/types/string/formatters.hpp

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

33
#include "fly/fly.hpp"
4+
#include "fly/traits/concepts.hpp"
45
#include "fly/types/string/detail/classifier.hpp"
56
#include "fly/types/string/detail/format_specifier.hpp"
67
#include "fly/types/string/detail/stream_util.hpp"
@@ -11,7 +12,6 @@
1112
#include <array>
1213
#include <charconv>
1314
#include <cmath>
14-
#include <concepts>
1515
#include <iomanip>
1616
#include <limits>
1717
#include <sstream>
@@ -127,7 +127,7 @@ struct Formatter<T, CharType> : public detail::BasicFormatSpecifier<CharType>
127127
view = view_like_type(value).substr(0, value_size);
128128
}
129129

130-
if constexpr (std::same_as<string_type, string_like_type>)
130+
if constexpr (fly::SameAs<string_type, string_like_type>)
131131
{
132132
for (const auto &ch : view)
133133
{
@@ -448,7 +448,7 @@ struct Formatter<T, CharType> : public detail::BasicFormatSpecifier<CharType>
448448
}
449449
}
450450

451-
if constexpr (std::same_as<string_type, std::string>)
451+
if constexpr (fly::SameAs<string_type, std::string>)
452452
{
453453
for (const char *it = begin; it != result.ptr; ++it)
454454
{
@@ -564,7 +564,7 @@ struct Formatter<T, CharType> : public detail::BasicFormatSpecifier<CharType>
564564

565565
auto append_number = [this, &context, &result]()
566566
{
567-
if constexpr (std::same_as<string_type, std::string>)
567+
if constexpr (fly::SameAs<string_type, std::string>)
568568
{
569569
for (auto ch : result.m_digits)
570570
{

fly/types/string/string.hpp

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

3+
#include "fly/traits/concepts.hpp"
34
#include "fly/types/string/detail/classifier.hpp"
45
#include "fly/types/string/detail/converter.hpp"
56
#include "fly/types/string/detail/format_context.hpp"
@@ -18,7 +19,6 @@
1819
#include <cctype>
1920
#include <chrono>
2021
#include <cmath>
21-
#include <concepts>
2222
#include <cstdint>
2323
#include <cstdlib>
2424
#include <ios>
@@ -1038,7 +1038,7 @@ std::optional<T> BasicString<CharType>::convert(const string_type &value)
10381038
{
10391039
return unicode::template convert_encoding<T>(value);
10401040
}
1041-
else if constexpr (std::same_as<char_type, char>)
1041+
else if constexpr (fly::SameAs<char_type, char>)
10421042
{
10431043
return detail::Converter<T>::convert(value);
10441044
}

0 commit comments

Comments
 (0)