Skip to content

Commit faaec61

Browse files
committed
Promoted 'std::ranges::to<>()'
1 parent 9007189 commit faaec61

7 files changed

Lines changed: 9 additions & 19 deletions

File tree

src/abi/memory.ixx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export namespace essence::abi {
5858
constexpr uniform_allocator(uniform_allocator&&) noexcept = default;
5959

6060
template <typename U>
61-
constexpr uniform_allocator(const uniform_allocator<U>&) noexcept {}
61+
constexpr explicit uniform_allocator(const uniform_allocator<U>&) noexcept {}
6262

6363
~uniform_allocator() = default;
6464

src/cli/option.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ namespace essence::cli {
112112
}
113113

114114
[[nodiscard]] abi::string name_hints() const {
115-
auto joint = join_with(aliases_, std::string_view{U8(",")});
116-
117-
return {joint.begin(), joint.end()};
115+
return join_with(aliases_, std::string_view{U8(",")}) | std::ranges::to<abi::string>();
118116
}
119117

120118
[[nodiscard]] static abi::string value_hints() {

src/jni/util.ixx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,9 @@ export namespace essence::jni {
6666

6767
if (convert_to_boolean(transformer)) {
6868
jobject_array_proxy proxy{array};
69-
auto intermediate =
70-
proxy | std::views::common | std::views::transform(std::forward<Transformer>(transformer));
7169

72-
return result_type{intermediate.begin(), intermediate.end()};
70+
return proxy | std::views::common | std::views::transform(std::forward<Transformer>(transformer))
71+
| std::ranges::to<result_type>();
7372
}
7473

7574
return result_type{};

src/managed_handle.ixx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export namespace essence {
8888
* @brief Gets the stored handle.
8989
* @return The stored handle.
9090
*/
91-
native_type get() const noexcept {
91+
[[nodiscard]] native_type get() const noexcept {
9292
return value_.get();
9393
}
9494

src/net/ipv4_address.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ module essence.net;
2929
namespace essence::net {
3030
std::optional<ipv4_address> parse_ipv4_address(std::string_view str) {
3131
auto adapter = std::views::split(str, U8('.')) | std::views::transform([](const auto& inner) {
32-
auto iter = inner | std::views::common;
32+
auto component = inner | std::views::common | std::ranges::to<std::string>();
3333

34-
return essence::from_string<std::uint8_t>(std::string{iter.begin(), iter.end()});
34+
return essence::from_string<std::uint8_t>(component);
3535
}) | std::views::take(ipv4_address::value_size);
3636

3737
auto result = std::make_optional<ipv4_address>();

src/string.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,10 @@ module essence.basic;
2424

2525
namespace essence {
2626
abi::string to_lower(std::string_view str) {
27-
auto lower = str | std::views::transform(&to_lower<char>);
28-
29-
return {lower.begin(), lower.end()};
27+
return str | std::views::transform(&to_lower<char>) | std::ranges::to<abi::string>();
3028
}
3129

3230
abi::string to_upper(std::string_view str) {
33-
auto upper = str | std::views::transform(&to_upper<char>);
34-
35-
return {upper.begin(), upper.end()};
31+
return str | std::views::transform(&to_upper<char>) | std::ranges::to<abi::string>();
3632
}
3733
} // namespace essence

src/string.ixx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ export namespace essence {
134134
return trim_right(trim_left(str, group), group);
135135
}
136136

137-
#if !defined(CPP_ESSENCE_HEADER_ONLY) || !CPP_ESSENCE_HEADER_ONLY
138137
/**
139138
* @brief Lowercases a string.
140139
* @param str The string.
@@ -149,6 +148,4 @@ export namespace essence {
149148
*
150149
*/
151150
ES_API(CPPESSENCE) abi::string to_upper(std::string_view str);
152-
#endif
153-
154151
} // namespace essence

0 commit comments

Comments
 (0)