Программы на C++. Форум разработчиков
Anonymous
Определение вне класса с требованием CLAUE отклоняется Clang, но работает с GCC
Сообщение
Anonymous » 24 июн 2025, 15:53
Clang в настоящее время отклоняет следующий код: < /p>
Код: Выделить всё
template
constexpr bool is_valid = true;
template
class Nesting
{
public:
template requires is_valid
class Inner;
};
template
template requires is_valid
class Nesting::Inner
{
public:
static inline void Do();
};
#include
template
template requires is_valid
inline void Nesting::Inner::Do()
{
std::cout
с < /p>
:14:31: error: requires clause differs in template redeclaration
14 | template requires is_valid
| ^
:8:35: note: previous template declaration is here
8 | template requires is_valid
| ^
:25:35: error: out-of-line definition of 'Do' from class 'Inner' without definition
25 | inline void Nesting::Inner::Do()
| ~~~~~~~~~~~~~~~~~~~~~~^
:31:19: error: implicit instantiation of undefined template 'Nesting::Inner'
31 | Nesting::Inner::Do();
| ^
:9:11: note: template is declared here
9 | class Inner;
Что не так с моим кодом - это ошибка Clang?
Подробнее здесь:
https://stackoverflow.com/questions/796 ... works-with
1750769624
Anonymous
Clang в настоящее время отклоняет следующий код: < /p> [code]template constexpr bool is_valid = true; template class Nesting { public: template requires is_valid class Inner; }; template template requires is_valid class Nesting::Inner { public: static inline void Do(); }; #include template template requires is_valid inline void Nesting::Inner::Do() { std::cout с < /p> :14:31: error: requires clause differs in template redeclaration 14 | template requires is_valid | ^ :8:35: note: previous template declaration is here 8 | template requires is_valid | ^ :25:35: error: out-of-line definition of 'Do' from class 'Inner' without definition 25 | inline void Nesting::Inner::Do() | ~~~~~~~~~~~~~~~~~~~~~~^ :31:19: error: implicit instantiation of undefined template 'Nesting::Inner' 31 | Nesting::Inner::Do(); | ^ :9:11: note: template is declared here 9 | class Inner; [/code] Что не так с моим кодом - это ошибка Clang? Подробнее здесь: [url]https://stackoverflow.com/questions/79677606/out-of-class-definition-with-requires-clause-is-rejected-by-clang-but-works-with[/url]
0 Ответы
5 Просмотры
Последнее сообщение Anonymous
24 июн 2025, 19:00
0 Ответы
1 Просмотры
Последнее сообщение Anonymous
10 апр 2025, 10:03
0 Ответы
1 Просмотры
Последнее сообщение Anonymous
10 апр 2025, 12:34
Требуется компиляция с помощью msvc, но отклоняется gcc
Гость »
13 мар 2024, 19:03 » в форуме
C++
Я написал следующую программу, которая использует require без круглых скобок. Программа компилируется с помощью msvc, но не с помощью gcc и clang. Я хочу знать, какой компилятор находится здесь. Демо
#include
template requires !std::is_enum_v...
0 Ответы
14 Просмотры
Последнее сообщение Гость
13 мар 2024, 19:03
Требуется компиляция с помощью msvc, но отклоняется gcc
Гость »
13 мар 2024, 20:20 » в форуме
C++
Я написал следующую программу, которая использует require без круглых скобок. Программа компилируется с помощью msvc, но не с помощью gcc и clang. Я хочу знать, какой компилятор находится здесь. Демо
#include
template requires !std::is_enum_v...
0 Ответы
14 Просмотры
Последнее сообщение Гость
13 мар 2024, 20:20