Use template aliases when available
This commit is contained in:
parent
d536832239
commit
d9f6e944c9
16
SConstruct
16
SConstruct
|
@ -707,6 +707,22 @@ struct B:A {{
|
||||||
if not macro_value:
|
if not macro_value:
|
||||||
raise SCons.Errors.StopError("C++ compiler does not support constructor forwarding.")
|
raise SCons.Errors.StopError("C++ compiler does not support constructor forwarding.")
|
||||||
context.sconf.Define(macro_name + macro_parameters, macro_value)
|
context.sconf.Define(macro_name + macro_parameters, macro_value)
|
||||||
|
@_custom_test
|
||||||
|
def check_cxx11_template_alias(self,context):
|
||||||
|
text = '''
|
||||||
|
template <typename>
|
||||||
|
struct A;
|
||||||
|
template <typename T>
|
||||||
|
using B = A<T>;
|
||||||
|
int main(int, char **){
|
||||||
|
A<int> *a = 0;
|
||||||
|
B<int> *b = a;
|
||||||
|
(void)b;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
if self.Cxx11Compile(context, text=text, msg='for C++11 template aliases'):
|
||||||
|
context.sconf.Define('DXX_HAVE_CXX11_TEMPLATE_ALIAS')
|
||||||
|
|
||||||
class LazyObjectConstructor:
|
class LazyObjectConstructor:
|
||||||
def __lazy_objects(self,name,source):
|
def __lazy_objects(self,name,source):
|
||||||
|
|
|
@ -38,8 +38,13 @@ struct tree_index_sequence<1>
|
||||||
typedef index_sequence<0> type;
|
typedef index_sequence<0> type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef DXX_HAVE_CXX11_TEMPLATE_ALIAS
|
||||||
|
template <std::size_t N>
|
||||||
|
using make_tree_index_sequence = typename tree_index_sequence<N>::type;
|
||||||
|
#else
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
static inline constexpr typename tree_index_sequence<N>::type make_tree_index_sequence()
|
static inline constexpr typename tree_index_sequence<N>::type make_tree_index_sequence()
|
||||||
{
|
{
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue