Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

namespace bug with icc

$
0
0

The following compiles fine with gcc and clang but fails with icc 2016 (-std=c++14)

 

#include <tuple>
#include <type_traits>
#include <iostream>

namespace htl {
template<std::size_t... Ix, class Functor, class T>
auto map_impl(std::index_sequence<Ix...>, Functor f, const T& t) {
  return std::make_tuple(
    f(std::get<Ix>(t))...
  );
}

template<class Functor, class T>
auto map(Functor f, const T& t) {
  return map_impl(
    std::make_index_sequence<std::tuple_size<T>::value>(),
    f,
    t
  );
}
}

namespace detail {
template<int I>
auto get_subdimension(std::integral_constant<int, I>) {
  return std::integral_constant<int, I+1>();
}

auto get_subdimension(int x) {
  return x*x;
}

template<class T>
auto get_subdimensions(const T& x) {
  return htl::map([](auto x) { return get_subdimension(x); }, x);
}
}

int main() {
  auto t1 = std::make_tuple(3, std::integral_constant<int, 7>());
  detail::get_subdimensions(t1);
  return 0;
}

 


Viewing all articles
Browse latest Browse all 1616

Trending Articles