waifulib: cxx11: better C++11 detection by @mittorn

This commit is contained in:
Alibek Omarov 2019-10-27 23:06:37 +03:00
parent 75a36dd255
commit a1041073b1

View File

@ -25,6 +25,27 @@ modern_cpp_flags = {
'default': ['-std=c++11']
}
CXX11_LAMBDA_FRAGMENT='''
class T
{
static void M(){}
public:
void t()
{
auto l = []()
{
T::M();
};
}
};
int main()
{
T t;
t.t();
}
'''
@Configure.conf
def check_cxx11(ctx, *k, **kw):
if not 'msg' in kw:
@ -36,7 +57,7 @@ def check_cxx11(ctx, *k, **kw):
# not best way, but this check
# was written for exactly mainui_cpp,
# where lambdas are mandatory
return ctx.check_cxx(fragment='int main( void ){ auto pfnLambda = [](){}; return 0;}', *k, **kw)
return ctx.check_cxx(fragment=CXX11_LAMBDA_FRAGMENT, *k, **kw)
def configure(conf):
flags = get_flags_by_compiler(modern_cpp_flags, conf.env.COMPILER_CXX)
@ -51,4 +72,3 @@ def configure(conf):
if conf.env.CXX11_MANDATORY:
conf.fatal('C++11 support not available!')