1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_TYPE_TRAITS_SCALAR_TYPE_HPP
12 #define BOOST_COMPUTE_TYPE_TRAITS_SCALAR_TYPE_HPP
14 #include <boost/preprocessor/cat.hpp>
16 #include <boost/compute/types/fundamental.hpp>
21 /// Meta-function returning the scalar type for a vector type.
25 /// scalar_type<float4_>::type == float
27 template<class Vector>
35 #define BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTION(scalar) \
37 struct scalar_type<BOOST_PP_CAT(scalar, _)> \
39 typedef BOOST_PP_CAT(scalar, _) type; \
43 #define BOOST_COMPUTE_DECLARE_VECTOR_SCALAR_TYPE_FUNCTION(scalar, size) \
45 struct scalar_type<BOOST_PP_CAT(BOOST_PP_CAT(scalar, size), _)> \
47 typedef BOOST_PP_CAT(scalar, _) type; \
51 #define BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(scalar) \
52 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTION(scalar) \
53 BOOST_COMPUTE_DECLARE_VECTOR_SCALAR_TYPE_FUNCTION(scalar, 2) \
54 BOOST_COMPUTE_DECLARE_VECTOR_SCALAR_TYPE_FUNCTION(scalar, 4) \
55 BOOST_COMPUTE_DECLARE_VECTOR_SCALAR_TYPE_FUNCTION(scalar, 8) \
56 BOOST_COMPUTE_DECLARE_VECTOR_SCALAR_TYPE_FUNCTION(scalar, 16)
58 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(char)
59 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(uchar)
60 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(short)
61 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(ushort)
62 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(int)
63 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(uint)
64 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(long)
65 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(ulong)
66 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(float)
67 BOOST_COMPUTE_DECLARE_SCALAR_TYPE_FUNCTIONS(double)
69 } // end compute namespace
70 } // end boost namespace
72 #endif // BOOST_COMPUTE_TYPE_TRAITS_SCALAR_TYPE_HPP