OSDN Git Service

CUDA
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / cuda-6.5 / include / thrust / detail / static_assert.h
1 /*
2  *  Copyright 2008-2013 NVIDIA Corporation
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #pragma once
18
19 #include <thrust/detail/config.h>
20 #include <thrust/detail/type_traits.h>
21
22 /*
23  * (C) Copyright John Maddock 2000.
24  * 
25  * Distributed under the Boost Software License, Version 1.0.
26  * (See accompanying NOTICE file for the complete license)
27  *
28  * For more information, see http://www.boost.org
29  */
30
31 //
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.
38 //
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
42
43 namespace thrust
44 {
45
46 namespace detail
47 {
48
49 // HP aCC cannot deal with missing names for template value parameters
50 template <bool x> struct STATIC_ASSERTION_FAILURE;
51
52 template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
53
54 // HP aCC cannot deal with missing names for template value parameters
55 template<int x> struct static_assert_test{};
56
57 template<typename, bool x>
58   struct depend_on_instantiation
59 {
60   static const bool value = x;
61 };
62
63 } // end detail
64
65 } // end thrust
66
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))
73 #else
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__)
78 #endif // gcc 4.8+
79