Skip to content

Commit 3e931de

Browse files
committed
[Core] put meta symbols on meta namespace
1 parent 843fdcc commit 3e931de

35 files changed

+799
-603
lines changed

include/stormkit/Core/PimplImplMacro.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
template<class T, bool Defer> \
1515
Pimpl<T, Defer>::~Pimpl() = default; \
1616
template<class T, bool Defer> \
17-
template<IsNot<T> First, class... Args> \
17+
template<meta::IsNot<T> First, class... Args> \
1818
Pimpl<T, Defer>::Pimpl(First&& first, Args&&... args) { \
1919
init(std::forward<First>(first), std::forward<Args>(args)...); \
2020
} \

modules/stormkit/Core/Console/Style.mpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export {
7979
export namespace std {
8080
template<typename T, class CharT>
8181
struct formatter<stormkit::core::Stylized<T>, CharT>
82-
: formatter<stormkit::core::CanonicalType<T>, CharT> {
82+
: formatter<stormkit::core::meta::CanonicalType<T>, CharT> {
8383
template<class FormatContext>
8484
auto format(const stormkit::core::Stylized<T>& stylized, FormatContext& ctx) const noexcept
8585
-> decltype(ctx.out());

modules/stormkit/Core/Containers/RingBuffer.mpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import std;
1313
import :Utils.Assert;
1414
import :TypeSafe.Integer;
1515
import :TypeSafe.Byte;
16+
import :Meta;
1617

1718
export namespace stormkit::core {
1819
template<class T>
@@ -41,7 +42,8 @@ export namespace stormkit::core {
4142
[[nodiscard]] auto size() const noexcept -> ExtentType;
4243
[[nodiscard]] auto capacity() const noexcept -> ExtentType;
4344

44-
template<Is<CanonicalType<ValueType>> U>
45+
template<typename U>
46+
requires meta::Is<T, meta::CanonicalType<U>>
4547
auto push(U&& value) noexcept(std::is_nothrow_constructible_v<ValueType, U>) -> void;
4648

4749
template<class... Args>
@@ -199,7 +201,8 @@ namespace stormkit::core {
199201
////////////////////////////////////////
200202
////////////////////////////////////////
201203
template<class T>
202-
template<Is<CanonicalType<typename RingBuffer<T>::ValueType>> U>
204+
template<typename U>
205+
requires meta::Is<T, meta::CanonicalType<U>>
203206
auto RingBuffer<T>::push(U&& value) noexcept(std::is_nothrow_constructible_v<ValueType, U>)
204207
-> void {
205208
emplace(std::forward(value));
@@ -262,8 +265,8 @@ namespace stormkit::core {
262265
template<class T>
263266
template<class Self>
264267
auto RingBuffer<T>::getPtr(this Self& self, ExtentType pos) noexcept -> decltype(auto) {
265-
using OutPtr = ConstnessLike<Self, T*>;
266-
auto addr = std::forward_like<Self>(&(self.m_buffer[pos * sizeof(ValueType)]));
268+
using OutPtr = meta::ConstnessLike<Self, T*>;
269+
auto addr = std::forward_like<Self>(&(self.m_buffer[pos * sizeof(ValueType)]));
267270

268271
return std::launder(std::bit_cast<OutPtr>(addr));
269272
}

modules/stormkit/Core/Containers/Utils.mpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ export namespace stormkit::core {
1414
constexpr auto merge(T& output, const U&... ranges) noexcept -> void;
1515

1616
template<std::ranges::range T, std::ranges::range... U>
17-
constexpr auto concat(const T& first, const U&... others) noexcept -> std::vector<RangeType<T>>;
17+
constexpr auto concat(const T& first, const U&... others) noexcept -> std::vector<meta::RangeType<T>>;
1818

1919
template<std::ranges::range T, std::ranges::range... U>
2020
constexpr auto moveAndMerge(T& output, U&&... ranges) noexcept -> void;
2121

2222
template<std::ranges::range T, std::ranges::range... U>
23-
constexpr auto moveAndConcat(T&& first, U&&... others) noexcept -> std::vector<RangeType<T>>;
23+
constexpr auto moveAndConcat(T&& first, U&&... others) noexcept -> std::vector<meta::RangeType<T>>;
2424

2525
template<class T, typename... Args>
26-
requires((core::Is<T, Args> and ...) or (std::convertible_to<T, Args> and ...) or
26+
requires((core::meta::Is<T, Args> and ...) or (std::convertible_to<T, Args> and ...) or
2727
(std::constructible_from<T, Args> and ...))
2828
constexpr auto makeStaticArray(T&& first, Args&&... args) noexcept -> decltype(auto);
2929

3030
template<class T, typename... Args>
31-
requires((core::Is<T, Args> and ...) or (std::convertible_to<T, Args> and ...) or
31+
requires((core::meta::Is<T, Args> and ...) or (std::convertible_to<T, Args> and ...) or
3232
(std::constructible_from<T, Args> and ...))
3333
constexpr auto makeArray(T&& first, Args&&... args) noexcept -> decltype(auto);
3434

@@ -39,7 +39,7 @@ export namespace stormkit::core {
3939
constexpr auto viewAsBytes(T& data) -> decltype(auto);
4040

4141
template<typename T>
42-
constexpr auto viewAs(std::span<core::ConstnessLike<T, core::Byte>> data) -> decltype(auto);
42+
constexpr auto viewAs(std::span<core::meta::ConstnessLike<T, core::Byte>> data) -> decltype(auto);
4343

4444
template<std::ranges::range R1,
4545
std::ranges::range R2,
@@ -94,8 +94,8 @@ namespace stormkit::core {
9494
////////////////////////////////////////
9595
template<std::ranges::range T, std::ranges::range... U>
9696
constexpr auto concat(const T& first,
97-
const U&... others) noexcept -> std::vector<RangeType<T>> {
98-
auto output = std::vector<RangeType<T>> {};
97+
const U&... others) noexcept -> std::vector<meta::RangeType<T>> {
98+
auto output = std::vector<meta::RangeType<T>> {};
9999
merge(output, first, others...);
100100

101101
return output;
@@ -112,8 +112,8 @@ namespace stormkit::core {
112112
////////////////////////////////////////
113113
////////////////////////////////////////
114114
template<std::ranges::range T, std::ranges::range... U>
115-
constexpr auto moveAndConcat(T&& first, U&&... others) noexcept -> std::vector<RangeType<T>> {
116-
auto output = std::vector<RangeType<T>> {};
115+
constexpr auto moveAndConcat(T&& first, U&&... others) noexcept -> std::vector<meta::RangeType<T>> {
116+
auto output = std::vector<meta::RangeType<T>> {};
117117
moveAndMerge(output, std::forward<T>(first), std::forward<U>(others)...);
118118

119119
return output;
@@ -122,7 +122,7 @@ namespace stormkit::core {
122122
/////////////////////////////////////
123123
/////////////////////////////////////
124124
template<class T, typename... Args>
125-
requires((core::Is<T, Args> and ...) or (std::convertible_to<T, Args> and ...) or
125+
requires((core::meta::Is<T, Args> and ...) or (std::convertible_to<T, Args> and ...) or
126126
(std::constructible_from<T, Args> and ...))
127127
constexpr auto makeStaticArray(T&& first, Args&&... args) noexcept -> decltype(auto) {
128128
return std::array { std::forward<T>(first), static_cast<T>(std::forward<Args>(args))... };
@@ -131,7 +131,7 @@ namespace stormkit::core {
131131
/////////////////////////////////////
132132
/////////////////////////////////////
133133
template<class T, typename... Args>
134-
requires((core::Is<T, Args> and ...) or (std::convertible_to<T, Args> and ...) or
134+
requires((core::meta::Is<T, Args> and ...) or (std::convertible_to<T, Args> and ...) or
135135
(std::constructible_from<T, Args> and ...))
136136
constexpr auto makeArray(T&& first, Args&&... args) noexcept -> decltype(auto) {
137137
return std::vector { std::forward<T>(first), static_cast<T>(std::forward<Args>(args))... };
@@ -148,15 +148,15 @@ namespace stormkit::core {
148148
/////////////////////////////////////
149149
template<std::ranges::range T>
150150
constexpr auto viewAsBytes(T& data) -> decltype(auto) {
151-
using Byte = core::ConstnessLike<typename T::value_type, core::Byte>;
151+
using Byte = core::meta::ConstnessLike<typename T::value_type, core::Byte>;
152152
return std::span<Byte> { std::bit_cast<Byte*>(std::ranges::data(data)),
153153
std::ranges::size(data) * sizeof(T) };
154154
}
155155

156156
/////////////////////////////////////
157157
/////////////////////////////////////
158158
template<typename T>
159-
constexpr auto viewAs(std::span<core::ConstnessLike<T, core::Byte>> data) -> decltype(auto) {
159+
constexpr auto viewAs(std::span<core::meta::ConstnessLike<T, core::Byte>> data) -> decltype(auto) {
160160
return std::span<T> { std::bit_cast<T*>(std::ranges::data(data)),
161161
std::ranges::size(data) / sizeof(T) };
162162
}

modules/stormkit/Core/Functional/ErrorHandling.mpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ namespace stormkit::core::monadic {
109109
constexpr auto ensuresWithMessage(std::string&& message, std::source_location location) noexcept
110110
-> decltype(auto) {
111111
return [message = std::move(message), location = std::move(location)] NORETURN_LAMBDA(
112-
auto&& error) -> std::expected<void, CanonicalType<decltype(error)>> {
112+
auto&& error) -> std::expected<void, meta::CanonicalType<decltype(error)>> {
113113
std::println(getSTDErr(),
114114
"{} failed in \n"
115115
" > file: {}\n"
@@ -136,7 +136,7 @@ namespace stormkit::core::monadic {
136136
////////////////////////////////////////
137137
constexpr auto ensures(std::source_location location) noexcept -> decltype(auto) {
138138
return [location = std::move(location)] NORETURN_LAMBDA(
139-
auto&& error) -> std::expected<void, CanonicalType<decltype(error)>> {
139+
auto&& error) -> std::expected<void, meta::CanonicalType<decltype(error)>> {
140140
std::println(getSTDErr(),
141141
"{} failed in \n"
142142
" > file: {}\n"
@@ -161,7 +161,7 @@ namespace stormkit::core::monadic {
161161
constexpr auto log(std::invocable auto&& logger, std::string&& message) noexcept
162162
-> decltype(auto) {
163163
return [logger = std::forward<decltype(logger)>, message = std::move(message)](
164-
auto&& error) -> std::expected<void, CanonicalType<decltype(error)>> {
164+
auto&& error) -> std::expected<void, meta::CanonicalType<decltype(error)>> {
165165
logger(message, error);
166166

167167
return {};
@@ -172,7 +172,7 @@ namespace stormkit::core::monadic {
172172
////////////////////////////////////////
173173
constexpr auto throwError() noexcept -> decltype(auto) {
174174
return [] NORETURN_LAMBDA(
175-
auto&& error) static -> std::expected<void, CanonicalType<decltype(error)>> {
175+
auto&& error) static -> std::expected<void, meta::CanonicalType<decltype(error)>> {
176176
throw std::forward<decltype(error)>(error);
177177
};
178178
}

modules/stormkit/Core/Functional/Monadic.mpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import :Meta;
1515
import :TypeSafe.AsCast;
1616
import :Functional.Utils;
1717
import :TypeSafe.Ref;
18+
import :TypeSafe.Byte;
1819

1920
export namespace stormkit::core::monadic {
2021
struct Anything {
@@ -54,7 +55,7 @@ export namespace stormkit::core::monadic {
5455
either(std::regular_invocable<Anything> auto&&... visitors) noexcept -> decltype(auto);
5556

5657
template<typename T>
57-
[[nodiscard]] constexpr auto either(IsUnaryPredicate<T> auto&& predicate,
58+
[[nodiscard]] constexpr auto either(meta::IsUnaryPredicate<T> auto&& predicate,
5859
std::invocable<T> auto&& true_,
5960
std::invocable<T> auto&& false_) noexcept -> decltype(auto);
6061

@@ -72,6 +73,7 @@ export namespace stormkit::core::monadic {
7273
[[nodiscard]] constexpr auto init(Args&&... args) noexcept -> decltype(auto);
7374

7475
[[nodiscard]] constexpr auto borrow() noexcept -> decltype(auto);
76+
[[nodiscard]] constexpr auto borrowMut() noexcept -> decltype(auto);
7577

7678
template<typename T>
7779
[[nodiscard]] constexpr auto forwardLike() noexcept -> decltype(auto);
@@ -85,7 +87,7 @@ namespace stormkit::core::monadic {
8587
/////////////////////////////////////
8688
/////////////////////////////////////
8789
STORMKIT_FORCE_INLINE constexpr auto value() noexcept -> decltype(auto) {
88-
return []<IsFancyPointer T>(T&& value) static noexcept -> decltype(auto) {
90+
return []<meta::IsFancyPointer T>(T&& value) static noexcept -> decltype(auto) {
8991
return std::forward_like<T>(value.get());
9092
};
9193
}
@@ -191,8 +193,8 @@ namespace stormkit::core::monadic {
191193
-> decltype(auto) {
192194
using First = decltype(first);
193195
using Second = decltype(second);
194-
using FirstP = core::CanonicalType<First>;
195-
using SecondP = core::CanonicalType<Second>;
196+
using FirstP = core::meta::CanonicalType<First>;
197+
using SecondP = core::meta::CanonicalType<Second>;
196198

197199
return
198200
[first = std::forward<First>(first),
@@ -205,7 +207,7 @@ namespace stormkit::core::monadic {
205207
/////////////////////////////////////
206208
/////////////////////////////////////
207209
template<typename T>
208-
STORMKIT_FORCE_INLINE constexpr auto either(IsUnaryPredicate<T> auto&& predicate,
210+
STORMKIT_FORCE_INLINE constexpr auto either(meta::IsUnaryPredicate<T> auto&& predicate,
209211
std::invocable<T> auto&& true_,
210212
std::invocable<T> auto&& false_) noexcept
211213
-> decltype(auto) {
@@ -248,7 +250,7 @@ namespace stormkit::core::monadic {
248250
/////////////////////////////////////
249251
STORMKIT_FORCE_INLINE constexpr auto clone() noexcept -> decltype(auto) {
250252
return []<typename T>(auto&& value) static noexcept(
251-
noexcept(std::is_nothrow_copy_constructible_v<CanonicalType<T>>)) {
253+
noexcept(std::is_nothrow_copy_constructible_v<meta::CanonicalType<T>>)) {
252254
return auto(std::forward<T>(value));
253255
};
254256
}
@@ -281,6 +283,14 @@ namespace stormkit::core::monadic {
281283
};
282284
}
283285

286+
/////////////////////////////////////
287+
/////////////////////////////////////
288+
STORMKIT_FORCE_INLINE constexpr auto borrowMut() noexcept -> decltype(auto) {
289+
return []<typename T>(T&& value) static noexcept {
290+
return core::borrowMut(std::forward<T>(value));
291+
};
292+
}
293+
284294
/////////////////////////////////////
285295
/////////////////////////////////////
286296
template<typename T>

modules/stormkit/Core/Functional/Utils.mpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ namespace stormkit::core::details {
2020
-> decltype(false_());
2121

2222
template<typename T>
23-
requires IsOptionalType<CanonicalType<T>>
23+
requires meta::IsOptionalType<meta::CanonicalType<T>>
2424
[[nodiscard]] static constexpr auto
2525
operator()(T&& optional,
26-
std::invocable<typename CanonicalType<T>::value_type> auto&& true_,
26+
std::invocable<typename meta::CanonicalType<T>::value_type> auto&& true_,
2727
std::invocable auto&& false_) noexcept -> decltype(false_());
2828
};
2929
} // namespace stormkit::core::details
@@ -55,10 +55,10 @@ namespace stormkit::core {
5555
/////////////////////////////////////
5656
/////////////////////////////////////
5757
template<typename T>
58-
requires IsOptionalType<CanonicalType<T>>
58+
requires meta::IsOptionalType<meta::CanonicalType<T>>
5959
STORMKIT_FORCE_INLINE constexpr auto
6060
EitherFunc::operator()(T&& optional,
61-
std::invocable<typename CanonicalType<T>::value_type> auto&& true_,
61+
std::invocable<typename meta::CanonicalType<T>::value_type> auto&& true_,
6262
std::invocable auto&& false_) noexcept -> decltype(false_()) {
6363
if (optional != std::nullopt) return true_(*std::forward<T>(optional));
6464
return false_();

modules/stormkit/Core/Hash/Base.mpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ export namespace stormkit::core {
1313
using Hash64 = std::uint64_t;
1414

1515
template<class T>
16-
concept HashValue = core::IsOneOf<T, Hash32, Hash64>;
16+
concept HashValue = core::meta::IsOneOf<T, Hash32, Hash64>;
1717

1818
template<HashValue OutputType = Hash32>
1919
constexpr auto hashCombine(auto&& value) -> OutputType;
2020

21-
constexpr auto hashCombine(HashValue auto& hash, IsHashable auto&& v) noexcept;
21+
constexpr auto hashCombine(HashValue auto& hash, meta::IsHashable auto&& v) noexcept;
2222

2323
constexpr auto hashCombine(HashValue auto& hash, std::ranges::range auto&& range) noexcept;
2424

@@ -40,7 +40,7 @@ namespace stormkit::core {
4040
return hash;
4141
}
4242

43-
constexpr auto hashCombine(HashValue auto& hash, IsHashable auto&& value) noexcept {
43+
constexpr auto hashCombine(HashValue auto& hash, meta::IsHashable auto&& value) noexcept {
4444
const auto hasher = std::hash<std::remove_cvref_t<decltype(value)>> {};
4545
hash ^=
4646
hasher(std::forward<decltype(value)>(value)) + 0x9e3779b9 + (hash << 6) + (hash >> 2);

modules/stormkit/Core/Meta/Algorithms.mpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,22 @@ import std;
1313
import :Meta.Concepts;
1414
import :Meta.Traits;
1515

16-
export namespace stormkit::core {
16+
export namespace stormkit::core::meta {
1717
template<typename Predicate, template<typename...> class Variant, typename... Ts>
1818
constexpr auto variantTypeFindIf(const Variant<Ts...>&, Predicate&& predicate) noexcept
1919
-> std::size_t;
20-
} // namespace stormkit::core
20+
} // namespace stormkit::core::meta
2121

2222
////////////////////////////////////////////////////////////////////
2323
/// IMPLEMENTATION ///
2424
////////////////////////////////////////////////////////////////////
2525

26-
namespace stormkit::core {
26+
namespace stormkit::core::meta {
2727
/////////////////////////////////////
2828
/////////////////////////////////////
2929
template<typename... Ts, typename Predicate>
30-
STORMKIT_FORCE_INLINE constexpr auto variantTypeFindIfImpl(Predicate&& predicate) noexcept -> std::size_t {
30+
STORMKIT_FORCE_INLINE constexpr auto variantTypeFindIfImpl(Predicate&& predicate) noexcept
31+
-> std::size_t {
3132
auto found = std::variant_npos;
3233
[&]<std::size_t... Indices>(std::index_sequence<Indices...>) noexcept {
3334
if constexpr ((requires {
@@ -48,8 +49,9 @@ namespace stormkit::core {
4849
/////////////////////////////////////
4950
/////////////////////////////////////
5051
template<typename Predicate, template<typename...> class Variant, typename... Ts>
51-
STORMKIT_FORCE_INLINE constexpr auto variantTypeFindIf(const Variant<Ts...>&, Predicate&& predicate) noexcept
52+
STORMKIT_FORCE_INLINE constexpr auto variantTypeFindIf(const Variant<Ts...>&,
53+
Predicate&& predicate) noexcept
5254
-> std::size_t {
5355
return variantTypeFindIfImpl<Ts...>(std::forward<Predicate>(predicate));
5456
}
55-
} // namespace stormkit::core
57+
} // namespace stormkit::core::meta

modules/stormkit/Core/Meta/Concepts.mpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export module stormkit.Core:Meta.Concepts;
66

77
import std;
88

9-
namespace stormkit::core {
9+
namespace stormkit::core::meta {
1010
namespace details {
1111
template<class T>
1212
concept IsBooleanTestable = std::convertible_to<T, bool>;
@@ -112,7 +112,8 @@ namespace stormkit::core {
112112
= IsPointer<T> and IsPolymorphic<typename std::pointer_traits<T>::element_type>;
113113

114114
template<class T>
115-
concept IsPolymorphicReference = IsReference<T> and IsPolymorphic<std::remove_reference_t<T>>;
115+
concept IsPolymorphicReference
116+
= IsReference<T> and IsPolymorphic<std::remove_reference_t<T>>;
116117

117118
template<class T>
118119
concept IsPolymorphicIndirection = IsPolymorphicReference<T> or IsPolymorphicPointer<T>;
@@ -214,7 +215,7 @@ namespace stormkit::core {
214215
concept IsConst = std::is_const_v<T>;
215216

216217
template<class T>
217-
concept IsNotConst = std::is_const_v<T>;
218+
concept IsNotConst = not IsConst<T>;
218219

219220
template<class From, typename To>
220221
concept IsBraceInitializableTo = requires(From&& from) { To { std::forward<From>(from) }; };
@@ -238,7 +239,4 @@ namespace stormkit::core {
238239
{ first == second } -> IsBooleanTestable;
239240
};
240241
} // namespace stormkit::core
241-
242-
#ifndef STORMKIT_NO_MODULES
243-
}
244-
#endif
242+
} // namespace stormkit::core::meta

0 commit comments

Comments
 (0)