/* * Copyright 2008-2012 NVIDIA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include namespace thrust { // forward definitions for is_commutative template struct plus; template struct multiplies; template struct minimum; template struct maximum; template struct logical_or; template struct logical_and; template struct bit_or; template struct bit_and; template struct bit_xor; namespace detail { // some metafunctions which check for the nested types of the adaptable functions __THRUST_DEFINE_HAS_NESTED_TYPE(has_result_type, result_type) __THRUST_DEFINE_HAS_NESTED_TYPE(has_argument_type, argument_type) __THRUST_DEFINE_HAS_NESTED_TYPE(has_first_argument_type, first_argument_type) __THRUST_DEFINE_HAS_NESTED_TYPE(has_second_argument_type, second_argument_type) template struct result_type { typedef typename AdaptableBinaryFunction::result_type type; }; template struct is_adaptable_unary_function : thrust::detail::and_< has_result_type, has_argument_type > {}; template struct is_adaptable_binary_function : thrust::detail::and_< has_result_type, thrust::detail::and_< has_first_argument_type, has_second_argument_type > > {}; template struct is_commutative : public thrust::detail::false_type {}; template struct is_commutative< typename thrust::plus > : public thrust::detail::is_arithmetic {}; template struct is_commutative< typename thrust::multiplies > : public thrust::detail::is_arithmetic {}; template struct is_commutative< typename thrust::minimum > : public thrust::detail::is_arithmetic {}; template struct is_commutative< typename thrust::maximum > : public thrust::detail::is_arithmetic {}; template struct is_commutative< typename thrust::logical_or > : public thrust::detail::is_arithmetic {}; template struct is_commutative< typename thrust::logical_and > : public thrust::detail::is_arithmetic {}; template struct is_commutative< typename thrust::bit_or > : public thrust::detail::is_arithmetic {}; template struct is_commutative< typename thrust::bit_and > : public thrust::detail::is_arithmetic {}; template struct is_commutative< typename thrust::bit_xor > : public thrust::detail::is_arithmetic {}; } // end namespace detail } // end namespace thrust