Я написал следующую программу, которая работает с msvc c++17, но отклонена gcc и clang. Я хочу знать, какой компилятор находится здесь.
Демо.
#include
struct C
{
std::variant mem;
C(std::variant p): mem(p)
{
}
};
int main()
{
C c(1); //works with msvc but not with gcc and clang
}
GCC говорит:
: In function 'int main()':
:13:10: error: no matching function for call to 'C::C(int)'
13 | C c(1); //works with msvc but not with gcc and clang
| ^
:6:5: note: candidate: 'C::C(std::variant)'
6 | C(std::variant p): mem(p)
| ^
:6:26: note: no known conversion for argument 1 from 'int' to 'std::variant'
6 | C(std::variant p): mem(p)
| ~~~~~~~~~~~~~~~~~~~^
:3:8: note: candidate: 'constexpr C::C(const C&)'
3 | struct C
| ^
:3:8: note: no known conversion for argument 1 from 'int' to 'const C&'
:3:8: note: candidate: 'constexpr C::C(C&&)'
:3:8: note: no known conversion for argument 1 from 'int' to 'C&&'
:13:7: warning: unused variable 'c' [-Wunused-variable]
13 | C c(1); //works with msvc but not with gcc and clang
Подробнее здесь: https://stackoverflow.com/questions/781 ... not-in-gcc