Language
C++
Compiler
gcc 7.2.0
Options
Warnings
Boost 1.65.1
C++1z(GNU)
Boost 1.65.1
C++1z(GNU)
Boost 1.65.1
C++1z(GNU)
Boost 1.65.1
C++1z(GNU)
no pedantic
Raw compiler options
-fconcepts
#include <iostream>
struct Foo { using Bar = int; };
template<typename T>
void doSmth(T)
{
if constexpr (requires { typename T::Bar; })
std::cout << "has nested! " << typename T::Bar {} << std::endl;
else
std::cout << "no nested!" << std::endl;
}
int main()
{
doSmth(Foo {});
//doSmth(0);
}
$ g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.65.1/gcc-7.2.0/include -std=gnu++1z -fconcepts
has nested! 0
Exit Code:
0