diff --git a/CMakeLists.txt b/CMakeLists.txt index 35eb8530948e..6ec72f5eeff2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -910,27 +910,29 @@ if(NOT MSVC) if(HPX_WITH_CUDA AND NOT HPX_WITH_CUDA_CLANG) set(CXX_FLAG -std=c++11) else() - # Try -std=c++14 first - # The Intel compiler has the C++14 flag, but doesn't have sufficient C++14 - # support to compile Boost. If the user has explicitly asked for it, use it, - # otherwise don't run the check. - # FIXME: This should be replaced with a version-based check in the future - # when the Intel compiler is able to build Boost with -std=c++14. - if(HPX_WITH_CXX14 OR NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")) + # Try -std=c++14 first + if(HPX_WITH_CXX14 OR NOT (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17))) check_cxx_compiler_flag(-std=c++14 HPX_WITH_CXX14) endif() - if(HPX_WITH_CXX14) + if(HPX_WITH_CXX14) set(CXX_FLAG -std=c++14) + # The Intel compiler doesn't appear to have a fully functional + # implementation of C++14 constexpr. It's fine with our C++14 constexpr + # usage in HPX but chokes on Boost. + # FIXME: This should be replaced with a version-based check in the future + # when the Intel compiler is able to build Boost with -std=c++14. + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + add_definitions(-DBOOST_NO_CXX14_CONSTEXPR) + endif() else() # ... otherwise try -std=c++1y - # See comment above. - # FIXME: This should be replaced with a version-based check in the future - # when the Intel compiler is able to build Boost with -std=c++14. - if(HPX_WITH_CXX1Y OR NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")) - check_cxx_compiler_flag(-std=c++1y HPX_WITH_CXX1Y) + if(HPX_WITH_CXX1Y OR NOT (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17))) + check_cxx_compiler_flag(-std=c++1y HPX_WITH_CXX1y) endif() if(HPX_WITH_CXX1Y) diff --git a/cmake/HPX_AddConfigTest.cmake b/cmake/HPX_AddConfigTest.cmake index e7af4ba9a82c..efbd8e559bff 100644 --- a/cmake/HPX_AddConfigTest.cmake +++ b/cmake/HPX_AddConfigTest.cmake @@ -445,9 +445,9 @@ macro(hpx_check_for_cxx14_std_result_of_sfinae) endmacro() ############################################################################### -macro(hpx_check_for_cxx_experimental_std_optional) - add_hpx_config_test(HPX_WITH_CXX1Y_EXPERIMENTAL_OPTIONAL - SOURCE cmake/tests/cxx1y_experimental_std_optional.cpp +macro(hpx_check_for_libfun_std_experimental_optional) + add_hpx_config_test(HPX_WITH_LIBFUN_EXPERIMENTAL_OPTIONAL + SOURCE cmake/tests/libfun_std_experimental_optional.cpp FILE ${ARGN}) endmacro() diff --git a/cmake/HPX_PerformCxxFeatureTests.cmake b/cmake/HPX_PerformCxxFeatureTests.cmake index 49ab537139a1..0e3585c55e60 100644 --- a/cmake/HPX_PerformCxxFeatureTests.cmake +++ b/cmake/HPX_PerformCxxFeatureTests.cmake @@ -130,7 +130,7 @@ macro(hpx_perform_cxx_feature_tests) hpx_check_for_cxx11_std_type_traits( DEFINITIONS HPX_HAVE_CXX11_STD_TYPE_TRAITS) - if(HPX_WITH_CXX1Y) + if(HPX_WITH_CXX1Y OR HPX_WITH_CXX14) # Check the availability of certain C++14 language features hpx_check_for_cxx14_constexpr( DEFINITIONS HPX_HAVE_CXX14_CONSTEXPR) @@ -153,10 +153,11 @@ macro(hpx_perform_cxx_feature_tests) endif() # check for experimental facilities - if(HPX_WITH_CXX1Y) - # check for experimenta/optional only of in C++14 mode - hpx_check_for_cxx_experimental_std_optional( - DEFINITIONS HPX_HAVE_CXX1Y_EXPERIMENTAL_OPTIONAL) + if(HPX_WITH_CXX1Y OR HPX_WITH_CXX14) + # check for Library Fundamentals TS v2's experimental/optional only if in + # C++1y or C++14 mode. + hpx_check_for_libfun_std_experimental_optional( + DEFINITIONS HPX_HAVE_LIBFUN_STD_EXPERIMENTAL_OPTIONAL) endif() endmacro() diff --git a/cmake/tests/cxx1y_experimental_std_optional.cpp b/cmake/tests/libfun_std_experimental_optional.cpp similarity index 100% rename from cmake/tests/cxx1y_experimental_std_optional.cpp rename to cmake/tests/libfun_std_experimental_optional.cpp diff --git a/hpx/parallel/datapar/execution_policy.hpp b/hpx/parallel/datapar/execution_policy.hpp index c1d62e232681..d9d1078edfc8 100644 --- a/hpx/parallel/datapar/execution_policy.hpp +++ b/hpx/parallel/datapar/execution_policy.hpp @@ -348,7 +348,7 @@ namespace hpx { namespace parallel { namespace execution { HPX_INLINE_NAMESPACE( }; /// \cond NOINTERNAL - HPX_CONSTEXPR dataseq_policy() {} + HPX_CONSTEXPR dataseq_policy() : exec_{}, params_{} {} /// \endcond /// Create a new dataseq_task_policy. @@ -451,7 +451,7 @@ namespace hpx { namespace parallel { namespace execution { HPX_INLINE_NAMESPACE( }; /// Default sequential execution policy object. - static dataseq_policy HPX_CONSTEXPR_OR_CONST dataseq; + HPX_STATIC_CONSTEXPR dataseq_policy dataseq; /// The class dataseq_policy is an execution policy type used /// as a unique type to disambiguate parallel algorithm overloading and @@ -764,7 +764,7 @@ namespace hpx { namespace parallel { namespace execution { HPX_INLINE_NAMESPACE( }; /// \cond NOINTERNAL - HPX_CONSTEXPR datapar_policy() {} + HPX_CONSTEXPR datapar_policy() : exec_{}, params_{} {} /// \endcond /// Create a new datapar_policy referencing a chunk size. @@ -1363,8 +1363,8 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) execution::datapar_policy_shim; /////////////////////////////////////////////////////////////////////////// - static dataseq_execution_policy HPX_CONSTEXPR_OR_CONST dataseq_execution; - static datapar_execution_policy HPX_CONSTEXPR_OR_CONST datapar_execution; + HPX_STATIC_CONSTEXPR dataseq_execution_policy dataseq_execution; + HPX_STATIC_CONSTEXPR datapar_execution_policy datapar_execution; }}} #endif diff --git a/hpx/parallel/execution_policy.hpp b/hpx/parallel/execution_policy.hpp index 332dc1a1d8b3..d32fef70bf90 100644 --- a/hpx/parallel/execution_policy.hpp +++ b/hpx/parallel/execution_policy.hpp @@ -355,7 +355,7 @@ namespace hpx { namespace parallel { namespace execution }; /// \cond NOINTERNAL - HPX_CONSTEXPR sequenced_policy() {} + HPX_CONSTEXPR sequenced_policy() : exec_{}, params_{} {} /// \endcond /// Create a new sequenced_task_policy. @@ -459,7 +459,7 @@ namespace hpx { namespace parallel { namespace execution }; /// Default sequential execution policy object. - static sequenced_policy HPX_CONSTEXPR_OR_CONST seq; + HPX_STATIC_CONSTEXPR sequenced_policy seq; /// The class sequenced_policy is an execution policy type used /// as a unique type to disambiguate parallel algorithm overloading and @@ -916,7 +916,7 @@ namespace hpx { namespace parallel { namespace execution }; /// \cond NOINTERNAL - HPX_CONSTEXPR parallel_policy() {} + HPX_CONSTEXPR parallel_policy() : exec_{}, params_{} {} /// \endcond /// Create a new parallel_policy referencing a chunk size. @@ -1013,7 +1013,7 @@ namespace hpx { namespace parallel { namespace execution }; /// Default parallel execution policy object. - static parallel_policy HPX_CONSTEXPR_OR_CONST par; + HPX_STATIC_CONSTEXPR parallel_policy par; /// The class parallel_policy_shim is an execution policy type /// used as a unique type to disambiguate parallel algorithm overloading @@ -1176,7 +1176,7 @@ namespace hpx { namespace parallel { namespace execution typedef parallel::parallel_execution_tag execution_category; /// \cond NOINTERNAL - HPX_CONSTEXPR parallel_unsequenced_policy() {} + HPX_CONSTEXPR parallel_unsequenced_policy() : exec_{}, params_{} {} /// \endcond /// Create a new parallel_unsequenced_policy from itself @@ -1218,7 +1218,7 @@ namespace hpx { namespace parallel { namespace execution }; /// Default vector execution policy object. - static parallel_unsequenced_policy HPX_CONSTEXPR_OR_CONST par_unseq; + HPX_STATIC_CONSTEXPR parallel_unsequenced_policy par_unseq; /////////////////////////////////////////////////////////////////////////// // Allow to detect execution policies which were created as a result @@ -1437,11 +1437,11 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v1) using task_execution_policy_tag = parallel::execution::task_policy_tag; /////////////////////////////////////////////////////////////////////////// - static sequential_execution_policy HPX_CONSTEXPR_OR_CONST seq; - static parallel_execution_policy HPX_CONSTEXPR_OR_CONST par; - static parallel_vector_execution_policy HPX_CONSTEXPR_OR_CONST par_vec; + HPX_STATIC_CONSTEXPR sequential_execution_policy seq; + HPX_STATIC_CONSTEXPR parallel_execution_policy par; + HPX_STATIC_CONSTEXPR parallel_vector_execution_policy par_vec; - static task_execution_policy_tag HPX_CONSTEXPR_OR_CONST task; + HPX_STATIC_CONSTEXPR task_execution_policy_tag task; #if defined(HPX_HAVE_GENERIC_EXECUTION_POLICY) /////////////////////////////////////////////////////////////////////////// diff --git a/hpx/parallel/executors/executor_traits.hpp b/hpx/parallel/executors/executor_traits.hpp index 84d6fb528cb8..fa3bcf30d2ce 100644 --- a/hpx/parallel/executors/executor_traits.hpp +++ b/hpx/parallel/executors/executor_traits.hpp @@ -33,7 +33,7 @@ #include #include -#if defined(HPX_HAVE_CXX1Y_EXPERIMENTAL_OPTIONAL) +#if defined(HPX_HAVE_LIBFUN_STD_EXPERIMENTAL_OPTIONAL) #include #else #include @@ -177,7 +177,7 @@ namespace hpx { namespace parallel { HPX_INLINE_NAMESPACE(v3) auto && args = hpx::util::forward_as_tuple(std::forward(ts)...); -#if defined(HPX_HAVE_CXX1Y_EXPERIMENTAL_OPTIONAL) +#if defined(HPX_HAVE_LIBFUN_STD_EXPERIMENTAL_OPTIONAL) std::experimental::optional out; auto && wrapper = [&]() mutable diff --git a/hpx/runtime/threads/run_as_hpx_thread.hpp b/hpx/runtime/threads/run_as_hpx_thread.hpp index 7d4992ed7513..3211313da247 100644 --- a/hpx/runtime/threads/run_as_hpx_thread.hpp +++ b/hpx/runtime/threads/run_as_hpx_thread.hpp @@ -22,7 +22,7 @@ #include #include -#if defined(HPX_HAVE_CXX1Y_EXPERIMENTAL_OPTIONAL) +#if defined(HPX_HAVE_LIBFUN_STD_EXPERIMENTAL_OPTIONAL) #include #else #include @@ -47,7 +47,7 @@ namespace hpx { namespace threads // Using the optional for storing the returned result value // allows to support non-default-constructible and move-only // types. -#if defined(HPX_HAVE_CXX1Y_EXPERIMENTAL_OPTIONAL) +#if defined(HPX_HAVE_LIBFUN_STD_EXPERIMENTAL_OPTIONAL) std::experimental::optional result; #else boost::optional result; @@ -62,7 +62,7 @@ namespace hpx { namespace threads // Execute the given function, forward all parameters, // store result. -#if defined(HPX_HAVE_CXX1Y_EXPERIMENTAL_OPTIONAL) +#if defined(HPX_HAVE_LIBFUN_STD_EXPERIMENTAL_OPTIONAL) result.emplace(util::invoke_fused(f, std::move(args))); #elif BOOST_VERSION < 105600 result = boost::in_place(