1 2 3 4
├─────────┼─────────┼─────────┼─────────┤
argument: char A B C long
Functor #
= 1 Functor,
2 Functor,
3 Functor,
4 Functor
< /code>
code < /h3>
namespace ns
{
template
class Functor
{
public:
using first = X;
using second = Y;
Functor(X lVal) : x(lVal) {}
private:
X x;
};
template
requires(std::is_convertible_v && ...) //error
class Template
{
// How does one use `std::is_convertible_v` on
// an un-specialized template class?
};
template
class Template
{};
}
< /code>
Questions:
[list]
[*]What is the best approach?
[list]
Can this be done with fold expression(s)?
[*]Or concepts?
[/list]
[*]How does one use std::is_convertible
(или любая из других признаков метапрограммирования) на не эксперизованном классе шаблонов?
[/list]
Предположим, у меня есть два класса: < /p> [code]template class Functor {};
template class Template {}; < /code> Template[/code] имеет ограничения: [list] [*] Все функторы должны быть типа Functor
[*] Все функтор должен быть в последовательности first Functor must have Start as its [b]first[/b] argument [*]the [b]last[/b] Functor must have End as its [b]second[/b] argument [*]each Functor's [b]first[/b] argument is the [b]second[/b] Аргумент фанктора предшествует этому [/list] e.g. Functor , Functor , Functor , ... и т. Д.
Пример: Запуск с: char end: long
[code]Template t;[/code] [code] 1 2 3 4 ├─────────┼─────────┼─────────┼─────────┤ argument: char A B C long Functor # = 1 Functor, 2 Functor, 3 Functor, 4 Functor < /code> code < /h3> namespace ns { template class Functor { public: using first = X; using second = Y; Functor(X lVal) : x(lVal) {} private: X x; };
template requires(std::is_convertible_v && ...) //error class Template { // How does one use `std::is_convertible_v` on // an un-specialized template class? };
template class Template {}; } < /code> Questions: [list] [*]What is the best approach? [list] Can this be done with fold expression(s)? [*]Or concepts? [/list]
[*]How does one use std::is_convertible[/code] (или любая из других признаков метапрограммирования) на не эксперизованном классе шаблонов? [/list]