# Changeset View

Changeset View

# Standalone View

Standalone View

# libcxx/test/std/experimental/simd/simd.whereexpr/where.pass.cpp

- This file was added.

1 | //===----------------------------------------------------------------------===// | ||||
---|---|---|---|---|---|

2 | // | ||||

3 | // The LLVM Compiler Infrastructure | ||||

4 | // | ||||

5 | // This file is dual licensed under the MIT and the University of Illinois Open | ||||

6 | // Source Licenses. See LICENSE.TXT for details. | ||||

7 | // | ||||

8 | //===----------------------------------------------------------------------===// | ||||

9 | | ||||

10 | // UNSUPPORTED: c++98, c++03 | ||||

11 | | ||||

12 | // <experimental/simd> | ||||

13 | // | ||||

14 | // // masked assignment [simd.mask.where] | ||||

15 | // template <class T, class Abi> | ||||

16 | // where_expression<simd_mask<T, Abi>, simd<T, Abi>> | ||||

17 | // where(const typename simd<T, Abi>::mask_type&, simd<T, Abi>&) noexcept; | ||||

18 | // | ||||

19 | // template <class T, class Abi> | ||||

20 | // const_where_expression<simd_mask<T, Abi>, const simd<T, Abi>> | ||||

21 | // where(const typename simd<T, Abi>::mask_type&, const simd<T, Abi>&) noexcept; | ||||

22 | // | ||||

23 | // template <class T, class Abi> | ||||

24 | // where_expression<simd_mask<T, Abi>, simd_mask<T, Abi>> | ||||

25 | // where(const nodeduce_t<simd_mask<T, Abi>>&, simd_mask<T, Abi>&) noexcept; | ||||

26 | // | ||||

27 | // template <class T, class Abi> | ||||

28 | // const_where_expression<simd_mask<T, Abi>, const simd_mask<T, Abi>> | ||||

29 | // where(const nodeduce_t<simd_mask<T, Abi>>&, const simd_mask<T, Abi>&) noexcept; | ||||

30 | // | ||||

31 | // template <class T> where_expression<bool, T> where(see below k, T& d) noexcept; | ||||

32 | // | ||||

33 | // template <class T> | ||||

34 | // const_where_expression<bool, const T> where(see below k, const T& d) noexcept; | ||||

35 | | ||||

36 | #include <experimental/simd> | ||||

37 | #include <cassert> | ||||

38 | #include <cstdint> | ||||

39 | #include <algorithm> | ||||

40 | | ||||

41 | using namespace std::experimental::parallelism_v2; | ||||

42 | | ||||

43 | void compile_const_where() { | ||||

44 | { | ||||

45 | const native_simd<int> a{}; | ||||

46 | static_assert( | ||||

47 | std::is_same<decltype(where(a < 2, a)), | ||||

48 | const_where_expression<native_simd_mask<int>, | ||||

49 | const native_simd<int>>>::value, | ||||

50 | ""); | ||||

51 | } | ||||

52 | { | ||||

53 | const native_simd_mask<int> a{}; | ||||

54 | static_assert( | ||||

55 | std::is_same< | ||||

56 | decltype(where(a, a)), | ||||

57 | const_where_expression<native_simd_mask<int>, | ||||

58 | const native_simd_mask<int>>>::value, | ||||

59 | ""); | ||||

60 | } | ||||

61 | { | ||||

62 | const bool b = true; | ||||

63 | static_assert(std::is_same<decltype(where(b, 3)), | ||||

64 | const_where_expression<bool, const int>>::value, | ||||

65 | ""); | ||||

66 | } | ||||

67 | } | ||||

68 | | ||||

69 | void compile_where() { | ||||

70 | { | ||||

71 | native_simd<int> a; | ||||

72 | static_assert( | ||||

73 | std::is_same< | ||||

74 | decltype(where(a < 2, a)), | ||||

75 | where_expression<native_simd_mask<int>, native_simd<int>>>::value, | ||||

76 | ""); | ||||

77 | } | ||||

78 | { | ||||

79 | native_simd_mask<int> a; | ||||

80 | static_assert(std::is_same<decltype(where(a, a)), | ||||

81 | where_expression<native_simd_mask<int>, | ||||

82 | native_simd_mask<int>>>::value, | ||||

83 | ""); | ||||

84 | } | ||||

85 | { | ||||

86 | int v = 3; | ||||

87 | static_assert( | ||||

88 | std::is_same<decltype(where(true, v)), where_expression<bool, int>>::value, | ||||

89 | ""); | ||||

90 | } | ||||

91 | } | ||||

92 | | ||||

93 | int main() {} |