Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit a607152

Browse files
committed
Emit diagnostics for device lambdas
1 parent 88ec5b8 commit a607152

File tree

5 files changed

+19
-41
lines changed

5 files changed

+19
-41
lines changed

thrust/detail/type_traits/result_of_adaptable_function.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <thrust/detail/type_traits.h>
2121
#include <thrust/detail/type_traits/function_traits.h>
2222

23+
#include <cub/detail/type_traits.cuh>
24+
2325
#include <type_traits>
2426

2527
THRUST_NAMESPACE_BEGIN
@@ -29,7 +31,6 @@ namespace detail
2931
// Sets `type` to the result of the specified Signature invocation. If the
3032
// callable defines a `result_type` alias member, that type is used instead.
3133
// Use invoke_result / result_of when FuncType::result_type is not defined.
32-
#if THRUST_CPP_DIALECT >= 2017
3334
template <typename Signature, typename Enable = void>
3435
struct result_of_adaptable_function
3536
{
@@ -39,16 +40,12 @@ struct result_of_adaptable_function
3940
template <typename F, typename...Args>
4041
struct impl<F(Args...)>
4142
{
42-
using type = std::invoke_result_t<F, Args...>;
43+
using type = CUB_NS_QUALIFIER::detail::invoke_result_t<F, Args...>;
4344
};
4445

4546
public:
4647
using type = typename impl<Signature>::type;
4748
};
48-
#else // < C++17
49-
template <typename Signature, typename Enable = void>
50-
struct result_of_adaptable_function : std::result_of<Signature> {};
51-
#endif // < C++17
5249

5350
// specialization for invocations which define result_type
5451
template <typename Functor, typename... ArgTypes>

thrust/iterator/detail/transform_input_output_iterator.inl

+4-13
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
#pragma once
1818

1919
#include <thrust/detail/config.h>
20-
2120
#include <thrust/iterator/iterator_adaptor.h>
2221

22+
#include <cub/detail/type_traits.cuh>
23+
2324
THRUST_NAMESPACE_BEGIN
2425

2526
template <typename InputFunction, typename OutputFunction, typename Iterator>
@@ -35,12 +36,7 @@ template <typename InputFunction, typename OutputFunction, typename Iterator>
3536
{
3637
using iterator_value_type = typename thrust::iterator_value<Iterator>::type;
3738

38-
// std::result_of is deprecated in 2017, replace with std::invoke_result
39-
#if THRUST_CPP_DIALECT < 2017
40-
using Value = typename std::result_of<InputFunction(iterator_value_type)>::type;
41-
#else
42-
using Value = std::invoke_result_t<InputFunction, iterator_value_type>;
43-
#endif
39+
using Value = cub::detail::invoke_result_t<InputFunction, iterator_value_type>;
4440

4541
public:
4642
__host__ __device__
@@ -93,12 +89,7 @@ public:
9389
<
9490
transform_input_output_iterator<InputFunction, OutputFunction, Iterator>
9591
, Iterator
96-
// std::result_of is deprecated in 2017, replace with std::invoke_result
97-
#if THRUST_CPP_DIALECT < 2017
98-
, typename std::result_of<InputFunction(iterator_value_type)>::type
99-
#else
100-
, std::invoke_result_t<InputFunction, iterator_value_type>
101-
#endif
92+
, cub::detail::invoke_result_t<InputFunction, iterator_value_type>
10293
, thrust::use_default
10394
, thrust::use_default
10495
, transform_input_output_iterator_proxy<InputFunction, OutputFunction, Iterator>

thrust/optional.h

+6-11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <thrust/detail/config.h>
1717
#include <thrust/detail/cpp11_required.h>
1818

19+
#include <cub/detail/type_traits.cuh>
20+
1921
#if THRUST_CPP_DIALECT >= 2011
2022

2123
#include <thrust/addressof.h>
@@ -256,19 +258,12 @@ constexpr auto invoke(Fn &&f, Args &&... args)
256258
return std::forward<Fn>(f)(std::forward<Args>(args)...);
257259
}
258260

259-
// std::invoke_result from C++17
260-
template <class F, class, class... Us> struct invoke_result_impl;
261-
262-
template <class F, class... Us>
263-
struct invoke_result_impl<
264-
F, decltype(detail::invoke(std::declval<F>(), std::declval<Us>()...), void()),
265-
Us...> {
266-
using type = decltype(detail::invoke(std::declval<F>(), std::declval<Us>()...));
261+
template <class F, class... Us>
262+
struct invoke_result
263+
{
264+
using type = CUB_NS_QUALIFIER::detail::invoke_result_t<F, Us...>;
267265
};
268266

269-
template <class F, class... Us>
270-
using invoke_result = invoke_result_impl<F, void, Us...>;
271-
272267
template <class F, class... Us>
273268
using invoke_result_t = typename invoke_result<F, Us...>::type;
274269
#endif

thrust/system/cuda/detail/transform_scan.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include <thrust/system/cuda/detail/scan.h>
3434
#include <thrust/distance.h>
3535

36+
#include <cub/detail/type_traits.cuh>
37+
3638
THRUST_NAMESPACE_BEGIN
3739

3840
namespace cuda_cub {
@@ -52,12 +54,7 @@ transform_inclusive_scan(execution_policy<Derived> &policy,
5254
{
5355
// Use the transformed input iterator's value type per https://wg21.link/P0571
5456
using input_type = typename thrust::iterator_value<InputIt>::type;
55-
#if THRUST_CPP_DIALECT < 2017
56-
using result_type = typename std::result_of<TransformOp(input_type)>::type;
57-
#else
58-
using result_type = std::invoke_result_t<TransformOp, input_type>;
59-
#endif
60-
57+
using result_type = CUB_NS_QUALIFIER::detail::invoke_result_t<TransformOp, input_type>;
6158
using value_type = typename std::remove_reference<result_type>::type;
6259

6360
typedef typename iterator_traits<InputIt>::difference_type size_type;

thrust/system/detail/generic/transform_scan.inl

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <thrust/detail/type_traits/function_traits.h>
2626
#include <thrust/detail/type_traits/iterator/is_output_iterator.h>
2727

28+
#include <cub/detail/type_traits.cuh>
29+
2830
THRUST_NAMESPACE_BEGIN
2931
namespace system
3032
{
@@ -49,11 +51,7 @@ __host__ __device__
4951
{
5052
// Use the input iterator's value type per https://wg21.link/P0571
5153
using InputType = typename thrust::iterator_value<InputIterator>::type;
52-
#if THRUST_CPP_DIALECT < 2017
53-
using ResultType = typename std::result_of<UnaryFunction(InputType)>::type;
54-
#else
55-
using ResultType = std::invoke_result_t<UnaryFunction, InputType>;
56-
#endif
54+
using ResultType = CUB_NS_QUALIFIER::detail::invoke_result_t<UnaryFunction, InputType>;
5755
using ValueType = typename std::remove_reference<ResultType>::type;
5856

5957
thrust::transform_iterator<UnaryFunction, InputIterator, ValueType> _first(first, unary_op);

0 commit comments

Comments
 (0)