2 * Copyright 2008-2012 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.
20 #include <thrust/system/detail/error_condition.inl>
21 #include <thrust/functional.h>
30 ::error_condition(void)
31 :m_val(0),m_cat(&generic_category())
34 } // end error_condition::error_condition()
38 ::error_condition(int val, const error_category &cat)
39 :m_val(val),m_cat(&cat)
42 } // end error_condition::error_condition()
45 template<typename ErrorConditionEnum>
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
54 *this = make_error_condition(e);
55 } // end error_condition::error_condition()
59 ::assign(int val, const error_category &cat)
63 } // end error_category::assign()
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 &
72 #endif // THRUST_HOST_COMPILER != THRUST_HOST_COMPILER_MSVC
74 ::operator=(ErrorConditionEnum e)
76 *this = make_error_condition(e);
78 } // end error_condition::operator=()
85 m_cat = &generic_category();
86 } // end error_condition::clear()
93 } // end error_condition::value()
96 const error_category &error_condition
97 ::category(void) const
100 } // end error_condition::category()
103 std::string error_condition
104 ::message(void) const
106 return category().message(value());
107 } // end error_condition::message()
111 ::operator bool (void) const
114 } // end error_condition::operator bool ()
117 error_condition make_error_condition(errc::errc_t e)
119 return error_condition(static_cast<int>(e), generic_category());
120 } // end make_error_condition()
123 bool operator<(const error_condition &lhs,
124 const error_condition &rhs)
126 return lhs.category().operator<(rhs.category()) || (lhs.category().operator==(rhs.category()) && (lhs.value() < rhs.value()));