Skip to content

Commit 0b6450c

Browse files
committed
🎨 Move loggable concept to sc_like
1 parent a19a0a7 commit 0b6450c

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

include/log/log.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ struct config {
3232

3333
template <typename...> inline auto config = null::config{};
3434

35-
template <typename T>
36-
concept loggable = requires(T const &t) {
37-
t.apply([]<typename StringType>(StringType, auto const &...) {});
38-
};
39-
4035
struct default_flavor_t;
4136

4237
template <typename Flavor, typename... Ts>

include/match/concepts.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <log/log.hpp>
3+
#include <sc/fwd.hpp>
44

55
#include <concepts>
66
#include <type_traits>
@@ -12,7 +12,7 @@ concept matcher = requires { typename std::remove_cvref_t<T>::is_matcher; };
1212
template <typename T, typename Event>
1313
concept matcher_for = matcher<T> and requires(T const &t, Event const &e) {
1414
{ t(e) } -> std::convertible_to<bool>;
15-
{ t.describe() } -> logging::loggable;
16-
{ t.describe_match(e) } -> logging::loggable;
15+
{ t.describe() } -> sc::sc_like;
16+
{ t.describe_match(e) } -> sc::sc_like;
1717
};
1818
} // namespace match

include/sc/fwd.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,10 @@ template <stdx::ct_string S> CONSTEVAL auto operator""_sc() {
3737
return stdx::ct_string_to_type<S, string_constant>();
3838
}
3939
} // namespace literals
40+
41+
template <typename T>
42+
concept sc_like = requires(T const &t) {
43+
t.apply([]<typename StringType>(StringType, auto const &...) {});
44+
};
4045
} // namespace sc
4146
using sc::literals::operator""_sc;

test/sc/format.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,9 @@ TEST_CASE("format a formatted string", "[sc::format]") {
120120
(sc::lazy_string_format{"a1{}2{}3b4{}5{}6c"_sc,
121121
stdx::make_tuple(10, 20, 30, 40)}));
122122
}
123+
124+
TEST_CASE("lazy_string_format is sc_like", "[sc::format]") {
125+
[[maybe_unused]] auto lsf =
126+
sc::lazy_string_format{"{}"_sc, stdx::make_tuple(0)};
127+
static_assert(sc::sc_like<decltype(lsf)>);
128+
}

test/sc/string_constant.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ TEST_CASE("join", "[sc::string_constant]") {
3333
static_assert(""_sc + "Luke"_sc == "Luke"_sc);
3434
static_assert("Computer"_sc + ""_sc == "Computer"_sc);
3535
}
36+
37+
TEST_CASE("string_constant is sc_like", "[sc::string_constant]") {
38+
[[maybe_unused]] auto hi = "Hello, cruel world!"_sc;
39+
static_assert(sc::sc_like<decltype(hi)>);
40+
}

0 commit comments

Comments
 (0)