template method in a C++ 20 'concepts'

101 views Asked by At

I would like to define a concept which requires a template method, like

template <typename t>
concept event = std::default_initializable<t> && std::copy_constructible<t>;

template <typename t>
concept dispatcher = requires(t p_t) {
  { template <event e> p_t.publish(e &) } -> std::same_as<void>;
};

I am using

g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

which reports main.cpp:11:5: Expected expression

in line { template <event e> p_t.publish(e &) } -> std::same_as<void>;

I've searching and by posts like this it seems it's not possible.

Is it really?

0

There are 0 answers