OSDN Git Service

modified: utilsrc/src/Admin/Makefile
[eos/others.git] / utiltools / X86MAC64 / cuda / include / thrust / system / detail / error_condition.inl
1 /*
2  *  Copyright 2008-2012 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
18 #pragma once
19
20 #include <thrust/system/detail/error_condition.inl>
21 #include <thrust/functional.h>
22
23 namespace thrust
24 {
25
26 namespace system
27 {
28
29 error_condition
30   ::error_condition(void)
31     :m_val(0),m_cat(&generic_category())
32 {
33   ;
34 } // end error_condition::error_condition()
35
36
37 error_condition
38   ::error_condition(int val, const error_category &cat)
39     :m_val(val),m_cat(&cat)
40 {
41   ;
42 } // end error_condition::error_condition()
43
44
45 template<typename ErrorConditionEnum>
46   error_condition
47     ::error_condition(ErrorConditionEnum e
48 // XXX WAR msvc's problem with enable_if
49 #if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC
50                       , typename thrust::detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value>::type *
51 #endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC
52                      )
53 {
54   *this = make_error_condition(e);
55 } // end error_condition::error_condition()
56
57
58 void error_condition
59   ::assign(int val, const error_category &cat)
60 {
61   m_val = val;
62   m_cat = &cat;
63 } // end error_category::assign()
64
65
66 template<typename ErrorConditionEnum>
67 // XXX WAR msvc's problem with enable_if
68 #if THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC
69   typename thrust::detail::enable_if<is_error_condition_enum<ErrorConditionEnum>::value, error_condition>::type &
70 #else
71   error_condition &
72 #endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC
73     error_condition
74       ::operator=(ErrorConditionEnum e)
75 {
76   *this = make_error_condition(e);
77   return *this;
78 } // end error_condition::operator=()
79
80
81 void error_condition
82   ::clear(void)
83 {
84   m_val = 0;
85   m_cat = &generic_category();
86 } // end error_condition::clear()
87
88
89 int error_condition
90   ::value(void) const
91 {
92   return m_val;
93 } // end error_condition::value()
94
95
96 const error_category &error_condition
97   ::category(void) const
98 {
99   return *m_cat;
100 } // end error_condition::category()
101
102
103 std::string error_condition
104   ::message(void) const
105 {
106   return category().message(value());
107 } // end error_condition::message()
108
109
110 error_condition
111   ::operator bool (void) const
112 {
113   return value() != 0;
114 } // end error_condition::operator bool ()
115
116
117 error_condition make_error_condition(errc::errc_t e)
118 {
119   return error_condition(static_cast<int>(e), generic_category());
120 } // end make_error_condition()
121
122
123 bool operator<(const error_condition &lhs,
124                const error_condition &rhs)
125 {
126   return lhs.category().operator<(rhs.category()) || (lhs.category().operator==(rhs.category()) && (lhs.value() < rhs.value()));
127 } // end operator<()
128
129
130 } // end system
131
132 } // end thrust
133