Use template aliases when available

This commit is contained in:
Kp 2014-08-02 04:51:07 +00:00
parent d536832239
commit d9f6e944c9
2 changed files with 21 additions and 0 deletions

View file

@ -707,6 +707,22 @@ struct B:A {{
if not macro_value:
raise SCons.Errors.StopError("C++ compiler does not support constructor forwarding.")
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:
def __lazy_objects(self,name,source):

View file

@ -38,8 +38,13 @@ struct tree_index_sequence<1>
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>
static inline constexpr typename tree_index_sequence<N>::type make_tree_index_sequence()
{
return {};
}
#endif