2 * Copyright 2008-2013 NVIDIA Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <thrust/detail/config.h>
20 #include <thrust/detail/type_traits.h>
23 * (C) Copyright John Maddock 2000.
25 * Distributed under the Boost Software License, Version 1.0.
26 * (See accompanying NOTICE file for the complete license)
28 * For more information, see http://www.boost.org
32 // Helper macro THRUST_JOIN (based on BOOST_JOIN):
33 // The following piece of macro magic joins the two
34 // arguments together, even when one of the arguments is
35 // itself a macro (see 16.3.1 in C++ standard). The key
36 // is that macro expansion of macro arguments does not
37 // occur in THRUST_DO_JOIN2 but does in THRUST_DO_JOIN.
39 #define THRUST_JOIN( X, Y ) THRUST_DO_JOIN( X, Y )
40 #define THRUST_DO_JOIN( X, Y ) THRUST_DO_JOIN2(X,Y)
41 #define THRUST_DO_JOIN2( X, Y ) X##Y
49 // HP aCC cannot deal with missing names for template value parameters
50 template <bool x> struct STATIC_ASSERTION_FAILURE;
52 template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
54 // HP aCC cannot deal with missing names for template value parameters
55 template<int x> struct static_assert_test{};
57 template<typename, bool x>
58 struct depend_on_instantiation
60 static const bool value = x;
67 #if (THRUST_HOST_COMPILER == THRUST_HOST_COMPILER_GCC) && (THRUST_GCC_VERSION >= 40800)
68 // gcc 4.8+ will complain about this typedef being unused unless we annotate it as such
69 # define THRUST_STATIC_ASSERT( B ) \
70 typedef ::thrust::detail::static_assert_test<\
71 sizeof(::thrust::detail::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
72 THRUST_JOIN(thrust_static_assert_typedef_, __LINE__) __attribute__((unused))
74 # define THRUST_STATIC_ASSERT( B ) \
75 typedef ::thrust::detail::static_assert_test<\
76 sizeof(::thrust::detail::STATIC_ASSERTION_FAILURE< (bool)( B ) >)>\
77 THRUST_JOIN(thrust_static_assert_typedef_, __LINE__)