[질문]
C++ concept로 함수랑 인자를 제한하는 방법 없을까
익명(64.120)
2021-01-11 22:04
추천 0
뭔 소리냐면 대충 이런 식
#include <type_traits>
template <typename Fn
>
concept FooPredicate
= std
::is_invocable_r_v
<bool, Fn
, FooElement
>;
template <typename Fn
>
concept FooPolicy
=
std
::is_invocable_r_v
<FooElement
, Fn
, FooThreashold
, FooPredicate
>;
이러는 방법이 없을까
FooPolicy 에다 typename을 하나 더 추가해서 FooPredicate에 넘겨주는 방식 밖에 없을 거 같은데 너무 지저분하다
지금 쓰고 있는 방식은 이럼
#include <type_traits>
template <typename Fn
>
concept FooPredicate
= std
::is_invocable_r_v
<bool, Fn
, FooElement
>;
template <typename Fn
, typename Compare
>
concept FooPolicy
=
std
::is_invocable_r_v
<FooElement
, Fn
, FooThreashold
, Compare
>;
template <FooPredicate Predicate
= DefaultPredicate
,
FooPolicy
<Predicate
> Policy
= DefaultPolicy
>
struct PolicyManager {};
// ssibal dirty as fuck
으아악
requires?
와중에 Threshold 스펠링 틀림
앗... 넘어가주라