From 086193d802d1e7127f3927a473402195184cf133 Mon Sep 17 00:00:00 2001 From: Allison Vacanti Date: Mon, 24 Feb 2020 18:57:47 -0500 Subject: [PATCH] Deprecate C++03, C++11, MSVC < 2017, GCC < 5.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build infrastructure and static configuration fixes: - Bump CMAKE_CXX_STANDARD to 14 - Add `-Werror all-warnings` to NVCC to promote warnings to errors - Add `-Xcudafe --display_error_number` to get useful diagnositics from cudafe. - Clean up cub include dir spec in CMake. - Move THRUST_DEPRECATED logic out of compiler.h and into new header. - Fix CPP dialect detection on newer MSVC. - Remove raw `__cplusplus` checks. - Use `_Pragma`/`__pragma` instead of `#pragma` in macro. - Remove THRUST_BEGIN/END_NS macros. - These were used inconsistently, rendering them non-functional. Removing to prevent people from trying to use them. Workarounds for msvc: - MSVC isn't a fan of `decltype(...)::some_member` syntax. - WAR by aliasing the `decltype(...)` and doing `NewAlias::some_member` - Missing `template` keyword when rebinding pointer in `async/reduce.h` - Silence warning C4494 `declspec(allocator) used on non-pointer/ref type` - Bug in MSVC STL: https://github.com/microsoft/STL/issues/696 - Disable async sort test on MSVC - Triage. Looks like a bug in cudafe? See thrust/thrust#1098. - Add pointer::pointer_to(reference) - Required for C++11, hard compile error on MSVC. - Bring a definition of `atanh` into scope for complex number impl - Fix floating point literals be declared as floats instead of doubles - Replace `std::remove_reference::type&` with `std::add_lvalue_reference`. - Same behavior, and MSVC chokes on the other syntax when followed by `__host__`. - Remove constexpr markup from defaulted functions. - These are constexpr by default when possible, and the compilers were complaining about the markup in places. - Use `thrust::detail::integer_traits` instead of `std::numeric_limits` in device code. - Avoid aligning beyond platform limits in alignment.cu. - Pass /bigobj to MSVC so it can handle the async tests - Work around MSVC compiler bug by replacing SFINAE with static dispatch Bug 2865172 Bug 2880936 Reviewed-by: Bryce Adelstein Lelbach aka wash Reviewed-by: MichaƂ 'Griwes' Dominiak --- CMakeLists.txt | 31 ++++-- dependencies/cub | 2 +- doc/thrust.dox | 2 - examples/cuda/async_reduce.cu | 5 +- examples/cuda/global_device_vector.cu | 3 +- internal/benchmark/bench.cu | 3 +- internal/build/common_compiler.mk | 11 ++ testing/alignment.cu | 17 ++- testing/allocator.cu | 5 +- testing/async_sort.cu | 4 +- testing/complex.cu | 4 +- testing/dependencies_aware_policies.cu | 7 +- testing/mr_disjoint_pool.cu | 10 +- testing/mr_pool.cu | 10 +- testing/vector.cu | 5 +- testing/vector_allocators.cu | 8 +- thrust/addressof.h | 5 +- thrust/allocate_unique.h | 5 +- thrust/async/copy.h | 5 +- thrust/async/for_each.h | 5 +- thrust/async/reduce.h | 92 ++++++++++++---- thrust/async/sort.h | 28 +++-- thrust/async/transform.h | 5 +- thrust/complex.h | 2 +- thrust/detail/alignment.h | 12 +- thrust/detail/allocator/allocator_traits.h | 2 +- .../detail/allocator_aware_execution_policy.h | 2 +- thrust/detail/complex/catrig.h | 14 ++- thrust/detail/complex/catrigf.h | 13 ++- thrust/detail/config/compiler.h | 12 +- thrust/detail/config/config.h | 1 + thrust/detail/config/cpp_dialect.h | 104 +++++++++++++++--- .../{util/blocking.h => config/deprecated.h} | 34 +++--- thrust/detail/config/exec_check_disable.h | 6 +- thrust/detail/contiguous_storage.h | 5 +- thrust/detail/contiguous_storage.inl | 5 +- thrust/detail/distance.inl | 1 + thrust/detail/event_error.h | 5 +- thrust/detail/execute_with_allocator.h | 2 +- thrust/detail/execute_with_dependencies.h | 2 +- thrust/detail/memory_algorithms.h | 8 +- thrust/detail/pointer.h | 6 + thrust/detail/select_system.h | 5 +- thrust/detail/static_assert.h | 5 +- thrust/detail/tuple_algorithms.h | 5 +- thrust/detail/type_traits.h | 9 +- .../result_of_adaptable_function.h | 4 +- thrust/detail/vector_base.h | 5 +- thrust/detail/vector_base.inl | 5 +- thrust/device_make_unique.h | 5 +- thrust/future.h | 5 +- thrust/host_vector.h | 4 +- thrust/iterator/detail/reverse_iterator.inl | 4 +- thrust/iterator/reverse_iterator.h | 4 +- thrust/limits.h | 5 +- thrust/mr/allocator.h | 6 +- thrust/mr/detail/config.h | 2 +- thrust/mr/validator.h | 2 +- thrust/optional.h | 22 ++-- thrust/per_device_resource.h | 5 +- thrust/system/cpp/detail/vector.inl | 4 +- thrust/system/cpp/vector.h | 4 +- .../system/cuda/detail/adjacent_difference.h | 5 +- thrust/system/cuda/detail/assign_value.h | 5 +- thrust/system/cuda/detail/async/copy.h | 27 +++-- .../system/cuda/detail/async/customization.h | 5 +- thrust/system/cuda/detail/async/for_each.h | 5 +- thrust/system/cuda/detail/async/reduce.h | 7 +- thrust/system/cuda/detail/async/sort.h | 5 +- thrust/system/cuda/detail/async/transform.h | 5 +- thrust/system/cuda/detail/binary_search.h | 5 +- thrust/system/cuda/detail/copy.h | 10 +- thrust/system/cuda/detail/copy_if.h | 5 +- .../system/cuda/detail/core/agent_launcher.h | 5 +- thrust/system/cuda/detail/core/alignment.h | 5 +- .../cuda/detail/core/triple_chevron_launch.h | 5 +- thrust/system/cuda/detail/core/util.h | 5 +- thrust/system/cuda/detail/count.h | 5 +- thrust/system/cuda/detail/cross_system.h | 65 ++++++----- thrust/system/cuda/detail/dispatch.h | 7 +- thrust/system/cuda/detail/equal.h | 5 +- thrust/system/cuda/detail/execution_policy.h | 5 +- thrust/system/cuda/detail/extrema.h | 5 +- thrust/system/cuda/detail/fill.h | 5 +- thrust/system/cuda/detail/find.h | 10 +- thrust/system/cuda/detail/for_each.h | 5 +- thrust/system/cuda/detail/future.inl | 5 +- thrust/system/cuda/detail/gather.h | 5 +- thrust/system/cuda/detail/generate.h | 5 +- thrust/system/cuda/detail/get_value.h | 5 +- thrust/system/cuda/detail/inner_product.h | 5 +- .../cuda/detail/internal/copy_cross_system.h | 5 +- .../detail/internal/copy_device_to_device.h | 5 +- thrust/system/cuda/detail/iter_swap.h | 5 +- .../cuda/detail/make_unsigned_special.h | 5 +- thrust/system/cuda/detail/malloc_and_free.h | 5 +- thrust/system/cuda/detail/merge.h | 5 +- thrust/system/cuda/detail/mismatch.h | 10 +- thrust/system/cuda/detail/par.h | 5 +- thrust/system/cuda/detail/par_to_seq.h | 5 +- thrust/system/cuda/detail/parallel_for.h | 5 +- thrust/system/cuda/detail/partition.h | 5 +- .../system/cuda/detail/per_device_resource.h | 5 +- thrust/system/cuda/detail/reduce.h | 5 +- thrust/system/cuda/detail/reduce_by_key.h | 5 +- thrust/system/cuda/detail/remove.h | 5 +- thrust/system/cuda/detail/replace.h | 5 +- thrust/system/cuda/detail/reverse.h | 10 +- thrust/system/cuda/detail/scan.h | 10 +- thrust/system/cuda/detail/scan_by_key.h | 5 +- thrust/system/cuda/detail/scatter.h | 5 +- thrust/system/cuda/detail/set_operations.h | 5 +- thrust/system/cuda/detail/sort.h | 5 +- thrust/system/cuda/detail/swap_ranges.h | 5 +- thrust/system/cuda/detail/tabulate.h | 5 +- thrust/system/cuda/detail/transform.h | 5 +- thrust/system/cuda/detail/transform_reduce.h | 5 +- thrust/system/cuda/detail/transform_scan.h | 5 +- .../system/cuda/detail/uninitialized_copy.h | 5 +- .../system/cuda/detail/uninitialized_fill.h | 5 +- thrust/system/cuda/detail/unique.h | 5 +- thrust/system/cuda/detail/unique_by_key.h | 5 +- thrust/system/cuda/detail/util.h | 5 +- thrust/system/cuda/detail/vector.inl | 4 +- thrust/system/cuda/future.h | 5 +- thrust/system/cuda/memory.h | 5 +- thrust/system/cuda/memory_resource.h | 5 +- thrust/system/cuda/vector.h | 4 +- thrust/system/detail/generic/distance.inl | 2 +- thrust/system/omp/detail/vector.inl | 4 +- thrust/system/omp/vector.h | 4 +- thrust/system/tbb/detail/vector.inl | 4 +- thrust/system/tbb/vector.h | 4 +- thrust/type_traits/integer_sequence.h | 5 +- thrust/type_traits/is_contiguous_iterator.h | 11 +- thrust/type_traits/is_execution_policy.h | 5 +- ...operator_less_or_greater_function_object.h | 5 +- .../is_operator_plus_function_object.h | 5 +- thrust/type_traits/is_trivially_relocatable.h | 9 +- thrust/type_traits/logical_metafunctions.h | 5 +- thrust/type_traits/remove_cvref.h | 5 +- thrust/type_traits/void_t.h | 5 +- thrust/version.h | 12 -- thrust/zip_function.h | 5 +- 144 files changed, 724 insertions(+), 423 deletions(-) rename thrust/detail/{util/blocking.h => config/deprecated.h} (52%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36a883f2c0..5e7d429eea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,11 +64,13 @@ endif () add_definitions(-DTHRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_${THRUST_DEVICE_SYSTEM}) # Please note this also sets the default for the CUDA C++ version; see the comment below. -set(CMAKE_CXX_STANDARD 11 CACHE STRING "The C++ version to be used.") +set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ version to be used.") set(CMAKE_CXX_EXTENSIONS OFF) message("-- C++ Standard version: ${CMAKE_CXX_STANDARD}") +set(CUB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/dependencies/cub") + if ("CUDA" STREQUAL "${THRUST_DEVICE_SYSTEM}") if (NOT "${CMAKE_CUDA_HOST_COMPILER}" STREQUAL "") unset(CMAKE_CUDA_HOST_COMPILER CACHE) @@ -177,6 +179,19 @@ if ("MSVC" STREQUAL "${CMAKE_CXX_COMPILER_ID}") # Disable warning about applying unary operator- to unsigned type. append_option_if_available("/wd4146" THRUST_CXX_WARNINGS) + # MSVC STL assumes that `allocator_traits`'s allocator will use raw pointers, + # and the `__DECLSPEC_ALLOCATOR` macro causes issues with thrust's universal + # allocators: + # warning C4494: 'std::allocator_traits<_Alloc>::allocate' : + # Ignoring __declspec(allocator) because the function return type is not + # a pointer or reference + # See https://github.com/microsoft/STL/issues/696 + append_option_if_available("/wd4494" THRUST_CXX_WARNINGS) + + # Some of the async tests require /bigobj to fit all their sections into the + # object files: + append_option_if_available("/bigobj" THRUST_CXX_WARNINGS) + set(THRUST_TREAT_FILE_AS_CXX "/TP") else () append_option_if_available("-Werror" THRUST_CXX_WARNINGS) @@ -243,6 +258,8 @@ if ("CUDA" STREQUAL "${THRUST_DEVICE_SYSTEM}") foreach (CXX_OPTION IN LISTS THRUST_CXX_WARNINGS) set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler=${CXX_OPTION}") endforeach () + set(CMAKE_CUDA_FLAGS + "${CMAKE_CUDA_FLAGS} -Werror all-warnings -Xcudafe --display_error_number") endif () # For every public header, build a translation unit containing `#include
` @@ -355,7 +372,7 @@ endforeach () add_library(header-test OBJECT ${THRUST_HEADER_TEST_SOURCES}) target_include_directories( header-test - PUBLIC ${PROJECT_SOURCE_DIR} + PUBLIC ${PROJECT_SOURCE_DIR} ${CUB_INCLUDE_DIR} ) include(CTest) @@ -383,7 +400,7 @@ endif () add_library(thrust_testframework STATIC ${THRUST_TESTFRAMEWORK_FILES}) target_include_directories( thrust_testframework - PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/dependencies/cub + PUBLIC ${PROJECT_SOURCE_DIR} ${CUB_INCLUDE_DIR} PRIVATE ${PROJECT_SOURCE_DIR}/testing ) @@ -491,7 +508,7 @@ foreach (THRUST_TEST_SOURCE IN LISTS THRUST_TESTS) target_include_directories( ${THRUST_TEST} - PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/dependencies/cub + PUBLIC ${PROJECT_SOURCE_DIR} ${CUB_INCLUDE_DIR} PRIVATE ${PROJECT_SOURCE_DIR}/testing ) @@ -518,7 +535,7 @@ foreach (THRUST_TEST_SOURCE IN LISTS THRUST_TESTS) target_include_directories( ${THRUST_TEST_RDC} - PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/dependencies/cub + PUBLIC ${PROJECT_SOURCE_DIR} ${CUB_INCLUDE_DIR} PRIVATE ${PROJECT_SOURCE_DIR}/testing ) @@ -617,7 +634,7 @@ foreach (THRUST_EXAMPLE_SOURCE IN LISTS THRUST_EXAMPLES) target_include_directories( ${THRUST_EXAMPLE} - PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/dependencies/cub + PUBLIC ${PROJECT_SOURCE_DIR} ${CUB_INCLUDE_DIR} PRIVATE ${PROJECT_SOURCE_DIR}/examples ) @@ -640,7 +657,7 @@ foreach (THRUST_EXAMPLE_SOURCE IN LISTS THRUST_EXAMPLES) target_include_directories( ${THRUST_EXAMPLE_RDC} - PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/dependencies/cub + PUBLIC ${PROJECT_SOURCE_DIR} ${CUB_INCLUDE_DIR} PRIVATE ${PROJECT_SOURCE_DIR}/examples ) diff --git a/dependencies/cub b/dependencies/cub index b2e64cf0fb..66a3f9324e 160000 --- a/dependencies/cub +++ b/dependencies/cub @@ -1 +1 @@ -Subproject commit b2e64cf0fb4ea7ace6c86ca6765ca7c1087ef82e +Subproject commit 66a3f9324e9cfde6f9f68512c7bb38dff43cd2e1 diff --git a/doc/thrust.dox b/doc/thrust.dox index b74f436f55..95ec1a4806 100644 --- a/doc/thrust.dox +++ b/doc/thrust.dox @@ -2063,8 +2063,6 @@ PREDEFINED = THRUST_NOEXCEPT=noexcept \ "THRUST_MR_DEFAULT_ALIGNMENT=alignof(max_align_t)" \ "THRUST_FINAL=final" \ "THRUST_OVERRIDE=" \ - "THRUST_BEGIN_NS=namespace thrust {" \ - "THRUST_END_NS=}" \ "cuda_cub=system::cuda" # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this diff --git a/examples/cuda/async_reduce.cu b/examples/cuda/async_reduce.cu index ca21c88cbc..845fe882de 100644 --- a/examples/cuda/async_reduce.cu +++ b/examples/cuda/async_reduce.cu @@ -1,9 +1,10 @@ +#include #include #include #include #include -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 #include #endif @@ -52,7 +53,7 @@ int main() // reset the result result[0] = 0; -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 // method 2: use std::async to create asynchrony // copy all the algorithm parameters diff --git a/examples/cuda/global_device_vector.cu b/examples/cuda/global_device_vector.cu index 1419cae627..a995667962 100644 --- a/examples/cuda/global_device_vector.cu +++ b/examples/cuda/global_device_vector.cu @@ -1,3 +1,4 @@ +#include #include // If you create a global `thrust::device_vector` with the default allocator, @@ -20,7 +21,7 @@ typedef thrust::system::cuda::detail::cuda_memory_resource< thrust::cuda::pointer > device_ignore_shutdown_memory_resource; -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template using device_ignore_shutdown_allocator = thrust::mr::stateless_resource_allocator< diff --git a/internal/benchmark/bench.cu b/internal/benchmark/bench.cu index 786d9f34cd..b574693c10 100644 --- a/internal/benchmark/bench.cu +++ b/internal/benchmark/bench.cu @@ -4,6 +4,7 @@ #include #include #include +#include #if THRUST_CPP_DIALECT >= 2011 #include @@ -47,7 +48,7 @@ // We don't use THRUST_NOEXCEPT because it's new, and we want this benchmark to // be backwards-compatible to older versions of Thrust. -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 #define NOEXCEPT noexcept #else #define NOEXCEPT throw() diff --git a/internal/build/common_compiler.mk b/internal/build/common_compiler.mk index 2d6fc28a28..b337c4fe90 100644 --- a/internal/build/common_compiler.mk +++ b/internal/build/common_compiler.mk @@ -117,5 +117,16 @@ else ifeq ($(OS),win32) # Disable warning about applying unary - to unsigned type. CUDACC_FLAGS += -Xcompiler "/wd4146" + + # Warning about declspec(allocator) on inappropriate function types + CUDACC_FLAGS += -Xcompiler "/wd4494" + + # Allow tests to have lots and lots of sections in each translation unit: + CUDACC_FLAGS += -Xcompiler "/bigobj" endif +# Promote all NVCC warnings into errors +CUDACC_FLAGS += -Werror all-warnings + +# Print warning numbers with cudafe diagnostics +CUDACC_FLAGS += -Xcudafe --display_error_number diff --git a/testing/alignment.cu b/testing/alignment.cu index 6ddf1c73c0..e55df2e961 100644 --- a/testing/alignment.cu +++ b/testing/alignment.cu @@ -210,7 +210,7 @@ void test_aligned_type() DECLARE_UNITTEST(test_aligned_type); template -void test_aligned_storage_instantiation() +void test_aligned_storage_instantiation(thrust::detail::true_type /* Align is valid */) { typedef typename thrust::detail::aligned_storage::type type; ASSERT_GEQUAL(sizeof(type), Len); @@ -218,6 +218,21 @@ void test_aligned_storage_instantiation() ASSERT_EQUAL(thrust::detail::alignment_of::value, Align); } +template +void test_aligned_storage_instantiation(thrust::detail::false_type /* Align is invalid */) +{ + // no-op -- alignment is > max_align_t and MSVC complains loudly. +} + +template +void test_aligned_storage_instantiation() +{ + typedef thrust::detail::integral_constant< + bool, Align <= THRUST_ALIGNOF(thrust::detail::max_align_t)> + ValidAlign; + test_aligned_storage_instantiation(ValidAlign()); +} + template void test_aligned_storage_size() { diff --git a/testing/allocator.cu b/testing/allocator.cu index edc6f0d522..a29408de95 100644 --- a/testing/allocator.cu +++ b/testing/allocator.cu @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -202,7 +203,7 @@ void TestAllocatorTraitsRebind() } DECLARE_UNITTEST(TestAllocatorTraitsRebind); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 void TestAllocatorTraitsRebindCpp11() { ASSERT_EQUAL( @@ -250,5 +251,5 @@ void TestAllocatorTraitsRebindCpp11() ); } DECLARE_UNITTEST(TestAllocatorTraitsRebindCpp11); -#endif +#endif // C++11 diff --git a/testing/async_sort.cu b/testing/async_sort.cu index 626e21c3ce..c9ae1dd34e 100644 --- a/testing/async_sort.cu +++ b/testing/async_sort.cu @@ -1,6 +1,8 @@ #include -#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC) +// Disabled on MSVC for GH issue #1098 +#if THRUST_CPP_DIALECT >= 2011 && !defined(THRUST_LEGACY_GCC) && \ + THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC #include diff --git a/testing/complex.cu b/testing/complex.cu index e69f2e7cdb..cf980962ae 100644 --- a/testing/complex.cu +++ b/testing/complex.cu @@ -1,6 +1,8 @@ #include #include +#include + #include #include #include @@ -273,7 +275,7 @@ struct TestComplexTrigonometricFunctions ASSERT_ALMOST_EQUAL(sinh(a),sinh(c)); ASSERT_ALMOST_EQUAL(tanh(a),tanh(c)); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 ASSERT_ALMOST_EQUAL(acos(a),acos(c)); ASSERT_ALMOST_EQUAL(asin(a),asin(c)); diff --git a/testing/dependencies_aware_policies.cu b/testing/dependencies_aware_policies.cu index 5f48bf4f26..5313392151 100644 --- a/testing/dependencies_aware_policies.cu +++ b/testing/dependencies_aware_policies.cu @@ -1,5 +1,6 @@ #include +#include #include #include #include @@ -9,7 +10,7 @@ # include #endif -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template struct test_allocator_t @@ -178,11 +179,11 @@ SimpleUnitTest< > > TestDependencyAttachmentInstance; -#else +#else // C++11 void TestDummy() { } DECLARE_UNITTEST(TestDummy); -#endif +#endif // C++11 diff --git a/testing/mr_disjoint_pool.cu b/testing/mr_disjoint_pool.cu index 8832506718..8499c6c538 100644 --- a/testing/mr_disjoint_pool.cu +++ b/testing/mr_disjoint_pool.cu @@ -1,8 +1,10 @@ #include + +#include #include #include -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 #include #endif @@ -177,7 +179,7 @@ void TestDisjointUnsynchronizedPool() } DECLARE_UNITTEST(TestDisjointUnsynchronizedPool); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 void TestDisjointSynchronizedPool() { TestDisjointPool(); @@ -260,7 +262,7 @@ void TestDisjointUnsynchronizedPoolCachingOversized() } DECLARE_UNITTEST(TestDisjointUnsynchronizedPoolCachingOversized); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 void TestDisjointSynchronizedPoolCachingOversized() { TestDisjointPoolCachingOversized(); @@ -285,7 +287,7 @@ void TestUnsynchronizedDisjointGlobalPool() } DECLARE_UNITTEST(TestUnsynchronizedDisjointGlobalPool); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 void TestSynchronizedDisjointGlobalPool() { TestDisjointGlobalPool(); diff --git a/testing/mr_pool.cu b/testing/mr_pool.cu index bd91c04ead..75b18f038c 100644 --- a/testing/mr_pool.cu +++ b/testing/mr_pool.cu @@ -1,8 +1,10 @@ #include + +#include #include #include -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 #include #endif @@ -241,7 +243,7 @@ void TestUnsynchronizedPool() } DECLARE_UNITTEST(TestUnsynchronizedPool); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 void TestSynchronizedPool() { TestPool(); @@ -324,7 +326,7 @@ void TestUnsynchronizedPoolCachingOversized() } DECLARE_UNITTEST(TestUnsynchronizedPoolCachingOversized); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 void TestSynchronizedPoolCachingOversized() { TestPoolCachingOversized(); @@ -348,7 +350,7 @@ void TestUnsynchronizedGlobalPool() } DECLARE_UNITTEST(TestUnsynchronizedGlobalPool); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 void TestSynchronizedGlobalPool() { TestGlobalPool(); diff --git a/testing/vector.cu b/testing/vector.cu index ed39d0edfe..8154b01c6c 100644 --- a/testing/vector.cu +++ b/testing/vector.cu @@ -1,6 +1,9 @@ #include + +#include #include #include + #include #include #include @@ -742,7 +745,7 @@ void TestVectorReversed(void) } DECLARE_VECTOR_UNITTEST(TestVectorReversed); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template void TestVectorMove(void) { diff --git a/testing/vector_allocators.cu b/testing/vector_allocators.cu index 00535d1b04..c7276b28cf 100644 --- a/testing/vector_allocators.cu +++ b/testing/vector_allocators.cu @@ -1,4 +1,6 @@ #include + +#include #include #include @@ -23,7 +25,7 @@ public: return *this; } -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 stateful_allocator(stateful_allocator && other) : BaseAlloc(std::move(other)), state(other.state) { @@ -129,7 +131,7 @@ void TestVectorAllocatorConstructors() ASSERT_EQUAL(Alloc::last_allocated, 2); Alloc::last_allocated = 0; -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 // FIXME: uncomment this after the vector_base(vector_base&&, const Alloc&) // is fixed and implemented // Vector v5(std::move(v3), alloc2); @@ -188,7 +190,7 @@ void TestVectorAllocatorPropagateOnCopyAssignmentDevice() } DECLARE_UNITTEST(TestVectorAllocatorPropagateOnCopyAssignmentDevice); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template void TestVectorAllocatorPropagateOnMoveAssignment() { diff --git a/thrust/addressof.h b/thrust/addressof.h index 5d4dbf3490..1134c759bc 100644 --- a/thrust/addressof.h +++ b/thrust/addressof.h @@ -11,7 +11,8 @@ # include #endif -THRUST_BEGIN_NS +namespace thrust +{ /////////////////////////////////////////////////////////////////////////////// @@ -28,5 +29,5 @@ T* addressof(T& arg) /////////////////////////////////////////////////////////////////////////////// -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/allocate_unique.h b/thrust/allocate_unique.h index 5daec97e03..8b1562b0eb 100644 --- a/thrust/allocate_unique.h +++ b/thrust/allocate_unique.h @@ -18,7 +18,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ // wg21.link/p0316r0 @@ -437,7 +438,7 @@ uninitialized_allocate_unique_n( /////////////////////////////////////////////////////////////////////////////// -THRUST_END_NS +} // end namespace thrust #endif // THRUST_CPP_DIALECT >= 2011 diff --git a/thrust/async/copy.h b/thrust/async/copy.h index b5923be2c2..e1bb46e60e 100644 --- a/thrust/async/copy.h +++ b/thrust/async/copy.h @@ -33,7 +33,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace async { @@ -140,7 +141,7 @@ THRUST_INLINE_CONSTANT copy_detail::copy_fn copy{}; } // namespace async -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/async/for_each.h b/thrust/async/for_each.h index 3bd86a6920..fc1814bdc6 100644 --- a/thrust/async/for_each.h +++ b/thrust/async/for_each.h @@ -33,7 +33,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace async { @@ -113,7 +114,7 @@ THRUST_INLINE_CONSTANT for_each_detail::for_each_fn for_each{}; } // namespace async -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/async/reduce.h b/thrust/async/reduce.h index ab63d6224b..a37499584d 100644 --- a/thrust/async/reduce.h +++ b/thrust/async/reduce.h @@ -35,7 +35,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace async { @@ -95,10 +96,11 @@ struct reduce_fn final , typename ForwardIt, typename Sentinel, typename T > __host__ - static auto call( + static auto call4( thrust::detail::execution_policy_base const& exec , ForwardIt&& first, Sentinel&& last , T&& init + , thrust::true_type ) // ADL dispatch. THRUST_DECLTYPE_RETURNS( @@ -116,9 +118,10 @@ struct reduce_fn final > __host__ static auto - call( + call3( thrust::detail::execution_policy_base const& exec , ForwardIt&& first, Sentinel&& last + , thrust::true_type ) // ADL dispatch. THRUST_DECLTYPE_RETURNS( @@ -136,10 +139,12 @@ struct reduce_fn final template __host__ - static auto call(ForwardIt&& first, Sentinel&& last, T&& init, BinaryOp&& op) - THRUST_DECLTYPE_RETURNS_WITH_SFINAE_CONDITION( - (negation>>::value) - , reduce_fn::call( + static auto call4(ForwardIt&& first, Sentinel&& last, + T&& init, + BinaryOp&& op, + thrust::false_type) + THRUST_DECLTYPE_RETURNS( + reduce_fn::call( thrust::detail::select_system( typename iterator_system>::type{} ) @@ -151,10 +156,11 @@ struct reduce_fn final template __host__ - static auto call(ForwardIt&& first, Sentinel&& last, T&& init) - THRUST_DECLTYPE_RETURNS_WITH_SFINAE_CONDITION( - (negation>>::value) - , reduce_fn::call( + static auto call3(ForwardIt&& first, Sentinel&& last, + T&& init, + thrust::false_type) + THRUST_DECLTYPE_RETURNS( + reduce_fn::call( thrust::detail::select_system( typename iterator_system>::type{} ) @@ -164,6 +170,25 @@ struct reduce_fn final ) ) + // MSVC WAR: MSVC gets angsty and eats all available RAM when we try to detect + // if T1 is an execution_policy by using SFINAE. Switching to a static + // dispatch pattern to prevent this. + template + __host__ + static auto call(T1&& t1, T2&& t2, T3&& t3) + THRUST_DECLTYPE_RETURNS( + reduce_fn::call3(THRUST_FWD(t1), THRUST_FWD(t2), THRUST_FWD(t3), + thrust::is_execution_policy>{}) + ) + + template + __host__ + static auto call(T1&& t1, T2&& t2, T3&& t3, T4&& t4) + THRUST_DECLTYPE_RETURNS( + reduce_fn::call4(THRUST_FWD(t1), THRUST_FWD(t2), THRUST_FWD(t3), THRUST_FWD(t4), + thrust::is_execution_policy>{}) + ) + template __host__ static auto call(ForwardIt&& first, Sentinel&& last) @@ -257,11 +282,12 @@ struct reduce_into_fn final , typename T > __host__ - static auto call( + static auto call5( thrust::detail::execution_policy_base const& exec , ForwardIt&& first, Sentinel&& last , OutputIt&& output , T&& init + , thrust::true_type ) // ADL dispatch. THRUST_DECLTYPE_RETURNS( @@ -280,10 +306,11 @@ struct reduce_into_fn final > __host__ static auto - call( + call4( thrust::detail::execution_policy_base const& exec , ForwardIt&& first, Sentinel&& last , OutputIt&& output + , thrust::true_type ) // ADL dispatch. THRUST_DECLTYPE_RETURNS( @@ -305,15 +332,15 @@ struct reduce_into_fn final , typename T, typename BinaryOp > __host__ - static auto call( + static auto call5( ForwardIt&& first, Sentinel&& last , OutputIt&& output , T&& init , BinaryOp&& op + , thrust::false_type ) - THRUST_DECLTYPE_RETURNS_WITH_SFINAE_CONDITION( - (negation>>::value) - , reduce_into_fn::call( + THRUST_DECLTYPE_RETURNS( + reduce_into_fn::call( thrust::detail::select_system( typename iterator_system>::type{} , typename iterator_system>::type{} @@ -330,14 +357,14 @@ struct reduce_into_fn final , typename T > __host__ - static auto call( + static auto call4( ForwardIt&& first, Sentinel&& last , OutputIt&& output , T&& init + , thrust::false_type ) - THRUST_DECLTYPE_RETURNS_WITH_SFINAE_CONDITION( - (negation>>::value) - , reduce_into_fn::call( + THRUST_DECLTYPE_RETURNS( + reduce_into_fn::call( thrust::detail::select_system( typename iterator_system>::type{} , typename iterator_system>::type{} @@ -374,6 +401,27 @@ struct reduce_into_fn final ) ) + // MSVC WAR: MSVC gets angsty and eats all available RAM when we try to detect + // if T1 is an execution_policy by using SFINAE. Switching to a static + // dispatch pattern to prevent this. + template + __host__ + static auto call(T1&& t1, T2&& t2, T3&& t3, T4&& t4) + THRUST_DECLTYPE_RETURNS( + reduce_into_fn::call4( + THRUST_FWD(t1), THRUST_FWD(t2), THRUST_FWD(t3), THRUST_FWD(t4), + thrust::is_execution_policy>{}) + ) + + template + __host__ + static auto call(T1&& t1, T2&& t2, T3&& t3, T4&& t4, T5&& t5) + THRUST_DECLTYPE_RETURNS( + reduce_into_fn::call5( + THRUST_FWD(t1), THRUST_FWD(t2), THRUST_FWD(t3), THRUST_FWD(t4), + THRUST_FWD(t5), thrust::is_execution_policy>{}) + ) + template THRUST_NODISCARD __host__ auto operator()(Args&&... args) const @@ -388,7 +436,7 @@ THRUST_INLINE_CONSTANT reduce_into_detail::reduce_into_fn reduce_into{}; } // namespace async -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/async/sort.h b/thrust/async/sort.h index 5a3ef067ad..0b6a558302 100644 --- a/thrust/async/sort.h +++ b/thrust/async/sort.h @@ -35,7 +35,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace async { @@ -199,9 +200,10 @@ struct sort_fn final , typename ForwardIt, typename Sentinel > __host__ - static auto call( + static auto call3( thrust::detail::execution_policy_base const& exec , ForwardIt&& first, Sentinel&& last + , thrust::true_type ) THRUST_DECLTYPE_RETURNS( sort_fn::call( @@ -215,10 +217,11 @@ struct sort_fn final template __host__ - static auto call(ForwardIt&& first, Sentinel&& last, StrictWeakOrdering&& comp) - THRUST_DECLTYPE_RETURNS_WITH_SFINAE_CONDITION( - (negation>>::value) - , sort_fn::call( + static auto call3(ForwardIt&& first, Sentinel&& last, + StrictWeakOrdering&& comp, + thrust::false_type) + THRUST_DECLTYPE_RETURNS( + sort_fn::call( thrust::detail::select_system( typename iterator_system>::type{} ) @@ -227,6 +230,17 @@ struct sort_fn final ) ) + // MSVC WAR: MSVC gets angsty and eats all available RAM when we try to detect + // if T1 is an execution_policy by using SFINAE. Switching to a static + // dispatch pattern to prevent this. + template + __host__ + static auto call(T1&& t1, T2&& t2, T3&& t3) + THRUST_DECLTYPE_RETURNS( + sort_fn::call3(THRUST_FWD(t1), THRUST_FWD(t2), THRUST_FWD(t3), + thrust::is_execution_policy>{}) + ) + template __host__ static auto call(ForwardIt&& first, Sentinel&& last) @@ -256,7 +270,7 @@ THRUST_INLINE_CONSTANT sort_detail::sort_fn sort{}; } // namespace async -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/async/transform.h b/thrust/async/transform.h index 3e13914159..3011a5df77 100644 --- a/thrust/async/transform.h +++ b/thrust/async/transform.h @@ -33,7 +33,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace async { @@ -128,7 +129,7 @@ THRUST_INLINE_CONSTANT transform_detail::transform_fn transform{}; } // namespace async -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/complex.h b/thrust/complex.h index cd21f24093..badacb4679 100644 --- a/thrust/complex.h +++ b/thrust/complex.h @@ -69,7 +69,7 @@ namespace detail template struct complex_storage; -#if __cplusplus >= 201103L \ +#if THRUST_CPP_DIALECT >= 2011 \ && (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC) \ && (THRUST_GCC_VERSION >= 40800) // C++11 implementation, excluding GCC 4.7, which doesn't have `alignas`. diff --git a/thrust/detail/alignment.h b/thrust/detail/alignment.h index c787b0a133..89c8afcd8c 100644 --- a/thrust/detail/alignment.h +++ b/thrust/detail/alignment.h @@ -25,7 +25,7 @@ #include // For `std::size_t` and `std::max_align_t`. -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 #include // For `std::alignment_of` and `std::aligned_storage`. #endif @@ -43,7 +43,7 @@ namespace detail /// inside of a `__declspec(align(#))` attribute. As a workaround, you can /// assign the result of \p THRUST_ALIGNOF to a variable and pass the variable /// as the argument to `__declspec(align(#))`. -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 #define THRUST_ALIGNOF(x) alignof(x) #else #define THRUST_ALIGNOF(x) __alignof(x) @@ -54,7 +54,7 @@ namespace detail /// expression. /// /// It is an implementation of C++11's \p std::alignment_of. -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template using alignment_of = std::alignment_of; #else @@ -97,7 +97,7 @@ namespace detail template struct aligned_type; -#if __cplusplus >= 201103L \ +#if THRUST_CPP_DIALECT >= 2011 \ && (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC) \ && (THRUST_GCC_VERSION >= 40800) // C++11 implementation, excluding GCC 4.7, which doesn't have `alignas`. @@ -161,7 +161,7 @@ struct aligned_type; /// The behavior is undefined if `Len` is 0 or `Align` is not a power of 2. /// /// It is an implementation of C++11's \p std::aligned_storage. -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template using aligned_storage = std::aligned_storage; #else @@ -184,7 +184,7 @@ struct aligned_type; /// strict (as large) as that of every scalar type. /// /// It is an implementation of C++11's \p std::max_align_t. -#if __cplusplus >= 201103L \ +#if THRUST_CPP_DIALECT >= 2011 \ && (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC) \ && (THRUST_GCC_VERSION >= 40900) // GCC 4.7 and 4.8 don't have `std::max_align_t`. diff --git a/thrust/detail/allocator/allocator_traits.h b/thrust/detail/allocator/allocator_traits.h index 36f56b8c83..768f74dabf 100644 --- a/thrust/detail/allocator/allocator_traits.h +++ b/thrust/detail/allocator/allocator_traits.h @@ -164,7 +164,7 @@ template::value> typedef typename Alloc::template rebind::other type; }; -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template class Alloc, typename T, typename... Args, typename U> struct rebind_alloc, U, true> diff --git a/thrust/detail/allocator_aware_execution_policy.h b/thrust/detail/allocator_aware_execution_policy.h index 3a6eb071bf..28fd54f9b7 100644 --- a/thrust/detail/allocator_aware_execution_policy.h +++ b/thrust/detail/allocator_aware_execution_policy.h @@ -83,7 +83,7 @@ struct allocator_aware_execution_policy return typename execute_with_allocator_type::type(alloc); } -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 // just the rvalue overload // perfect forwarding doesn't help, because a const reference has to be turned // into a value by copying for the purpose of storing it in execute_with_allocator diff --git a/thrust/detail/complex/catrig.h b/thrust/detail/complex/catrig.h index 70adf03ff8..0b60286db5 100644 --- a/thrust/detail/complex/catrig.h +++ b/thrust/detail/complex/catrig.h @@ -48,6 +48,7 @@ #pragma once +#include #include #include #include @@ -588,7 +589,7 @@ inline double real_part_reciprocal(double x, double y) * Re(catanh(z)) = x/|z|^2 + O(x/z^4) * as z -> infinity, uniformly in x */ -#if __cplusplus >= 201103L || !defined _MSC_VER +#if THRUST_CPP_DIALECT >= 2011 || THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC __host__ __device__ inline complex catanh(complex z) { @@ -601,7 +602,12 @@ complex catanh(complex z) y = z.imag(); ax = fabs(x); ay = fabs(y); - + + // MSVC needs to pull this in from the std namespace +#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC + using std::atanh; +#endif + /* This helps handle many cases. */ if (y == 0 && ax <= 1) return (complex(atanh(x), y)); @@ -752,7 +758,7 @@ inline complex asin(const complex& z){ return detail::complex::casin(z); } -#if __cplusplus >= 201103L || !defined _MSC_VER +#if THRUST_CPP_DIALECT >= 2011 || THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC template <> __host__ __device__ inline complex atan(const complex& z){ @@ -773,7 +779,7 @@ inline complex asinh(const complex& z){ return detail::complex::casinh(z); } -#if __cplusplus >= 201103L || !defined _MSC_VER +#if THRUST_CPP_DIALECT >= 2011 || THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC template <> __host__ __device__ inline complex atanh(const complex& z){ diff --git a/thrust/detail/complex/catrigf.h b/thrust/detail/complex/catrigf.h index db04c466a5..aa924717a7 100644 --- a/thrust/detail/complex/catrigf.h +++ b/thrust/detail/complex/catrigf.h @@ -50,6 +50,7 @@ #include #include +#include #include #include @@ -386,13 +387,13 @@ inline float real_part_reciprocal(float x, float y) return (x / (x * x + y * y) * scale); } -#if __cplusplus >= 201103L || !defined _MSC_VER +#if THRUST_CPP_DIALECT >= 2011 || THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC __host__ __device__ inline complex catanhf(complex z) { float x, y, ax, ay, rx, ry; - const volatile float pio2_lo = 6.1232339957367659e-17; /* 0x11a62633145c07.0p-106 */ - const float pio2_hi = 1.5707963267948966e0;/* 0x1921fb54442d18.0p-52 */ + const volatile float pio2_lo = 6.1232339957367659e-17f; /* 0x11a62633145c07.0p-106 */ + const float pio2_hi = 1.5707963267948966e0f;/* 0x1921fb54442d18.0p-52 */ x = z.real(); @@ -421,7 +422,7 @@ complex catanhf(complex z) return (complex(real_part_reciprocal(x, y), copysignf(pio2_hi + pio2_lo, y))); - const float SQRT_3_EPSILON = 5.9801995673e-4; /* 0x9cc471.0p-34 */ + const float SQRT_3_EPSILON = 5.9801995673e-4f; /* 0x9cc471.0p-34 */ if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) { raise_inexact(); return (z); @@ -467,7 +468,7 @@ inline complex asin(const complex& z){ return detail::complex::casinf(z); } -#if __cplusplus >= 201103L || !defined _MSC_VER +#if THRUST_CPP_DIALECT >= 2011 || THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC template <> __host__ __device__ inline complex atan(const complex& z){ @@ -488,7 +489,7 @@ inline complex asinh(const complex& z){ return detail::complex::casinhf(z); } -#if __cplusplus >= 201103L || !defined _MSC_VER +#if THRUST_CPP_DIALECT >= 2011 || THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC template <> __host__ __device__ inline complex atanh(const complex& z){ diff --git a/thrust/detail/config/compiler.h b/thrust/detail/config/compiler.h index c26f038903..644db93d4e 100644 --- a/thrust/detail/config/compiler.h +++ b/thrust/detail/config/compiler.h @@ -37,6 +37,8 @@ // XXX we should move the definition of THRUST_DEPRECATED out of this logic #if defined(_MSC_VER) #define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_MSVC +#define THRUST_MSVC_VERSION _MSC_VER +#define THRUST_MSVC_VERSION_FULL _MSC_FULL_VER #elif defined(__clang__) #define THRUST_HOST_COMPILER THRUST_HOST_COMPILER_CLANG #define THRUST_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__) @@ -181,14 +183,4 @@ THRUST_DISABLE_CLANG_AND_GCC_INITIALIZER_REORDERING_WARNING_END \ /**/ -// TODO we should move the definition of THRUST_DEPRECATED out of this logic -#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC - #define THRUST_DEPRECATED __declspec(deprecated) -#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG - #define THRUST_DEPRECATED __attribute__((deprecated)) -#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC - #define THRUST_DEPRECATED __attribute__((deprecated)) -#else - #define THRUST_DEPRECATED -#endif diff --git a/thrust/detail/config/config.h b/thrust/detail/config/config.h index 41a293a801..800bc4c51a 100644 --- a/thrust/detail/config/config.h +++ b/thrust/detail/config/config.h @@ -26,6 +26,7 @@ #include #include #include +#include // host_system.h & device_system.h must be #included as early as possible // because other config headers depend on it #include diff --git a/thrust/detail/config/cpp_dialect.h b/thrust/detail/config/cpp_dialect.h index 06cc3f2f16..1a0e8b6763 100644 --- a/thrust/detail/config/cpp_dialect.h +++ b/thrust/detail/config/cpp_dialect.h @@ -1,5 +1,5 @@ /* - * Copyright 2018 NVIDIA Corporation + * Copyright 2020 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,19 +14,97 @@ * limitations under the License. */ +/*! \file cpp_dialect.h + * \brief Detect the version of the C++ standard used by the compiler. + */ + #pragma once -#if __cplusplus < 201103L - #define THRUST_CPP03 - #define THRUST_CPP_DIALECT 2003 -#elif __cplusplus < 201402L - #define THRUST_CPP11 - #define THRUST_CPP_DIALECT 2011 -#elif __cplusplus < 201703L - #define THRUST_CPP14 - #define THRUST_CPP_DIALECT 2014 -#else - #define THRUST_CPP17 - #define THRUST_CPP_DIALECT 2017 +#include + +// Deprecation warnings may be silenced by defining the following macros. These +// may be combined. +// - THRUST_IGNORE_DEPRECATED_CPP_DIALECT: +// Ignore all deprecated C++ dialects and outdated compilers. +// - THRUST_IGNORE_DEPRECATED_CPP_11: +// Ignore deprecation warnings when compiling with C++11. C++03 and outdated +// compilers will still issue warnings. +// - THRUST_IGNORE_DEPRECATED_COMPILER +// Ignore deprecation warnings when using deprecated compilers. Compiling +// with C++03 and C++11 will still issue warnings. + +#ifdef THRUST_IGNORE_DEPRECATED_CPP_DIALECT +# define THRUST_IGNORE_DEPRECATED_CPP_11 +# define THRUST_IGNORE_DEPRECATED_COMPILER +#endif + +// Define this to override the built-in detection. +#ifndef THRUST_CPP_DIALECT + +// MSVC does not define __cplusplus correctly. _MSVC_LANG is used instead. +// This macro is only defined in MSVC 2015U3+. +# ifdef _MSVC_LANG // Do not replace with THRUST_HOST_COMPILER test (see above) +// MSVC2015 reports C++14 but lacks extended constexpr support. Treat as C++11. +# if THRUST_MSVC_VERSION < 1910 && _MSVC_LANG > 201103L /* MSVC < 2017 && CPP > 2011 */ +# define THRUST_CPLUSPLUS 201103L /* Fix to 2011 */ +# else +# define THRUST_CPLUSPLUS _MSVC_LANG /* We'll trust this for now. */ +# endif // MSVC 2015 C++14 fix +# else +# define THRUST_CPLUSPLUS __cplusplus +# endif + +// Detect current dialect: +# if THRUST_CPLUSPLUS < 201103L +# define THRUST_CPP_DIALECT 2003 +# elif THRUST_CPLUSPLUS < 201402L +# define THRUST_CPP_DIALECT 2011 +# elif THRUST_CPLUSPLUS < 201703L +# define THRUST_CPP_DIALECT 2014 +# elif THRUST_CPLUSPLUS == 201703L +# define THRUST_CPP_DIALECT 2017 +# elif THRUST_CPLUSPLUS > 201703L // unknown, but is higher than 2017. +# define THRUST_CPP_DIALECT 2020 +# endif + +# undef THRUST_CPLUSPLUS // cleanup + +#endif // !THRUST_CPP_DIALECT + +// Define THRUST_COMPILER_DEPRECATION macro: +#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC +# define THRUST_COMP_DEPR_IMPL(msg) \ + __pragma(message(__FILE__ ":" THRUST_COMP_DEPR_IMPL0(__LINE__) ": warning: " #msg)) +# define THRUST_COMP_DEPR_IMPL0(x) THRUST_COMP_DEPR_IMPL1(x) +# define THRUST_COMP_DEPR_IMPL1(x) #x +#else // clang / gcc: +# define THRUST_COMP_DEPR_IMPL(msg) THRUST_COMP_DEPR_IMPL0(GCC warning #msg) +# define THRUST_COMP_DEPR_IMPL0(expr) _Pragma(#expr) +# define THRUST_COMP_DEPR_IMPL1 /* intentionally blank */ +#endif + +#define THRUST_COMPILER_DEPRECATION(REQ, FIX) \ + THRUST_COMP_DEPR_IMPL(Thrust requires REQ. Please FIX. Define THRUST_IGNORE_DEPRECATED_CPP_DIALECT to suppress this message.) + +// Minimum required compiler checks: +#ifndef THRUST_IGNORE_DEPRECATED_COMPILER +# if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC && THRUST_GCC_VERSION < 50000 + THRUST_COMPILER_DEPRECATION(GCC 5.0, upgrade your compiler); +# endif +# if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG && THRUST_CLANG_VERSION < 60000 + THRUST_COMPILER_DEPRECATION(Clang 6.0, upgrade your compiler); +# endif +# if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC && THRUST_MSVC_VERSION < 1910 + THRUST_COMPILER_DEPRECATION(MSVC 2017, upgrade your compiler); +# endif +#endif + +#if !defined(THRUST_IGNORE_DEPRECATED_CPP_DIALECT) && THRUST_CPP_DIALECT < 2014 && \ + (THRUST_CPP_DIALECT != 2011 || !defined(THRUST_IGNORE_DEPRECATED_CPP_11)) + THRUST_COMPILER_DEPRECATION(C++14, pass -std=c++14 to your compiler); #endif +#undef THRUST_COMPILER_DEPRECATION +#undef THRUST_COMP_DEPR_IMPL +#undef THRUST_COMP_DEPR_IMPL0 +#undef THRUST_COMP_DEPR_IMPL1 diff --git a/thrust/detail/util/blocking.h b/thrust/detail/config/deprecated.h similarity index 52% rename from thrust/detail/util/blocking.h rename to thrust/detail/config/deprecated.h index 747d9b97b7..cd18f3ac92 100644 --- a/thrust/detail/util/blocking.h +++ b/thrust/detail/config/deprecated.h @@ -1,5 +1,5 @@ /* - * Copyright 2008-2013 NVIDIA Corporation + * Copyright 2018-2020 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,24 +14,20 @@ * limitations under the License. */ +/*! \file deprecated.h + * \brief Defines the THRUST_DEPRECATED macro + */ #pragma once -//functions to support blocking - -namespace thrust -{ - -namespace detail -{ - -namespace util -{ - - -} // end namespace util - -} // end namespace detail - -} // end namespace thrust - +#include + +#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC +# define THRUST_DEPRECATED __declspec(deprecated) +#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_CLANG +# define THRUST_DEPRECATED __attribute__((deprecated)) +#elif THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC +# define THRUST_DEPRECATED __attribute__((deprecated)) +#else +# define THRUST_DEPRECATED +#endif diff --git a/thrust/detail/config/exec_check_disable.h b/thrust/detail/config/exec_check_disable.h index ee36b65628..114ca3853a 100644 --- a/thrust/detail/config/exec_check_disable.h +++ b/thrust/detail/config/exec_check_disable.h @@ -28,7 +28,11 @@ #if defined(__CUDACC__) && !defined(__NVCOMPILER_CUDA__) && \ !(defined(__CUDA__) && defined(__clang__)) -#define __thrust_exec_check_disable__ #pragma nv_exec_check_disable +#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC +#define __thrust_exec_check_disable__ __pragma("nv_exec_check_disable") +#else // MSVC +#define __thrust_exec_check_disable__ _Pragma("nv_exec_check_disable") +#endif // MSVC #else diff --git a/thrust/detail/contiguous_storage.h b/thrust/detail/contiguous_storage.h index 378cfb8154..84485e7545 100644 --- a/thrust/detail/contiguous_storage.h +++ b/thrust/detail/contiguous_storage.h @@ -19,6 +19,7 @@ #include #include #include +#include namespace thrust { @@ -167,7 +168,7 @@ template __host__ __device__ void propagate_allocator(const contiguous_storage &other); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 __host__ __device__ void propagate_allocator(contiguous_storage &other); @@ -220,7 +221,7 @@ template __host__ __device__ void propagate_allocator_dispatch(false_type, const contiguous_storage &other); -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 __host__ __device__ void propagate_allocator_dispatch(true_type, contiguous_storage &other); diff --git a/thrust/detail/contiguous_storage.inl b/thrust/detail/contiguous_storage.inl index 27796e9412..8f26cb8106 100644 --- a/thrust/detail/contiguous_storage.inl +++ b/thrust/detail/contiguous_storage.inl @@ -16,6 +16,7 @@ #pragma once +#include #include #include #include @@ -384,7 +385,7 @@ __host__ __device__ propagate_allocator_dispatch(c, other); } // end contiguous_storage::propagate_allocator() -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template __host__ __device__ void contiguous_storage @@ -519,7 +520,7 @@ __host__ __device__ { } // end contiguous_storage::propagate_allocator() -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 __thrust_exec_check_disable__ template __host__ __device__ diff --git a/thrust/detail/distance.inl b/thrust/detail/distance.inl index 5732a9c25e..f12ef204cc 100644 --- a/thrust/detail/distance.inl +++ b/thrust/detail/distance.inl @@ -27,6 +27,7 @@ namespace thrust { +__thrust_exec_check_disable__ template inline __host__ __device__ typename thrust::iterator_traits::difference_type diff --git a/thrust/detail/event_error.h b/thrust/detail/event_error.h index 742439b7e7..8b7854a4f5 100644 --- a/thrust/detail/event_error.h +++ b/thrust/detail/event_error.h @@ -30,7 +30,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ enum class event_errc { @@ -159,7 +160,7 @@ inline bool operator<(event_error const& lhs, event_error const& rhs) noexcept return lhs.code() < rhs.code(); } -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/detail/execute_with_allocator.h b/thrust/detail/execute_with_allocator.h index 0b92d12b31..d18a2a064e 100644 --- a/thrust/detail/execute_with_allocator.h +++ b/thrust/detail/execute_with_allocator.h @@ -78,7 +78,7 @@ return_temporary_buffer( alloc_traits::deallocate(system.get_allocator(), to_ptr, 0); } -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template < typename T, diff --git a/thrust/detail/execute_with_dependencies.h b/thrust/detail/execute_with_dependencies.h index 01fb82364c..2fa44a8b9e 100644 --- a/thrust/detail/execute_with_dependencies.h +++ b/thrust/detail/execute_with_dependencies.h @@ -189,7 +189,7 @@ struct execute_with_allocator_and_dependencies return std::move(dependencies); } - typename std::remove_reference::type& + typename std::add_lvalue_reference::type __host__ get_allocator() { diff --git a/thrust/detail/memory_algorithms.h b/thrust/detail/memory_algorithms.h index 74e863dcc5..de0d53de61 100644 --- a/thrust/detail/memory_algorithms.h +++ b/thrust/detail/memory_algorithms.h @@ -8,6 +8,7 @@ #pragma once +#include #include #include #include @@ -17,7 +18,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ /////////////////////////////////////////////////////////////////////////////// @@ -101,7 +103,7 @@ ForwardIt destroy_n(Allocator const& alloc, ForwardIt first, Size n) return first; } -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template __host__ __device__ void uninitialized_construct( @@ -204,5 +206,5 @@ void uninitialized_construct_n_with_allocator( /////////////////////////////////////////////////////////////////////////////// -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/detail/pointer.h b/thrust/detail/pointer.h index baacac7fa3..e9204978f5 100644 --- a/thrust/detail/pointer.h +++ b/thrust/detail/pointer.h @@ -211,6 +211,12 @@ template __host__ __device__ explicit operator bool() const; #endif + + __host__ __device__ + static derived_type pointer_to(typename thrust::detail::pointer_traits_detail::pointer_to_param::type r) + { + return thrust::detail::pointer_traits::pointer_to(r); + } }; // end pointer // Output stream operator diff --git a/thrust/detail/select_system.h b/thrust/detail/select_system.h index dd07a28d18..b22ceb0e96 100644 --- a/thrust/detail/select_system.h +++ b/thrust/detail/select_system.h @@ -25,7 +25,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace detail { @@ -78,7 +79,7 @@ THRUST_INLINE_CONSTANT select_system_detail::select_system_fn select_system{}; } // detail -THRUST_END_NS +} // end namespace thrust #endif // THRUST_CPP_DIALECT >= 2011 diff --git a/thrust/detail/static_assert.h b/thrust/detail/static_assert.h index 66d7eb70f0..52674dcaf1 100644 --- a/thrust/detail/static_assert.h +++ b/thrust/detail/static_assert.h @@ -29,7 +29,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace detail { @@ -86,6 +87,6 @@ template struct static_assert_test {}; } // namespace detail -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/detail/tuple_algorithms.h b/thrust/detail/tuple_algorithms.h index ea50c8c98a..530de4b3f1 100644 --- a/thrust/detail/tuple_algorithms.h +++ b/thrust/detail/tuple_algorithms.h @@ -26,7 +26,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ template auto tuple_subset(Tuple&& t, index_sequence) @@ -104,7 +105,7 @@ THRUST_DECLTYPE_RETURNS( ) ); -THRUST_END_NS +} // end namespace thrust #endif // THRUST_CPP_DIALECT >= 2011 diff --git a/thrust/detail/type_traits.h b/thrust/detail/type_traits.h index ad02ba6f9d..9bfe60d31c 100644 --- a/thrust/detail/type_traits.h +++ b/thrust/detail/type_traits.h @@ -49,17 +49,14 @@ namespace detail // to the C++14 operator(), but we'd like standard traits to interoperate // with our version when tag dispatching. #if THRUST_CPP_DIALECT >= 2011 - constexpr integral_constant() = default; + integral_constant() = default; - constexpr integral_constant(integral_constant const&) = default; + integral_constant(integral_constant const&) = default; - #if THRUST_CPP_DIALECT >= 2014 - constexpr // In C++11, constexpr makes member functions const. - #endif integral_constant& operator=(integral_constant const&) = default; constexpr __host__ __device__ - integral_constant(std::integral_constant) {} + integral_constant(std::integral_constant) noexcept {} #endif THRUST_CONSTEXPR __host__ __device__ operator value_type() const THRUST_NOEXCEPT { return value; } diff --git a/thrust/detail/type_traits/result_of_adaptable_function.h b/thrust/detail/type_traits/result_of_adaptable_function.h index 5d862affd1..8f91ff0b21 100644 --- a/thrust/detail/type_traits/result_of_adaptable_function.h +++ b/thrust/detail/type_traits/result_of_adaptable_function.h @@ -20,7 +20,7 @@ #include #include -#if __cplusplus >= 201103L || defined(__cpp_lib_result_of_sfinae) +#if THRUST_CPP_DIALECT >= 2011 || defined(__cpp_lib_result_of_sfinae) // necessary for std::result_of #include #endif @@ -31,7 +31,7 @@ namespace detail { // In the C++11 mode, by default, result_of_adaptable function inheritfrom std::result_of -#if __cplusplus >= 201103L || defined(__cpp_lib_result_of_sfinae) +#if THRUST_CPP_DIALECT >= 2011 || defined(__cpp_lib_result_of_sfinae) template struct result_of_adaptable_function : std::result_of {}; #else /* cxx11 */ diff --git a/thrust/detail/vector_base.h b/thrust/detail/vector_base.h index 49cd070700..eecedfc14d 100644 --- a/thrust/detail/vector_base.h +++ b/thrust/detail/vector_base.h @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -106,7 +107,7 @@ template */ vector_base(const vector_base &v, const Alloc &alloc); - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move constructor moves from another vector_base. * \param v The vector_base to move. */ @@ -123,7 +124,7 @@ template */ vector_base &operator=(const vector_base &v); - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move assign operator moves from another vector_base. * \param v The vector_base to move. */ diff --git a/thrust/detail/vector_base.inl b/thrust/detail/vector_base.inl index 9d5511e26e..2e23317708 100644 --- a/thrust/detail/vector_base.inl +++ b/thrust/detail/vector_base.inl @@ -19,6 +19,7 @@ * \brief Inline file for vector_base.h. */ +#include #include #include #include @@ -110,7 +111,7 @@ template range_init(v.begin(), v.end()); } // end vector_base::vector_base() -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template vector_base ::vector_base(vector_base &&v) @@ -139,7 +140,7 @@ template return *this; } // end vector_base::operator=() -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template vector_base & vector_base diff --git a/thrust/device_make_unique.h b/thrust/device_make_unique.h index cb7e7c3b9f..939006f27e 100644 --- a/thrust/device_make_unique.h +++ b/thrust/device_make_unique.h @@ -32,7 +32,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ /////////////////////////////////////////////////////////////////////////////// @@ -53,6 +54,6 @@ auto device_make_unique(Args&&... args) /////////////////////////////////////////////////////////////////////////////// -THRUST_END_NS +} // end namespace thrust #endif // THRUST_CPP_DIALECT >= 2011 diff --git a/thrust/future.h b/thrust/future.h index 90dcc705db..12bebf8c6e 100644 --- a/thrust/future.h +++ b/thrust/future.h @@ -55,7 +55,8 @@ #include __THRUST_DEVICE_SYSTEM_FUTURE_HEADER #undef __THRUST_DEVICE_SYSTEM_FUTURE_HEADER -THRUST_BEGIN_NS +namespace thrust +{ /////////////////////////////////////////////////////////////////////////////// @@ -172,7 +173,7 @@ using thrust::system::__THRUST_DEVICE_SYSTEM_NAMESPACE::when_all; /////////////////////////////////////////////////////////////////////////////// -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/host_vector.h b/thrust/host_vector.h index 047949089b..bd97b69de2 100644 --- a/thrust/host_vector.h +++ b/thrust/host_vector.h @@ -135,7 +135,7 @@ template > host_vector(const host_vector &v, const Alloc &alloc) :Parent(v,alloc) {} - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move constructor moves from another host_vector. * \param v The host_vector to move. */ @@ -159,7 +159,7 @@ template > host_vector &operator=(const host_vector &v) { Parent::operator=(v); return *this; } - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move assign operator moves from another host_vector. * \param v The host_vector to move. */ diff --git a/thrust/iterator/detail/reverse_iterator.inl b/thrust/iterator/detail/reverse_iterator.inl index 5eb9ac5ffb..bb96c497fc 100644 --- a/thrust/iterator/detail/reverse_iterator.inl +++ b/thrust/iterator/detail/reverse_iterator.inl @@ -47,14 +47,14 @@ template reverse_iterator ::reverse_iterator(reverse_iterator const &r // XXX msvc screws this up -#ifndef _MSC_VER +#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC , typename thrust::detail::enable_if< thrust::detail::is_convertible< OtherBidirectionalIterator, BidirectionalIterator >::value >::type * -#endif // _MSC_VER +#endif // MSVC ) :super_t(r.base()) { diff --git a/thrust/iterator/reverse_iterator.h b/thrust/iterator/reverse_iterator.h index 2ba97d0ac3..365bc34d2e 100644 --- a/thrust/iterator/reverse_iterator.h +++ b/thrust/iterator/reverse_iterator.h @@ -180,14 +180,14 @@ template reverse_iterator(reverse_iterator const &r // XXX msvc screws this up // XXX remove these guards when we have static_assert -#ifndef _MSC_VER +#if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC , typename thrust::detail::enable_if< thrust::detail::is_convertible< OtherBidirectionalIterator, BidirectionalIterator >::value >::type * = 0 -#endif // _MSC_VER +#endif // MSVC ); /*! \cond diff --git a/thrust/limits.h b/thrust/limits.h index 10434a3cf5..f83dde9c37 100644 --- a/thrust/limits.h +++ b/thrust/limits.h @@ -9,10 +9,11 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ template struct numeric_limits : std::numeric_limits {}; -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/mr/allocator.h b/thrust/mr/allocator.h index 7645759eaf..4c6c328860 100644 --- a/thrust/mr/allocator.h +++ b/thrust/mr/allocator.h @@ -170,12 +170,12 @@ bool operator!=(const allocator & lhs, const allocator & rhs) THRU return !(lhs == rhs); } -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template using polymorphic_allocator = allocator >; -#else +#else // C++11 template class polymorphic_allocator : public allocator > @@ -190,7 +190,7 @@ class polymorphic_allocator : public allocator= 201703L +#if THRUST_CPP_DIALECT >= 2017 # if __has_include() # define THRUST_MR_STD_MR_HEADER # define THRUST_MR_STD_MR_NS std::pmr diff --git a/thrust/mr/validator.h b/thrust/mr/validator.h index 7f7e12c76a..9376ae870b 100644 --- a/thrust/mr/validator.h +++ b/thrust/mr/validator.h @@ -27,7 +27,7 @@ namespace mr template struct validator { -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 static_assert( std::is_base_of, MR>::value, "a type used as a memory resource must derive from memory_resource" diff --git a/thrust/optional.h b/thrust/optional.h index 94d10d902e..f2d9bb2a7a 100644 --- a/thrust/optional.h +++ b/thrust/optional.h @@ -30,7 +30,7 @@ #include #include -#if (defined(_MSC_VER) && _MSC_VER == 1900) +#if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC && _MSC_VER == 1900) #define THRUST_OPTIONAL_MSVC2015 #endif @@ -68,7 +68,8 @@ !defined(__clang__)) #ifndef THRUST_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX #define THRUST_GCC_LESS_8_TRIVIALLY_COPY_CONSTRUCTIBLE_MUTEX -THRUST_BEGIN_NS +namespace thrust +{ namespace detail { template struct is_trivially_copy_constructible : std::is_trivially_copy_constructible{}; @@ -78,7 +79,7 @@ THRUST_BEGIN_NS : std::is_trivially_copy_constructible{}; #endif } -THRUST_END_NS +} // end namespace thrust #endif #define THRUST_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T) \ @@ -94,12 +95,12 @@ THRUST_END_NS #define THRUST_OPTIONAL_IS_TRIVIALLY_DESTRUCTIBLE(T) std::is_trivially_destructible::value #endif -#if __cplusplus > 201103L +#if THRUST_CPP_DIALECT > 2011 #define THRUST_OPTIONAL_CPP14 #endif // constexpr implies const in C++11, not C++14 -#if (__cplusplus == 201103L || defined(THRUST_OPTIONAL_MSVC2015) || \ +#if (THRUST_CPP_DIALECT == 2011 || defined(THRUST_OPTIONAL_MSVC2015) || \ defined(THRUST_OPTIONAL_GCC49)) /// \exclude #define THRUST_OPTIONAL_CPP11_CONSTEXPR @@ -108,7 +109,8 @@ THRUST_END_NS #define THRUST_OPTIONAL_CPP11_CONSTEXPR constexpr #endif -THRUST_BEGIN_NS +namespace thrust +{ #ifndef THRUST_MONOSTATE_INPLACE_MUTEX #define THRUST_MONOSTATE_INPLACE_MUTEX /// \brief Used to represent an optional with no data; essentially a bool @@ -145,7 +147,7 @@ template struct conjunction : std::conditional, B>::type {}; -#if defined(_LIBCPP_VERSION) && __cplusplus == 201103L +#if defined(_LIBCPP_VERSION) && THRUST_CPP_DIALECT == 2011 #define THRUST_OPTIONAL_LIBCXX_MEM_FN_WORKAROUND #endif @@ -288,7 +290,7 @@ using enable_assign_from_other = detail::enable_if_t< !std::is_assignable &>::value && !std::is_assignable &&>::value>; -#ifdef _MSC_VER +#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC // TODO make a version which works with MSVC template struct is_swappable : std::true_type {}; @@ -1997,7 +1999,7 @@ inline constexpr optional make_optional(std::initializer_list il, return optional(in_place, il, std::forward(args)...); } -#if __cplusplus >= 201703L +#if THRUST_CPP_DIALECT >= 2017 template optional(T)->optional; #endif @@ -2827,7 +2829,7 @@ template class optional { T *m_value; }; -THRUST_END_NS +} // end namespace thrust namespace std { // TODO SFINAE diff --git a/thrust/per_device_resource.h b/thrust/per_device_resource.h index 91d4d9a0d1..3c0158aeea 100644 --- a/thrust/per_device_resource.h +++ b/thrust/per_device_resource.h @@ -28,7 +28,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ /*! Returns a global instance of \p MR for the current device of the provided system. * @@ -98,6 +99,6 @@ class per_device_allocator : public thrust::mr::allocator }; -THRUST_END_NS +} // end namespace thrust #endif // THRUST_CPP_DIALECT >= 2011 diff --git a/thrust/system/cpp/detail/vector.inl b/thrust/system/cpp/detail/vector.inl index 77f8be3bc5..55a1fa4bac 100644 --- a/thrust/system/cpp/detail/vector.inl +++ b/thrust/system/cpp/detail/vector.inl @@ -51,7 +51,7 @@ template : super_t(x) {} -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template vector ::vector(vector &&x) @@ -89,7 +89,7 @@ template return *this; } -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template vector & vector diff --git a/thrust/system/cpp/vector.h b/thrust/system/cpp/vector.h index 1748f3d6fa..9aeb7206be 100644 --- a/thrust/system/cpp/vector.h +++ b/thrust/system/cpp/vector.h @@ -96,7 +96,7 @@ template > */ vector(const vector &x); - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move constructor moves from over another \p cpp::vector. * \param x The other \p cpp::vector to move from. */ @@ -130,7 +130,7 @@ template > */ vector &operator=(const vector &x); - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move assignment operator moves from another \p cpp::vector. * \param x The other \p cpp::vector to move from. * \return *this diff --git a/thrust/system/cuda/detail/adjacent_difference.h b/thrust/system/cuda/detail/adjacent_difference.h index ed8d5a4c98..648ddba3e9 100644 --- a/thrust/system/cuda/detail/adjacent_difference.h +++ b/thrust/system/cuda/detail/adjacent_difference.h @@ -43,7 +43,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ template __host__ __device__ OutputIterator @@ -530,7 +531,7 @@ adjacent_difference(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust // #include diff --git a/thrust/system/cuda/detail/assign_value.h b/thrust/system/cuda/detail/assign_value.h index c21bb77735..f6fd987bf3 100644 --- a/thrust/system/cuda/detail/assign_value.h +++ b/thrust/system/cuda/detail/assign_value.h @@ -24,7 +24,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -97,5 +98,5 @@ inline __host__ __device__ } // end cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/async/copy.h b/thrust/system/cuda/detail/async/copy.h index 8083fccd9e..8d8779eb16 100644 --- a/thrust/system/cuda/detail/async/copy.h +++ b/thrust/system/cuda/detail/async/copy.h @@ -54,7 +54,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace system { namespace cuda { namespace detail { @@ -228,6 +229,10 @@ auto async_copy_n( template < typename FromPolicy, typename ToPolicy , typename ForwardIt, typename OutputIt + // MSVC2015 WAR: doesn't like decltype(...)::value in superclass definition +, typename IsH2DCopy = decltype(is_host_to_device_copy( + std::declval() + , std::declval())) > struct is_buffered_trivially_relocatable_host_to_device_copy : thrust::integral_constant< @@ -238,12 +243,7 @@ struct is_buffered_trivially_relocatable_host_to_device_copy typename iterator_traits::value_type , typename iterator_traits::value_type >::value - && decltype( - is_host_to_device_copy( - std::declval() - , std::declval() - ) - )::value + && IsH2DCopy::value > {}; @@ -333,6 +333,10 @@ auto async_copy_n( template < typename FromPolicy, typename ToPolicy , typename ForwardIt, typename OutputIt + // MSVC2015 WAR: doesn't like decltype(...)::value in superclass definition +, typename IsD2HCopy = decltype(is_device_to_host_copy( + std::declval() + , std::declval())) > struct is_buffered_trivially_relocatable_device_to_host_copy : thrust::integral_constant< @@ -343,12 +347,7 @@ struct is_buffered_trivially_relocatable_device_to_host_copy typename iterator_traits::value_type , typename iterator_traits::value_type >::value - && decltype( - is_device_to_host_copy( - std::declval() - , std::declval() - ) - )::value + && IsD2HCopy::value > {}; @@ -541,7 +540,7 @@ THRUST_DECLTYPE_RETURNS( } // cuda_cub -THRUST_END_NS +} // end namespace thrust #endif // THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC diff --git a/thrust/system/cuda/detail/async/customization.h b/thrust/system/cuda/detail/async/customization.h index 651eb287f5..4cabe372f9 100644 --- a/thrust/system/cuda/detail/async/customization.h +++ b/thrust/system/cuda/detail/async/customization.h @@ -49,7 +49,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace system { namespace cuda { namespace detail { @@ -120,7 +121,7 @@ THRUST_DECLTYPE_RETURNS( }}} // namespace system::cuda::detail -THRUST_END_NS +} // end namespace thrust #endif // THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC diff --git a/thrust/system/cuda/detail/async/for_each.h b/thrust/system/cuda/detail/async/for_each.h index a6faf178fe..37d998fe2c 100644 --- a/thrust/system/cuda/detail/async/for_each.h +++ b/thrust/system/cuda/detail/async/for_each.h @@ -48,7 +48,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace system { namespace cuda { namespace detail { @@ -153,7 +154,7 @@ THRUST_DECLTYPE_RETURNS( } // cuda_cub -THRUST_END_NS +} // end namespace thrust #endif // THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC diff --git a/thrust/system/cuda/detail/async/reduce.h b/thrust/system/cuda/detail/async/reduce.h index 78edb60dbe..8d538250e8 100644 --- a/thrust/system/cuda/detail/async/reduce.h +++ b/thrust/system/cuda/detail/async/reduce.h @@ -50,7 +50,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace system { namespace cuda { namespace detail { @@ -74,7 +75,7 @@ auto async_reduce_n( using pointer = typename thrust::detail::allocator_traits:: - rebind_traits::pointer; + template rebind_traits::pointer; unique_eager_future_promise_pair fp; @@ -346,7 +347,7 @@ THRUST_DECLTYPE_RETURNS( } // cuda_cub -THRUST_END_NS +} // end namespace thrust #endif // THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC diff --git a/thrust/system/cuda/detail/async/sort.h b/thrust/system/cuda/detail/async/sort.h index fe1bb35e50..f258a9c2a2 100644 --- a/thrust/system/cuda/detail/async/sort.h +++ b/thrust/system/cuda/detail/async/sort.h @@ -54,7 +54,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace system { namespace cuda { namespace detail { @@ -518,7 +519,7 @@ THRUST_DECLTYPE_RETURNS( } // cuda_cub -THRUST_END_NS +} // end namespace thrust #endif // THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC diff --git a/thrust/system/cuda/detail/async/transform.h b/thrust/system/cuda/detail/async/transform.h index 55cc1997be..44934f4a6e 100644 --- a/thrust/system/cuda/detail/async/transform.h +++ b/thrust/system/cuda/detail/async/transform.h @@ -48,7 +48,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace system { namespace cuda { namespace detail { @@ -157,7 +158,7 @@ THRUST_DECLTYPE_RETURNS( } // cuda_cub -THRUST_END_NS +} // end namespace thrust #endif // THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC diff --git a/thrust/system/cuda/detail/binary_search.h b/thrust/system/cuda/detail/binary_search.h index bcd156ffb4..1859824b83 100644 --- a/thrust/system/cuda/detail/binary_search.h +++ b/thrust/system/cuda/detail/binary_search.h @@ -44,7 +44,8 @@ # define BS_SIMPLE #endif -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __binary_search { @@ -774,7 +775,7 @@ lower_bound(execution_policy& policy, } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif #endif diff --git a/thrust/system/cuda/detail/copy.h b/thrust/system/cuda/detail/copy.h index 15dd00b41e..ef51e4a5bc 100644 --- a/thrust/system/cuda/detail/copy.h +++ b/thrust/system/cuda/detail/copy.h @@ -31,7 +31,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ template __host__ __device__ OutputIt @@ -91,7 +92,7 @@ copy_n(cross_system systems, OutputIterator result); } // namespace cuda_ -THRUST_END_NS +} // end namespace thrust @@ -99,7 +100,8 @@ THRUST_END_NS #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -190,7 +192,7 @@ copy_n(cross_system systems, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #include #include diff --git a/thrust/system/cuda/detail/copy_if.h b/thrust/system/cuda/detail/copy_if.h index 7cb8a1e256..04f6581728 100644 --- a/thrust/system/cuda/detail/copy_if.h +++ b/thrust/system/cuda/detail/copy_if.h @@ -41,7 +41,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ // XXX declare generic copy_if interface // to avoid circulular dependency from thrust/copy.h template @@ -850,7 +851,7 @@ copy_if(execution_policy &policy, } // func copy_if } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #include #endif diff --git a/thrust/system/cuda/detail/core/agent_launcher.h b/thrust/system/cuda/detail/core/agent_launcher.h index b20bd0c001..7788481c7b 100644 --- a/thrust/system/cuda/detail/core/agent_launcher.h +++ b/thrust/system/cuda/detail/core/agent_launcher.h @@ -42,7 +42,8 @@ template class ID_impl; template class Foo { ID_impl t;}; #endif -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace core { @@ -1179,5 +1180,5 @@ namespace core { } // namespace core } -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/core/alignment.h b/thrust/system/cuda/detail/core/alignment.h index bf3873efe1..1dc21ebcec 100644 --- a/thrust/system/cuda/detail/core/alignment.h +++ b/thrust/system/cuda/detail/core/alignment.h @@ -20,7 +20,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace alignment_of_detail { @@ -245,4 +246,4 @@ struct aligned_storage } // end cuda_ -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/core/triple_chevron_launch.h b/thrust/system/cuda/detail/core/triple_chevron_launch.h index 0db1c70362..deeffac9da 100644 --- a/thrust/system/cuda/detail/core/triple_chevron_launch.h +++ b/thrust/system/cuda/detail/core/triple_chevron_launch.h @@ -32,7 +32,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace launcher { @@ -972,4 +973,4 @@ namespace launcher { } // namespace launcher } // namespace cuda_ -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/core/util.h b/thrust/system/cuda/detail/core/util.h index f5561d8b70..a2c87772ed 100644 --- a/thrust/system/cuda/detail/core/util.h +++ b/thrust/system/cuda/detail/core/util.h @@ -36,7 +36,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace core { @@ -766,4 +767,4 @@ using core::sm35; using core::sm30; } // namespace cuda_ -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/count.h b/thrust/system/cuda/detail/count.h index 2ed68d7e7d..0d8f0c02dd 100644 --- a/thrust/system/cuda/detail/count.h +++ b/thrust/system/cuda/detail/count.h @@ -34,7 +34,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template &policy, } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/cross_system.h b/thrust/system/cuda/detail/cross_system.h index 56a20daa29..f89f3dba8d 100644 --- a/thrust/system/cuda/detail/cross_system.h +++ b/thrust/system/cuda/detail/cross_system.h @@ -30,7 +30,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template @@ -114,7 +115,12 @@ namespace cuda_cub { ) ) - template + template (), + std::declval()))> THRUST_CONSTEXPR __host__ __device__ auto is_device_to_host_copy( ExecutionPolicy0 const& exec0 @@ -122,28 +128,32 @@ namespace cuda_cub { ) noexcept -> thrust::detail::integral_constant< - bool - , cudaMemcpyDeviceToHost - == decltype(direction_of_copy(exec0, exec1))::value + bool, cudaMemcpyDeviceToHost == Direction::value > { return {}; } - template + template ()))> THRUST_CONSTEXPR __host__ __device__ auto is_device_to_host_copy(ExecutionPolicy const& exec) noexcept -> thrust::detail::integral_constant< - bool - , cudaMemcpyDeviceToHost - == decltype(direction_of_copy(exec))::value + bool, cudaMemcpyDeviceToHost == Direction::value > { return {}; } - template + template (), + std::declval()))> THRUST_CONSTEXPR __host__ __device__ auto is_host_to_device_copy( ExecutionPolicy0 const& exec0 @@ -151,28 +161,32 @@ namespace cuda_cub { ) noexcept -> thrust::detail::integral_constant< - bool - , cudaMemcpyHostToDevice - == decltype(direction_of_copy(exec0, exec1))::value + bool, cudaMemcpyHostToDevice == Direction::value > { return {}; } - template + template ()))> THRUST_CONSTEXPR __host__ __device__ auto is_host_to_device_copy(ExecutionPolicy const& exec) noexcept -> thrust::detail::integral_constant< - bool - , cudaMemcpyHostToDevice - == decltype(direction_of_copy(exec))::value + bool, cudaMemcpyHostToDevice == Direction::value > { return {}; } - template + template (), + std::declval()))> THRUST_CONSTEXPR __host__ __device__ auto is_device_to_device_copy( ExecutionPolicy0 const& exec0 @@ -180,22 +194,21 @@ namespace cuda_cub { ) noexcept -> thrust::detail::integral_constant< - bool - , cudaMemcpyDeviceToDevice - == decltype(direction_of_copy(exec0, exec1))::value + bool, cudaMemcpyDeviceToDevice == Direction::value > { return {}; } - template + template ()))> THRUST_CONSTEXPR __host__ __device__ auto is_device_to_device_copy(ExecutionPolicy const& exec) noexcept -> thrust::detail::integral_constant< - bool - , cudaMemcpyDeviceToDevice - == decltype(direction_of_copy(exec))::value + bool, cudaMemcpyDeviceToDevice == Direction::value > { return {}; @@ -327,5 +340,5 @@ namespace cuda_cub { } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/dispatch.h b/thrust/system/cuda/detail/dispatch.h index f391f91311..45b0342179 100644 --- a/thrust/system/cuda/detail/dispatch.h +++ b/thrust/system/cuda/detail/dispatch.h @@ -17,6 +17,7 @@ #pragma once #include +#include /** * Dispatch between 32-bit and 64-bit index based versions of the same algorithm @@ -25,7 +26,7 @@ * interfaces, that always deduce the size type from the arguments. */ #define THRUST_INDEX_TYPE_DISPATCH(status, call, count, arguments) \ - if (count <= std::numeric_limits::max()) { \ + if (count <= thrust::detail::integer_traits::const_max) { \ thrust::detail::int32_t THRUST_PP_CAT2(count, _fixed) = count; \ status = call arguments; \ } \ @@ -44,7 +45,7 @@ * necessary for set algorithms. */ #define THRUST_DOUBLE_INDEX_TYPE_DISPATCH(status, call, count1, count2, arguments) \ - if (count1 + count2 <= std::numeric_limits::max()) { \ + if (count1 + count2 <= thrust::detail::integer_traits::const_max) { \ thrust::detail::int32_t THRUST_PP_CAT2(count1, _fixed) = count1; \ thrust::detail::int32_t THRUST_PP_CAT2(count2, _fixed) = count2; \ status = call arguments; \ @@ -66,7 +67,7 @@ * See reduce_n_impl to see an example of how this is meant to be used. */ #define THRUST_INDEX_TYPE_DISPATCH2(status, call_32, call_64, count, arguments) \ - if (count <= std::numeric_limits::max()) { \ + if (count <= thrust::detail::integer_traits::const_max) { \ thrust::detail::int32_t THRUST_PP_CAT2(count, _fixed) = count; \ status = call_32 arguments; \ } \ diff --git a/thrust/system/cuda/detail/equal.h b/thrust/system/cuda/detail/equal.h index 7a995cffd2..dd5e7d6863 100644 --- a/thrust/system/cuda/detail/equal.h +++ b/thrust/system/cuda/detail/equal.h @@ -32,7 +32,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template & policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/execution_policy.h b/thrust/system/cuda/detail/execution_policy.h index 0b3af62e3b..ee49a60cb4 100644 --- a/thrust/system/cuda/detail/execution_policy.h +++ b/thrust/system/cuda/detail/execution_policy.h @@ -38,7 +38,8 @@ #include #endif -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -94,5 +95,5 @@ using thrust::cuda_cub::execution_policy; } // namespace cuda -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/extrema.h b/thrust/system/cuda/detail/extrema.h index faef53999b..40903cd9a9 100644 --- a/thrust/system/cuda/detail/extrema.h +++ b/thrust/system/cuda/detail/extrema.h @@ -37,7 +37,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __extrema { @@ -563,5 +564,5 @@ minmax_element(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/fill.h b/thrust/system/cuda/detail/fill.h index b5796f399b..078e1b3781 100644 --- a/thrust/system/cuda/detail/fill.h +++ b/thrust/system/cuda/detail/fill.h @@ -31,7 +31,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __fill { @@ -89,5 +90,5 @@ fill(execution_policy& policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/find.h b/thrust/system/cuda/detail/find.h index 0371c1cf83..298be0d1a6 100644 --- a/thrust/system/cuda/detail/find.h +++ b/thrust/system/cuda/detail/find.h @@ -34,7 +34,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { // XXX forward declare to circumvent circular depedency @@ -66,12 +67,13 @@ find(execution_policy &policy, T const& value); }; // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __find_if { @@ -211,5 +213,5 @@ find(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/for_each.h b/thrust/system/cuda/detail/for_each.h index 7a73242baf..542dcf754e 100644 --- a/thrust/system/cuda/detail/for_each.h +++ b/thrust/system/cuda/detail/for_each.h @@ -36,7 +36,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -104,5 +105,5 @@ namespace cuda_cub { } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/future.inl b/thrust/system/cuda/detail/future.inl index f64da12a93..8715559d84 100644 --- a/thrust/system/cuda/detail/future.inl +++ b/thrust/system/cuda/detail/future.inl @@ -32,7 +32,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ // Forward declaration. struct new_stream_t; @@ -1362,7 +1363,7 @@ THRUST_DECLTYPE_RETURNS(std::move(dependency)) }} // namespace system::cuda -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/gather.h b/thrust/system/cuda/detail/gather.h index e153a857a9..31ca3fd561 100644 --- a/thrust/system/cuda/detail/gather.h +++ b/thrust/system/cuda/detail/gather.h @@ -31,7 +31,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template & policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/generate.h b/thrust/system/cuda/detail/generate.h index e1058c8736..df77901e21 100644 --- a/thrust/system/cuda/detail/generate.h +++ b/thrust/system/cuda/detail/generate.h @@ -34,7 +34,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { // for_each functor @@ -85,5 +86,5 @@ generate(execution_policy &policy, } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/get_value.h b/thrust/system/cuda/detail/get_value.h index a690dcb1f8..9fbb0b548c 100644 --- a/thrust/system/cuda/detail/get_value.h +++ b/thrust/system/cuda/detail/get_value.h @@ -23,7 +23,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -92,6 +93,6 @@ inline __host__ __device__ } // end cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/inner_product.h b/thrust/system/cuda/detail/inner_product.h index 4e1cd5a4ce..bd6aec606c 100644 --- a/thrust/system/cuda/detail/inner_product.h +++ b/thrust/system/cuda/detail/inner_product.h @@ -33,7 +33,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -89,5 +90,5 @@ inner_product(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/internal/copy_cross_system.h b/thrust/system/cuda/detail/internal/copy_cross_system.h index fcdd51f51a..ab3b4e5bb7 100644 --- a/thrust/system/cuda/detail/internal/copy_cross_system.h +++ b/thrust/system/cuda/detail/internal/copy_cross_system.h @@ -40,7 +40,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __copy { @@ -238,4 +239,4 @@ namespace __copy { } // namespace __copy } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/internal/copy_device_to_device.h b/thrust/system/cuda/detail/internal/copy_device_to_device.h index 669211d1e5..7a6631d903 100644 --- a/thrust/system/cuda/detail/internal/copy_device_to_device.h +++ b/thrust/system/cuda/detail/internal/copy_device_to_device.h @@ -34,7 +34,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __copy { @@ -59,5 +60,5 @@ namespace __copy { } // namespace __copy } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/iter_swap.h b/thrust/system/cuda/detail/iter_swap.h index ac224c0423..353bb18513 100644 --- a/thrust/system/cuda/detail/iter_swap.h +++ b/thrust/system/cuda/detail/iter_swap.h @@ -24,7 +24,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -61,5 +62,5 @@ void iter_swap(thrust::cuda::execution_policy &, Pointer1 a, Poin } // end cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/make_unsigned_special.h b/thrust/system/cuda/detail/make_unsigned_special.h index 80fd2a2ea4..683647cbed 100644 --- a/thrust/system/cuda/detail/make_unsigned_special.h +++ b/thrust/system/cuda/detail/make_unsigned_special.h @@ -16,7 +16,8 @@ #pragma once -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace detail { @@ -37,5 +38,5 @@ namespace detail { } } -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/malloc_and_free.h b/thrust/system/cuda/detail/malloc_and_free.h index ed6cb87b29..5ca231d0b8 100644 --- a/thrust/system/cuda/detail/malloc_and_free.h +++ b/thrust/system/cuda/detail/malloc_and_free.h @@ -29,7 +29,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { #ifdef THRUST_CACHING_DEVICE_MALLOC @@ -99,4 +100,4 @@ void free(execution_policy &, Pointer ptr) } // end free() } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/merge.h b/thrust/system/cuda/detail/merge.h index 0e080a21e0..5a223b6060 100644 --- a/thrust/system/cuda/detail/merge.h +++ b/thrust/system/cuda/detail/merge.h @@ -43,7 +43,8 @@ j * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __merge { @@ -1013,5 +1014,5 @@ merge_by_key(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/mismatch.h b/thrust/system/cuda/detail/mismatch.h index 5854be3acd..98c462e844 100644 --- a/thrust/system/cuda/detail/mismatch.h +++ b/thrust/system/cuda/detail/mismatch.h @@ -33,7 +33,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template & policy, InputIt1 last1, InputIt2 first2); } // namespace cuda_ -THRUST_END_NS +} // end namespace thrust #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template & policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/par.h b/thrust/system/cuda/detail/par.h index ace0b39571..1e3be070fb 100644 --- a/thrust/system/cuda/detail/par.h +++ b/thrust/system/cuda/detail/par.h @@ -38,7 +38,8 @@ #endif -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template @@ -145,5 +146,5 @@ namespace cuda { using thrust::cuda_cub::par; } // namespace cuda -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/par_to_seq.h b/thrust/system/cuda/detail/par_to_seq.h index f1610b288c..22c4e58386 100644 --- a/thrust/system/cuda/detail/par_to_seq.h +++ b/thrust/system/cuda/detail/par_to_seq.h @@ -29,7 +29,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template @@ -87,4 +88,4 @@ cvt_to_seq(Policy& policy) #endif } // namespace cuda_ -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/parallel_for.h b/thrust/system/cuda/detail/parallel_for.h index 5e2d027fe5..17fa7e7a86 100644 --- a/thrust/system/cuda/detail/parallel_for.h +++ b/thrust/system/cuda/detail/parallel_for.h @@ -36,7 +36,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -173,5 +174,5 @@ parallel_for(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/partition.h b/thrust/system/cuda/detail/partition.h index 9be3aa4afd..c69d02409f 100644 --- a/thrust/system/cuda/detail/partition.h +++ b/thrust/system/cuda/detail/partition.h @@ -43,7 +43,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __partition { @@ -1141,5 +1142,5 @@ is_partitioned(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/per_device_resource.h b/thrust/system/cuda/detail/per_device_resource.h index 528ac221de..68f7194af3 100644 --- a/thrust/system/cuda/detail/per_device_resource.h +++ b/thrust/system/cuda/detail/per_device_resource.h @@ -43,7 +43,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -64,7 +65,7 @@ MR * get_per_device_resource(execution_policy&) } -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/reduce.h b/thrust/system/cuda/detail/reduce.h index 72b1d9d7bf..9fece97186 100644 --- a/thrust/system/cuda/detail/reduce.h +++ b/thrust/system/cuda/detail/reduce.h @@ -46,7 +46,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ // forward declare generic reduce // to circumvent circular dependency @@ -1067,7 +1068,7 @@ reduce(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #include #include diff --git a/thrust/system/cuda/detail/reduce_by_key.h b/thrust/system/cuda/detail/reduce_by_key.h index 2169881fff..673a64b827 100644 --- a/thrust/system/cuda/detail/reduce_by_key.h +++ b/thrust/system/cuda/detail/reduce_by_key.h @@ -47,7 +47,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ template &policy, } // namespace cuda_ -THRUST_END_NS +} // end namespace thrust #include #include diff --git a/thrust/system/cuda/detail/remove.h b/thrust/system/cuda/detail/remove.h index 2e252c61db..c590a1adf2 100644 --- a/thrust/system/cuda/detail/remove.h +++ b/thrust/system/cuda/detail/remove.h @@ -30,7 +30,8 @@ #if THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { // in-place @@ -128,5 +129,5 @@ remove_copy(execution_policy &policy, } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/replace.h b/thrust/system/cuda/detail/replace.h index 27878337c7..d2ccb7b249 100644 --- a/thrust/system/cuda/detail/replace.h +++ b/thrust/system/cuda/detail/replace.h @@ -31,7 +31,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __replace @@ -206,5 +207,5 @@ replace_copy(execution_policy &policy, } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/reverse.h b/thrust/system/cuda/detail/reverse.h index 4c2ea42ace..955825217d 100644 --- a/thrust/system/cuda/detail/reverse.h +++ b/thrust/system/cuda/detail/reverse.h @@ -30,7 +30,8 @@ #if THRUST_DEVICE_COMPILER == THRUST_DEVICE_COMPILER_NVCC #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template @@ -47,7 +48,7 @@ reverse(execution_policy &policy, ItemsIt last); } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #include #include @@ -55,7 +56,8 @@ THRUST_END_NS #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/scan.h b/thrust/system/cuda/detail/scan.h index 654a1b624f..4c3cfefec7 100644 --- a/thrust/system/cuda/detail/scan.h +++ b/thrust/system/cuda/detail/scan.h @@ -46,7 +46,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ template &exec, OutputIterator result, T init, AssociativeOperator binary_op); -THRUST_END_NS +} // end namespace thrust -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __scan { @@ -919,7 +921,7 @@ exclusive_scan(execution_policy &policy, }; } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #include diff --git a/thrust/system/cuda/detail/scan_by_key.h b/thrust/system/cuda/detail/scan_by_key.h index fd1784db8b..1744c9e8db 100644 --- a/thrust/system/cuda/detail/scan_by_key.h +++ b/thrust/system/cuda/detail/scan_by_key.h @@ -38,7 +38,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __scan_by_key { @@ -996,7 +997,7 @@ exclusive_scan_by_key(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #include diff --git a/thrust/system/cuda/detail/scatter.h b/thrust/system/cuda/detail/scatter.h index e3ba3d87d4..3ba0a4b743 100644 --- a/thrust/system/cuda/detail/scatter.h +++ b/thrust/system/cuda/detail/scatter.h @@ -31,7 +31,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template & policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/set_operations.h b/thrust/system/cuda/detail/set_operations.h index 654553a21f..38ba1011d5 100644 --- a/thrust/system/cuda/detail/set_operations.h +++ b/thrust/system/cuda/detail/set_operations.h @@ -42,7 +42,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -1993,5 +1994,5 @@ set_union_by_key(execution_policy &policy, } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/sort.h b/thrust/system/cuda/detail/sort.h index 850b7739a6..b9363b41b9 100644 --- a/thrust/system/cuda/detail/sort.h +++ b/thrust/system/cuda/detail/sort.h @@ -46,7 +46,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __merge_sort { @@ -1743,5 +1744,5 @@ stable_sort_by_key( } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/swap_ranges.h b/thrust/system/cuda/detail/swap_ranges.h index c8d56467b3..ba3b47d9b9 100644 --- a/thrust/system/cuda/detail/swap_ranges.h +++ b/thrust/system/cuda/detail/swap_ranges.h @@ -35,7 +35,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -102,5 +103,5 @@ swap_ranges(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/tabulate.h b/thrust/system/cuda/detail/tabulate.h index 2e5316f4c8..70b2720d9a 100644 --- a/thrust/system/cuda/detail/tabulate.h +++ b/thrust/system/cuda/detail/tabulate.h @@ -34,7 +34,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { namespace __tabulate { @@ -83,5 +84,5 @@ tabulate(execution_policy& policy, } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/transform.h b/thrust/system/cuda/detail/transform.h index 85e1cf69b6..053fe9095a 100644 --- a/thrust/system/cuda/detail/transform.h +++ b/thrust/system/cuda/detail/transform.h @@ -35,7 +35,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -421,5 +422,5 @@ transform(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/transform_reduce.h b/thrust/system/cuda/detail/transform_reduce.h index 8cfe2ac71a..e9a193f242 100644 --- a/thrust/system/cuda/detail/transform_reduce.h +++ b/thrust/system/cuda/detail/transform_reduce.h @@ -32,7 +32,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { template &policy, } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/transform_scan.h b/thrust/system/cuda/detail/transform_scan.h index 1ebfea5066..5001521906 100644 --- a/thrust/system/cuda/detail/transform_scan.h +++ b/thrust/system/cuda/detail/transform_scan.h @@ -32,7 +32,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -138,5 +139,5 @@ transform_exclusive_scan(execution_policy &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/uninitialized_copy.h b/thrust/system/cuda/detail/uninitialized_copy.h index 71a72c0e9c..8d916e33ba 100644 --- a/thrust/system/cuda/detail/uninitialized_copy.h +++ b/thrust/system/cuda/detail/uninitialized_copy.h @@ -34,7 +34,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -111,5 +112,5 @@ uninitialized_copy(execution_policy& policy, } // namespace cuda_ -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/uninitialized_fill.h b/thrust/system/cuda/detail/uninitialized_fill.h index ad990333f3..a8f5fa8097 100644 --- a/thrust/system/cuda/detail/uninitialized_fill.h +++ b/thrust/system/cuda/detail/uninitialized_fill.h @@ -34,7 +34,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -109,5 +110,5 @@ uninitialized_fill(execution_policy& policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #endif diff --git a/thrust/system/cuda/detail/unique.h b/thrust/system/cuda/detail/unique.h index d3ac04364c..c2aff4c648 100644 --- a/thrust/system/cuda/detail/unique.h +++ b/thrust/system/cuda/detail/unique.h @@ -42,7 +42,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ template &policy, } } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust // #include diff --git a/thrust/system/cuda/detail/unique_by_key.h b/thrust/system/cuda/detail/unique_by_key.h index 880e5d9a9a..e208321315 100644 --- a/thrust/system/cuda/detail/unique_by_key.h +++ b/thrust/system/cuda/detail/unique_by_key.h @@ -44,7 +44,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ template &policy, } // namespace cuda_cub -THRUST_END_NS +} // end namespace thrust #include #include diff --git a/thrust/system/cuda/detail/util.h b/thrust/system/cuda/detail/util.h index 7e2ecbf2cb..38136e599a 100644 --- a/thrust/system/cuda/detail/util.h +++ b/thrust/system/cuda/detail/util.h @@ -34,7 +34,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { @@ -893,4 +894,4 @@ struct counting_iterator_t } // cuda_ -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/detail/vector.inl b/thrust/system/cuda/detail/vector.inl index 38bb58e4a2..dfd4c89b5c 100644 --- a/thrust/system/cuda/detail/vector.inl +++ b/thrust/system/cuda/detail/vector.inl @@ -48,7 +48,7 @@ template : super_t(x) {} -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template vector ::vector(vector &&x) @@ -86,7 +86,7 @@ template return *this; } -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template vector & vector diff --git a/thrust/system/cuda/future.h b/thrust/system/cuda/future.h index 4709f16a2b..fc2986f8b2 100644 --- a/thrust/system/cuda/future.h +++ b/thrust/system/cuda/future.h @@ -14,7 +14,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace system { namespace cuda { @@ -66,7 +67,7 @@ unique_eager_future_type( thrust::cuda::execution_policy const& ) noexcept; -THRUST_END_NS +} // end namespace thrust #include diff --git a/thrust/system/cuda/memory.h b/thrust/system/cuda/memory.h index f1510549d4..cd27e4da67 100644 --- a/thrust/system/cuda/memory.h +++ b/thrust/system/cuda/memory.h @@ -27,7 +27,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace cuda_cub { /*! Allocates an area of memory available to Thrust's cuda system. @@ -140,7 +141,7 @@ using thrust::cuda_cub::free; using thrust::cuda_cub::allocator; } // end cuda -THRUST_END_NS +} // end namespace thrust #include diff --git a/thrust/system/cuda/memory_resource.h b/thrust/system/cuda/memory_resource.h index 2298981f74..9110e0af45 100644 --- a/thrust/system/cuda/memory_resource.h +++ b/thrust/system/cuda/memory_resource.h @@ -30,7 +30,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ namespace system { @@ -106,5 +107,5 @@ typedef detail::pinned_memory_resource universal_host_pinned_memory_resource; } // end cuda } // end system -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/system/cuda/vector.h b/thrust/system/cuda/vector.h index bc2e8d65af..707f9ff7f1 100644 --- a/thrust/system/cuda/vector.h +++ b/thrust/system/cuda/vector.h @@ -93,7 +93,7 @@ template > */ vector(const vector &x); - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move constructor moves from over another \p cuda::vector. * \param x The other \p cuda::vector to move from. */ @@ -125,7 +125,7 @@ template > */ vector &operator=(const vector &x); - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move assignment operator moves from another \p cuda::vector. * \param x The other \p cuda::vector to move from. * \return *this diff --git a/thrust/system/detail/generic/distance.inl b/thrust/system/detail/generic/distance.inl index 5cc697200d..930d0844cb 100644 --- a/thrust/system/detail/generic/distance.inl +++ b/thrust/system/detail/generic/distance.inl @@ -60,7 +60,7 @@ inline __host__ __device__ } // end detail - +__thrust_exec_check_disable__ template inline __host__ __device__ typename thrust::iterator_traits::difference_type diff --git a/thrust/system/omp/detail/vector.inl b/thrust/system/omp/detail/vector.inl index 2dac743cbc..3e08615f8a 100644 --- a/thrust/system/omp/detail/vector.inl +++ b/thrust/system/omp/detail/vector.inl @@ -51,7 +51,7 @@ template : super_t(x) {} -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template vector ::vector(vector &&x) @@ -89,7 +89,7 @@ template return *this; } -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template vector & vector diff --git a/thrust/system/omp/vector.h b/thrust/system/omp/vector.h index 1fe7845f37..223ce49357 100644 --- a/thrust/system/omp/vector.h +++ b/thrust/system/omp/vector.h @@ -96,7 +96,7 @@ template > */ vector(const vector &x); - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move constructor moves another \p omp::vector. * \param x The other \p omp::vector to move from. */ @@ -130,7 +130,7 @@ template > */ vector &operator=(const vector &x); - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move assignment operator moves another \p omp::vector. * \param x The other \p omp::vector to move. * \return *this diff --git a/thrust/system/tbb/detail/vector.inl b/thrust/system/tbb/detail/vector.inl index fe9d72ab0f..5d9cb1c09d 100644 --- a/thrust/system/tbb/detail/vector.inl +++ b/thrust/system/tbb/detail/vector.inl @@ -51,7 +51,7 @@ template : super_t(x) {} -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template vector ::vector(vector &&x) @@ -89,7 +89,7 @@ template return *this; } -#if __cplusplus >= 201103L +#if THRUST_CPP_DIALECT >= 2011 template vector & vector diff --git a/thrust/system/tbb/vector.h b/thrust/system/tbb/vector.h index 1a557ed710..9e12cdc092 100644 --- a/thrust/system/tbb/vector.h +++ b/thrust/system/tbb/vector.h @@ -91,7 +91,7 @@ template > */ vector(const vector &x); - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move constructor use the move semantic over another \p tbb::vector. * \param x The other \p tbb::vector to move from. */ @@ -125,7 +125,7 @@ template > */ vector &operator=(const vector &x); - #if __cplusplus >= 201103L + #if THRUST_CPP_DIALECT >= 2011 /*! Move assignment operator use move semantic over another \p tbb::vector. * \param x The other \p tbb::vector to move from. * \return *this diff --git a/thrust/type_traits/integer_sequence.h b/thrust/type_traits/integer_sequence.h index 4d04653d1c..e28e4f95c0 100644 --- a/thrust/type_traits/integer_sequence.h +++ b/thrust/type_traits/integer_sequence.h @@ -23,7 +23,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ #if THRUST_CPP_DIALECT >= 2014 @@ -255,7 +256,7 @@ struct integer_sequence_push_back_impl > } // namespace detail -THRUST_END_NS +} // end namespace thrust #endif // THRUST_CPP_DIALECT >= 2011 diff --git a/thrust/type_traits/is_contiguous_iterator.h b/thrust/type_traits/is_contiguous_iterator.h index 9e704dc31d..3e075bd28b 100644 --- a/thrust/type_traits/is_contiguous_iterator.h +++ b/thrust/type_traits/is_contiguous_iterator.h @@ -28,7 +28,7 @@ #include -#if defined(_MSC_VER) && _MSC_VER < 1916 // MSVC 2017 version 15.9 +#if THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_MSVC && _MSC_VER < 1916 // MSVC 2017 version 15.9 #include #include #include @@ -38,7 +38,8 @@ #endif #endif -THRUST_BEGIN_NS +namespace thrust +{ namespace detail { @@ -84,10 +85,10 @@ struct proclaim_contiguous_iterator : false_type {}; /// ContiguousIterator /// by specializing `thrust::proclaim_contiguous_iterator`. #define THRUST_PROCLAIM_CONTIGUOUS_ITERATOR(Iterator) \ - THRUST_BEGIN_NS \ + namespace thrust { \ template <> \ struct proclaim_contiguous_iterator : ::thrust::true_type {}; \ - THRUST_END_NS \ + } /* end namespace thrust */ \ /**/ /////////////////////////////////////////////////////////////////////////////// @@ -180,5 +181,5 @@ struct is_contiguous_iterator_impl } // namespace detail -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/type_traits/is_execution_policy.h b/thrust/type_traits/is_execution_policy.h index 5412e6c445..3f2f7ef80a 100644 --- a/thrust/type_traits/is_execution_policy.h +++ b/thrust/type_traits/is_execution_policy.h @@ -21,7 +21,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ /// Unary metafunction that is \c true if \c T is an \a ExecutionPolicy and /// \c false otherwise. @@ -44,6 +45,6 @@ template constexpr bool is_execution_policy_v = is_execution_policy::value; #endif -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/type_traits/is_operator_less_or_greater_function_object.h b/thrust/type_traits/is_operator_less_or_greater_function_object.h index 4fb53bda5b..6efc002238 100644 --- a/thrust/type_traits/is_operator_less_or_greater_function_object.h +++ b/thrust/type_traits/is_operator_less_or_greater_function_object.h @@ -27,7 +27,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace detail { @@ -131,5 +132,5 @@ struct is_operator_greater_function_object_impl > : true_type } // namespace detail -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/type_traits/is_operator_plus_function_object.h b/thrust/type_traits/is_operator_plus_function_object.h index 80481dfb06..0b2ebb1074 100644 --- a/thrust/type_traits/is_operator_plus_function_object.h +++ b/thrust/type_traits/is_operator_plus_function_object.h @@ -26,7 +26,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ namespace detail { @@ -72,5 +73,5 @@ struct is_operator_plus_function_object_impl > : true_type {}; } // namespace detail -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/type_traits/is_trivially_relocatable.h b/thrust/type_traits/is_trivially_relocatable.h index 00c614d3bf..de38735d29 100644 --- a/thrust/type_traits/is_trivially_relocatable.h +++ b/thrust/type_traits/is_trivially_relocatable.h @@ -22,7 +22,8 @@ #include #endif -THRUST_BEGIN_NS +namespace thrust +{ namespace detail { @@ -123,10 +124,10 @@ struct proclaim_trivially_relocatable : false_type {}; /// Declares that the type \c T is \a TriviallyRelocatable by specializing /// `thrust::proclaim_trivially_relocatable`. #define THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(T) \ - THRUST_BEGIN_NS \ + namespace thrust { \ template <> \ struct proclaim_trivially_relocatable : ::thrust::true_type {}; \ - THRUST_END_NS \ + } /* end namespace thrust */ \ /**/ /////////////////////////////////////////////////////////////////////////////// @@ -185,7 +186,7 @@ struct is_trivially_relocatable_impl : is_trivially_relocatable_impl {} } // namespace detail -THRUST_END_NS +} // end namespace thrust #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA diff --git a/thrust/type_traits/logical_metafunctions.h b/thrust/type_traits/logical_metafunctions.h index dbcc18382d..5f86ee6a82 100644 --- a/thrust/type_traits/logical_metafunctions.h +++ b/thrust/type_traits/logical_metafunctions.h @@ -19,7 +19,8 @@ #include -THRUST_BEGIN_NS +namespace thrust +{ #if THRUST_CPP_DIALECT >= 2017 @@ -172,7 +173,7 @@ constexpr bool negation_value_v = negation_value::value; template struct negation_value : std::integral_constant {}; -THRUST_END_NS +} // end namespace thrust #endif // THRUST_CPP_DIALECT >= 2011 diff --git a/thrust/type_traits/remove_cvref.h b/thrust/type_traits/remove_cvref.h index ef73044783..4079bfe8e8 100644 --- a/thrust/type_traits/remove_cvref.h +++ b/thrust/type_traits/remove_cvref.h @@ -19,7 +19,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ #if THRUST_CPP_DIALECT >= 2020 @@ -43,5 +44,5 @@ using remove_cvref_t = typename remove_cvref::type; #endif // THRUST_CPP_DIALECT >= 2020 -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/type_traits/void_t.h b/thrust/type_traits/void_t.h index 8550cc15b3..8ab56a3e87 100644 --- a/thrust/type_traits/void_t.h +++ b/thrust/type_traits/void_t.h @@ -26,7 +26,8 @@ # include #endif -THRUST_BEGIN_NS +namespace thrust +{ #if THRUST_CPP_DIALECT >= 2011 @@ -59,5 +60,5 @@ struct voider #endif -THRUST_END_NS +} // end namespace thrust diff --git a/thrust/version.h b/thrust/version.h index 8ab6b38ed4..79dadbfa30 100644 --- a/thrust/version.h +++ b/thrust/version.h @@ -73,9 +73,6 @@ */ #define THRUST_PATCH_NUMBER 0 - -// Declare these namespaces here for the purpose of Doxygenating them - /*! \namespace thrust * \brief \p thrust is the top-level namespace which contains all Thrust * functions and types. @@ -84,12 +81,3 @@ namespace thrust { } - -#ifndef THRUST_BEGIN_NS -#define THRUST_BEGIN_NS namespace thrust { -#endif - -#ifndef THRUST_END_NS -#define THRUST_END_NS } -#endif - diff --git a/thrust/zip_function.h b/thrust/zip_function.h index 26a7f43e7e..faea59d4c5 100644 --- a/thrust/zip_function.h +++ b/thrust/zip_function.h @@ -17,7 +17,8 @@ #include #include -THRUST_BEGIN_NS +namespace thrust +{ /*! \addtogroup function_objects Function Objects * \{ @@ -205,6 +206,6 @@ auto make_zip_function(Function&& fun) -> zip_function