/
niceSOFT
/
swig
Обзор
Документация
Войти
/
niceSOFT
/
swig
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Examples/test-suite/cpp20_variable_templates.i
17 строк
614 B
William S Fulton
C++20: parse a requires-expression as a primary in expression position
10 май 2026, 19:37
10 май 2026, 19:37
c2de37f
Код
Авторство
О чём код?
%module cpp20_variable_templates // C++20 added the ability to initialise a variable template from a // requires-expression. A %template instantiation of such a variable is // wrapped as a read only variable holding the bool the expression // evaluates to. %inline %{ template<typename T> constexpr bool Addable = requires (T t) { t + t; }; // Empty struct without an operator+, so Addable<NotAddable> is false. struct NotAddable {}; %} %template(addable_int) Addable<int>; // true: int + int compiles %template(addable_notaddable) Addable<NotAddable>; // false: NotAddable has no operator+