@@ -48,11 +48,33 @@ namespace experimental {
48
48
inline namespace __p1673_version_0 {
49
49
namespace linalg {
50
50
51
+ // begin anonymous namespace
52
+ namespace {
53
+
54
+ template <class Exec , class v_t , class = void >
55
+ struct is_custom_idx_abs_max_avail : std::false_type {};
56
+
57
+ template <class Exec , class v_t >
58
+ struct is_custom_idx_abs_max_avail <
59
+ Exec, v_t ,
60
+ std::enable_if_t <
61
+ std::is_integral<
62
+ decltype (idx_abs_max(std::declval<Exec>(),
63
+ std::declval<v_t>()
64
+ )
65
+ )
66
+ >::value
67
+ >
68
+ >
69
+ {
70
+ static constexpr bool value = !std::is_same<Exec,std::experimental::linalg::impl::inline_exec_t >::value;
71
+ };
72
+
51
73
template <class ElementType ,
52
74
extents<>::size_type ext0,
53
75
class Layout ,
54
76
class Accessor >
55
- extents<>::size_type idx_abs_max (
77
+ extents<>::size_type idx_abs_max_default_impl (
56
78
std::experimental::mdspan<ElementType, std::experimental::extents<ext0>, Layout, Accessor> v)
57
79
{
58
80
using std::abs ;
@@ -73,16 +95,38 @@ extents<>::size_type idx_abs_max(
73
95
return maxInd; // FIXME check for NaN "never less than" stuff
74
96
}
75
97
98
+ } // end anonymous namespace
99
+
76
100
template <class ExecutionPolicy ,
77
101
class ElementType ,
78
102
extents<>::size_type ext0,
79
103
class Layout ,
80
104
class Accessor >
81
105
extents<>::size_type idx_abs_max (
82
- ExecutionPolicy&& /* exec */ ,
106
+ ExecutionPolicy&& exec,
107
+ std::experimental::mdspan<ElementType, std::experimental::extents<ext0>, Layout, Accessor> v)
108
+ {
109
+ constexpr bool use_custom = is_custom_idx_abs_max_avail<
110
+ decltype (execpolicy_mapper (exec)), decltype (v)
111
+ >::value;
112
+
113
+ if constexpr (use_custom){
114
+ using return_type = extents<>::size_type;
115
+ return return_type (idx_abs_max (execpolicy_mapper (exec), v));
116
+ }
117
+ else {
118
+ return idx_abs_max_default_impl (v);
119
+ }
120
+ }
121
+
122
+ template <class ElementType ,
123
+ extents<>::size_type ext0,
124
+ class Layout ,
125
+ class Accessor >
126
+ extents<>::size_type idx_abs_max (
83
127
std::experimental::mdspan<ElementType, std::experimental::extents<ext0>, Layout, Accessor> v)
84
128
{
85
- return idx_abs_max (v);
129
+ return idx_abs_max (std::experimental::linalg::impl::default_exec_t (), v);
86
130
}
87
131
88
132
} // end namespace linalg
0 commit comments