Skip to content

Commit ebae9e7

Browse files
committed
also make non-default constructible colors unignorable
1 parent 7522b99 commit ebae9e7

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

include/chroma

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <meta>
66
#include <ranges>
77
#include <string_view>
8+
#include <type_traits>
89
#include <vector>
910

1011
namespace chroma {
@@ -79,7 +80,9 @@ template <typename T>
7980
struct callable_from;
8081

8182
template <typename Color>
82-
concept ignorable = not requires { Color::ignorable; } || Color::ignorable;
83+
concept ignorable =
84+
(not requires { Color::ignorable; } and std::is_default_constructible_v<Color>) or
85+
Color::ignorable;
8386

8487
enum struct viability { accepted, rejected, ignored };
8588

test/unignorable.pass.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,21 @@ void fnc1(callable_from<A> = {}) {}
1414
void test() {
1515
auto a = A();
1616
fnc1(a.make_context());
17+
}
18+
19+
struct B {
20+
static constexpr auto error_message = "not in B";
21+
22+
B() = delete;
23+
explicit B(int) {}
24+
operator callable_from<B>() const {
25+
return chroma::color<B>();
26+
}
27+
};
28+
29+
void fnc2(callable_from<B> = {}) {}
30+
31+
void test2() {
32+
auto b = B(123);
33+
fnc2(b);
1734
}

0 commit comments

Comments
 (0)