Require C++11 range-based for
Fallback support for Boost.Foreach is broken and no one has reported it. The minimum required gcc version supports range-based for. Recent Clang supports range-based for. No Microsoft compilers are supported. Remove support for the fallback Boost.Foreach and move the C++11 range-based for test to the Cxx11RequiredFeature array.
This commit is contained in:
parent
1d1f3f6568
commit
95a53ed820
27
SConstruct
27
SConstruct
|
@ -328,6 +328,13 @@ struct %(N)s_derived : %(N)s_base {
|
||||||
array<int,2>b;
|
array<int,2>b;
|
||||||
b[0]=1;
|
b[0]=1;
|
||||||
'''
|
'''
|
||||||
|
),
|
||||||
|
Cxx11RequiredFeature('range-based for', '''
|
||||||
|
#include "compiler-range_for.h"
|
||||||
|
''', '''
|
||||||
|
int b[2];
|
||||||
|
range_for(int&c,b)c=0;
|
||||||
|
'''
|
||||||
),
|
),
|
||||||
Cxx11RequiredFeature('std::unordered_map::emplace', '''
|
Cxx11RequiredFeature('std::unordered_map::emplace', '''
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
@ -1369,26 +1376,6 @@ typedef tt::conditional<false,int,long>::type b;
|
||||||
if self.check_cxx11_type_traits(context, f):
|
if self.check_cxx11_type_traits(context, f):
|
||||||
return
|
return
|
||||||
raise SCons.Errors.StopError("C++ compiler does not support <type_traits>.")
|
raise SCons.Errors.StopError("C++ compiler does not support <type_traits>.")
|
||||||
@_implicit_test
|
|
||||||
def check_boost_foreach(self,context,**kwargs):
|
|
||||||
"""
|
|
||||||
help:assume Boost.Foreach works
|
|
||||||
"""
|
|
||||||
return self.Compile(context, msg='for Boost.Foreach', successflags={'CPPDEFINES' : ['DXX_HAVE_BOOST_FOREACH']}, **kwargs)
|
|
||||||
@_implicit_test
|
|
||||||
def check_cxx11_range_for(self,context,_successflags={'CPPDEFINES' : ['DXX_HAVE_CXX11_RANGE_FOR']},**kwargs):
|
|
||||||
return self.Compile(context, msg='for C++11 range-based for', successflags=_successflags, **kwargs)
|
|
||||||
@_custom_test
|
|
||||||
def _check_range_based_for(self,context):
|
|
||||||
include = '''
|
|
||||||
#include "compiler-range_for.h"
|
|
||||||
'''
|
|
||||||
main = '''
|
|
||||||
int b[2];
|
|
||||||
range_for(int&c,b)c=0;
|
|
||||||
'''
|
|
||||||
if not self.check_cxx11_range_for(context, text=include, main=main) and not self.check_boost_foreach(context, text=include, main=main):
|
|
||||||
raise SCons.Errors.StopError("C++ compiler does not support range-based for or Boost.Foreach.")
|
|
||||||
@_custom_test
|
@_custom_test
|
||||||
def check_cxx11_required_features(self,context):
|
def check_cxx11_required_features(self,context):
|
||||||
features = self.__cxx11_required_features
|
features = self.__cxx11_required_features
|
||||||
|
|
|
@ -6,11 +6,4 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(DXX_HAVE_CXX11_RANGE_FOR)
|
|
||||||
#define range_for(A,B) for(A:B)
|
#define range_for(A,B) for(A:B)
|
||||||
#elif defined(DXX_HAVE_BOOST_FOREACH)
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
#define range_for BOOST_FOREACH
|
|
||||||
#else
|
|
||||||
#error "No range-based for implementation found."
|
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in a new issue