add requires for function
This commit is contained in:
parent
eda341026b
commit
0017c36e2f
1 changed files with 11 additions and 3 deletions
14
main.cxx
14
main.cxx
|
|
@ -8,7 +8,11 @@ struct BuildMixin {};
|
|||
|
||||
template <>
|
||||
struct BuildMixin<true> {
|
||||
auto build(this auto&& self) { return self.p1 + self.p2; }
|
||||
auto build(this auto&& self)
|
||||
requires requires { self.p1 + self.p2; }
|
||||
{
|
||||
return self.p1 + self.p2;
|
||||
}
|
||||
};
|
||||
|
||||
template <bool enabled>
|
||||
|
|
@ -16,7 +20,9 @@ struct Param1Mixin {};
|
|||
|
||||
template <>
|
||||
struct Param1Mixin<false> {
|
||||
auto fill_param1(this auto&& self) {
|
||||
auto fill_param1(this auto&& self)
|
||||
requires requires { self.p1; }
|
||||
{
|
||||
self.p1 = 1;
|
||||
return Builder<true, std::remove_reference_t<decltype(self)>::param2_v>(
|
||||
self);
|
||||
|
|
@ -28,7 +34,9 @@ struct Param2Mixin {};
|
|||
|
||||
template <>
|
||||
struct Param2Mixin<false> {
|
||||
auto fill_param2(this auto&& self) {
|
||||
auto fill_param2(this auto&& self)
|
||||
requires requires { self.p2; }
|
||||
{
|
||||
self.p2 = 1;
|
||||
return Builder<std::remove_reference_t<decltype(self)>::param1_v, true>(
|
||||
self);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue