【发布时间】:2018-12-16 00:14:32
【问题描述】:
考虑一个简单的实用程序函数来计算合取,并使用此实用程序来确保 std::tuple 中的类型都相等。
#include <type_traits>
#include <tuple>
constexpr auto all() noexcept -> bool { return true; }
template <class... Bools>
constexpr auto all(bool const x, Bools... xs) noexcept -> bool
{
return x && all(xs...);
}
template <class T, class = void>
struct foo;
template <class T, class... Ts>
struct foo< std::tuple<T, Ts...>
, std::enable_if_t<all(std::is_same<T, Ts>::value...)>
> {
};
int main()
{
foo<std::tuple<int, int>> x;
}
GCC 和 Clang 可以处理这段代码,但 MSVC 不行。 Here's 一个神螺栓链接。所以我想知道,这是一个 MSVC 错误还是只是我遗漏了什么?
【问题讨论】:
标签: c++ visual-c++ c++14