]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/compute/include/boost/compute/type_traits/vector_size.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / type_traits / vector_size.hpp
CommitLineData
7c673cae
FG
1//---------------------------------------------------------------------------//
2// Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com>
3//
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
7//
8// See http://boostorg.github.com/compute for more information.
9//---------------------------------------------------------------------------//
10
11#ifndef BOOST_COMPUTE_TYPE_TRAITS_VECTOR_SIZE_HPP
12#define BOOST_COMPUTE_TYPE_TRAITS_VECTOR_SIZE_HPP
13
14#include <boost/preprocessor/cat.hpp>
15
16#include <boost/compute/types/fundamental.hpp>
17
18namespace boost {
19namespace compute {
20
21/// Meta-function returning the size (number of components) of a vector type
22/// \p T. For scalar types this function returns \c 1.
23///
24/// For example,
25/// \code
26/// vector_size<float>::value == 1
27/// vector_size<float4_>::value == 4
28/// \endcode
29template<class T>
30struct vector_size
31{
32 /// \internal_
33 BOOST_STATIC_CONSTANT(size_t, value = 1);
34};
35
36/// \internal_
37#define BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTION(scalar, size) \
38 template<> \
39 struct vector_size<BOOST_PP_CAT(BOOST_PP_CAT(scalar, size), _)> \
40 { \
41 BOOST_STATIC_CONSTANT(size_t, value = size); \
42 };
43
44/// \internal_
45#define BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(scalar) \
46 BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTION(scalar, 2) \
47 BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTION(scalar, 4) \
48 BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTION(scalar, 8) \
49 BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTION(scalar, 16)
50
51BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(char)
52BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(uchar)
53BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(short)
54BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(ushort)
55BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(int)
56BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(uint)
57BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(long)
58BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(ulong)
59BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(float)
60BOOST_COMPUTE_DECLARE_VECTOR_SIZE_FUNCTIONS(double)
61
62} // end compute namespace
63} // end boost namespace
64
65#endif // BOOST_COMPUTE_TYPE_TRAITS_VECTOR_SIZE_HPP