//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11, c++14 // See GCC PR63723. // UNSUPPORTED: gcc-4.9 // // // [simd.class] // template explicit simd(G&& gen); #include #include namespace ex = std::experimental::parallelism_v2; template auto not_supported_simd128_ctor(Args&&... args) -> decltype( ex::fixed_size_simd(std::forward(args)...), void()) = delete; template void not_supported_simd128_ctor(...) {} template auto supported_simd128_ctor(Args&&... args) -> decltype( ex::fixed_size_simd(std::forward(args)...), void()) {} template void supported_simd128_ctor(...) = delete; struct identity { template int operator()(std::integral_constant) const { return value; } }; void compile_generator() { supported_simd128_ctor(identity()); not_supported_simd128_ctor([](int i) { return float(i); }); not_supported_simd128_ctor([](intptr_t i) { return (int*)(i); }); not_supported_simd128_ctor([](int* i) { return i; }); } struct limited_identity { template typename std::conditional::type operator()(std::integral_constant) const { return value; } }; void compile_limited_identity() { supported_simd128_ctor(limited_identity()); not_supported_simd128_ctor(limited_identity()); } template void test_generator() { { SimdType a([](int i) { return i; }); assert(a[0] == 0); assert(a[1] == 1); assert(a[2] == 2); assert(a[3] == 3); } { SimdType a([](int i) { return 2 * i - 1; }); assert(a[0] == -1); assert(a[1] == 1); assert(a[2] == 3); assert(a[3] == 5); } } int main() { // TODO: adjust the tests when this assertion fails. assert(ex::native_simd::size() >= 4); test_generator>(); test_generator>(); }