Skip to content

Commit

Permalink
Replace c++ deprecated functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Jan 25, 2024
1 parent 4362701 commit 9a83836
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class IndexTransformIter {

public:
using iterator_category = std::random_access_iterator_tag; // NOLINT
using value_type = std::result_of_t<Fn(size_t)>; // NOLINT
using value_type = std::invoke_result_t<Fn, size_t>; // NOLINT
using difference_type = detail::ptrdiff_t; // NOLINT
using reference = std::add_lvalue_reference_t<value_type>; // NOLINT
using pointer = std::add_pointer_t<value_type>; // NOLINT
Expand Down
2 changes: 1 addition & 1 deletion src/common/linalg_op.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace linalg {
template <typename T, int32_t D, typename Fn>
void ElementWiseKernelDevice(linalg::TensorView<T, D> t, Fn&& fn, cudaStream_t s = nullptr) {
dh::safe_cuda(cudaSetDevice(t.DeviceIdx()));
static_assert(std::is_void<std::result_of_t<Fn(size_t, T&)>>::value,
static_assert(std::is_void<std::invoke_result_t<Fn, size_t, T&>>::value,
"For function with return, use transform instead.");
if (t.Contiguous()) {
auto ptr = t.Values().data();
Expand Down
2 changes: 1 addition & 1 deletion src/common/linalg_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void ElementWiseTransformHost(linalg::TensorView<T, D> t, int32_t n_threads, Fn&

template <typename T, int32_t D, typename Fn>
void ElementWiseKernelHost(linalg::TensorView<T, D> t, int32_t n_threads, Fn&& fn) {
static_assert(std::is_void<std::result_of_t<Fn(size_t, T&)>>::value,
static_assert(std::is_void<std::invoke_result_t<Fn, size_t, T&>>::value,
"For function with return, use transform instead.");
if (t.Contiguous()) {
auto ptr = t.Values().data();
Expand Down
10 changes: 4 additions & 6 deletions src/data/proxy_dmatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,13 @@ inline DMatrixProxy* MakeProxy(DMatrixHandle proxy) {
template <typename Fn>
decltype(auto) HostAdapterDispatch(DMatrixProxy const* proxy, Fn fn, bool* type_error = nullptr) {
if (proxy->Adapter().type() == typeid(std::shared_ptr<CSRArrayAdapter>)) {
auto value =
dmlc::get<std::shared_ptr<CSRArrayAdapter>>(proxy->Adapter())->Value();
auto value = dmlc::get<std::shared_ptr<CSRArrayAdapter>>(proxy->Adapter())->Value();
if (type_error) {
*type_error = false;
}
return fn(value);
} else if (proxy->Adapter().type() == typeid(std::shared_ptr<ArrayAdapter>)) {
auto value = dmlc::get<std::shared_ptr<ArrayAdapter>>(
proxy->Adapter())->Value();
auto value = dmlc::get<std::shared_ptr<ArrayAdapter>>(proxy->Adapter())->Value();
if (type_error) {
*type_error = false;
}
Expand All @@ -146,8 +144,8 @@ decltype(auto) HostAdapterDispatch(DMatrixProxy const* proxy, Fn fn, bool* type_
} else {
LOG(FATAL) << "Unknown type: " << proxy->Adapter().type().name();
}
return std::result_of_t<Fn(
decltype(std::declval<std::shared_ptr<ArrayAdapter>>()->Value()))>();
return std::invoke_result_t<Fn,
decltype(std::declval<std::shared_ptr<ArrayAdapter>>()->Value())>();
}
}
} // namespace data
Expand Down

0 comments on commit 9a83836

Please sign in to comment.