//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14 // // // [simd.class] // template simd(U&& value); #include #include #include #include "test_macros.h" namespace ex = std::experimental::parallelism_v2; template auto not_supported_native_simd_ctor(Args&&... args) -> decltype(ex::native_simd(std::forward(args)...), void()) = delete; template void not_supported_native_simd_ctor(...) {} template auto supported_native_simd_ctor(Args&&... args) -> decltype(ex::native_simd(std::forward(args)...), void()) {} template void supported_native_simd_ctor(...) = delete; void compile_narrowing_conversion() { supported_native_simd_ctor(3); supported_native_simd_ctor(3); supported_native_simd_ctor(3); supported_native_simd_ctor(3); supported_native_simd_ctor(3); supported_native_simd_ctor(3); supported_native_simd_ctor(3); supported_native_simd_ctor(3); supported_native_simd_ctor(3.f); supported_native_simd_ctor(3.); supported_native_simd_ctor(3.); not_supported_native_simd_ctor(3.); not_supported_native_simd_ctor(long(3)); not_supported_native_simd_ctor(long(3)); not_supported_native_simd_ctor(3.); } void compile_convertible() { struct ConvertibleToInt { operator int64_t() const; }; supported_native_simd_ctor(ConvertibleToInt()); struct NotConvertibleToInt {}; not_supported_native_simd_ctor(NotConvertibleToInt()); } void compile_unsigned() { not_supported_native_simd_ctor(3u); supported_native_simd_ctor(3u); } template void test_broadcast() { SimdType a(3); for (size_t i = 0; i < a.size(); i++) { assert(a[i] == 3); } } int main(int, char**) { test_broadcast>(); test_broadcast>(); test_broadcast>(); return 0; }