ericniebler / meta

A tiny metaprogramming library
Boost Software License 1.0
302 stars 46 forks source link

Test gcc 5 in travis #25

Closed gnzlbg closed 9 years ago

gnzlbg commented 9 years ago

This make travis test clang 3.4 (C++11), clang 3.7 (C++11/14) and GCC 5 (C++11/14).

gnzlbg commented 9 years ago

@Manu343726 This PR adds 4 more entries to the test matrix. Do I have to change anything in the after_success part of the travis file for biicode ? I think that part runs after every entry of the matrix (i.e. before it ran 1 time, now it runs 5 times).

@ericniebler GCC 5 seems to have a problem with inline namespaces:

namespace meta {
  namespace extension  {
    template <typename F, typename T, T... Is>
    struct apply_list<F, std::integer_sequence<T, Is...>>
      // ^ error: specialization of alias template:
      // ‘template<class C, class List> using apply_list 
      //  = meta::v1::eval<meta::v1::extension::apply_list<C, List> >’
      : lazy::apply<F, std::integral_constant<T, Is>...> {};
  } // namespace extension
} // namespace meta

see the full error message here.

Then I tried to make it more explicit like this:

namespace meta {
  namespace extension  {
    template <typename F, typename T, T... Is>
    struct ::meta::extension::apply_list<F, std::integer_sequence<T, Is...>>
      // ^ error: reference to ‘extension’ is ambiguous, candidates are:
      //  `namespace meta::extension` and `namespace meta::v1::extension`
      : lazy::apply<F, std::integral_constant<T, Is>...> {};
  } // namespace extension
} // namespace meta

see the full error message here.

Changing this to the following makes gcc happy:

namespace meta {
  inline namespace v1 {  // be explicit here
  namespace extension  {
    template <typename F, typename T, T... Is>
    struct apply_list<F, std::integer_sequence<T, Is...>>
        : lazy::apply<F, std::integral_constant<T, Is>...> {};
  } // namespace extension
  } // namespace v1
} // namespace meta

I don't know enough about how inline namespaces interact with template specialization, but either this is a GCC bug or I misunderstood something fundamental about inline namespaces.

EDIT: from this SO question it appears that GCC is correct here: http://stackoverflow.com/questions/25435897/ambiguous-reference-to-namespace-within-an-inline-namespace

The namespaces meta::extension and meta::v1::extension are not the same namespaces, so when the inline namespace v1 inserts v1::extension into meta, there are two namespaces living in meta with the name extension that denote different namespaces and so the lookup is ambiguous.

There is a clang bug here

ericniebler commented 9 years ago

Awesome, thank you. I just started playing with gcc-5 last night. It doesn't like range-v3 at all.

gnzlbg commented 9 years ago

Awesome, thank you. I just started playing with gcc-5 last night. It doesn't like range-v3 at all.

I tried that too and ran away scared. I thought it would be better to start off with meta first, and then continue with range-v3.

I try to keep the constexpr_algorithms branch of range-v3 up to date since the only thing that remained to do was to get it to compile with gcc5.