Skip to content

Commit

Permalink
Add cmake test for std::decay_t to fix cuda build
Browse files Browse the repository at this point in the history
  • Loading branch information
msimberg committed Jan 17, 2018
1 parent 26fa6ed commit 8ef85e4
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cmake/HPX_AddConfigTest.cmake
Expand Up @@ -630,6 +630,14 @@ macro(hpx_check_for_cxx14_return_type_deduction)
CMAKECXXFEATURE cxx_return_type_deduction)
endmacro()

###############################################################################
macro(hpx_check_for_cxx14_std_decay_t)
add_hpx_config_test(HPX_WITH_CXX14_STD_DECAY_T
SOURCE cmake/tests/cxx14_std_decay_t.cpp
FILE ${ARGN}
CMAKECXXFEATURE cxx_std::decay_t)
endmacro()

###############################################################################
macro(hpx_check_for_libfun_std_experimental_optional)
add_hpx_config_test(HPX_WITH_LIBFUN_EXPERIMENTAL_OPTIONAL
Expand Down
3 changes: 3 additions & 0 deletions cmake/HPX_PerformCxxFeatureTests.cmake
Expand Up @@ -164,6 +164,9 @@ macro(hpx_perform_cxx_feature_tests)
hpx_check_for_cxx14_std_integer_sequence(
DEFINITIONS HPX_HAVE_CXX14_STD_INTEGER_SEQUENCE)

hpx_check_for_cxx14_std_decay_t(
DEFINITIONS HPX_HAVE_CXX14_STD_DECAY_T)

hpx_check_for_cxx14_std_is_final(
DEFINITIONS HPX_HAVE_CXX14_STD_IS_FINAL)

Expand Down
13 changes: 13 additions & 0 deletions cmake/tests/cxx14_std_decay_t.cpp
@@ -0,0 +1,13 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2018 Mikael Simberg
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
////////////////////////////////////////////////////////////////////////////////

#include <type_traits>

int main()
{
std::decay_t<int> a;
}
1 change: 1 addition & 0 deletions hpx/config.hpp
Expand Up @@ -20,6 +20,7 @@
#include <hpx/config/compiler_native_tls.hpp>
#include <hpx/config/compiler_specific.hpp>
#include <hpx/config/constexpr.hpp>
#include <hpx/config/decay_t.hpp>
#include <hpx/config/defines.hpp>
#include <hpx/config/emulate_deleted.hpp>
#include <hpx/config/export_definitions.hpp>
Expand Down
17 changes: 17 additions & 0 deletions hpx/config/decay_t.hpp
@@ -0,0 +1,17 @@
// Copyright (c) 2018 Mikael Simberg
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef HPX_CONFIG_DECAY_T_HPP
#define HPX_CONFIG_DECAY_T_HPP

#include <hpx/config/defines.hpp>

#if defined(HPX_HAVE_CXX14_DECAY_T)
#define HPX_DECAY_T(T) std::decay_t<T>
#else
#define HPX_DECAY_T(T) typename std::decay<T>::type
#endif

#endif
6 changes: 4 additions & 2 deletions hpx/util/optional.hpp
Expand Up @@ -6,6 +6,8 @@
#if !defined(HPX_UTIL_OPTIONAL_HPP)
#define HPX_UTIL_OPTIONAL_HPP

#include <hpx/config.hpp>

#include <exception>
#include <string>
#include <stdexcept>
Expand Down Expand Up @@ -483,9 +485,9 @@ namespace hpx { namespace util

///////////////////////////////////////////////////////////////////////////
template <typename T>
constexpr optional<std::decay_t<T>> make_optional(T && v)
constexpr optional<HPX_DECAY_T(T)> make_optional(T && v)
{
return optional<std::decay_t<T>>(std::forward<T>(v));
return optional<HPX_DECAY_T(T)>(std::forward<T>(v));
}

template <typename T, typename ... Ts>
Expand Down

0 comments on commit 8ef85e4

Please sign in to comment.