]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/compute/utility/dim.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / compute / utility / dim.hpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 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_UTILITY_DIM_HPP
12 #define BOOST_COMPUTE_UTILITY_DIM_HPP
13
14 #include <boost/compute/config.hpp>
15 #include <boost/compute/utility/extents.hpp>
16
17 namespace boost {
18 namespace compute {
19
20 #ifndef BOOST_COMPUTE_NO_VARIADIC_TEMPLATES
21 /// The variadic \c dim() function provides a concise syntax for creating
22 /// \ref extents objects.
23 ///
24 /// For example,
25 /// \code
26 /// extents<2> region = dim(640, 480); // region == (640, 480)
27 /// \endcode
28 ///
29 /// \see \ref extents "extents<N>"
30 template<class... Args>
31 inline extents<sizeof...(Args)> dim(Args... args)
32 {
33 return extents<sizeof...(Args)>({ static_cast<size_t>(args)... });
34 }
35
36 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1800)
37 // for some inexplicable reason passing one parameter to 'dim' variadic template
38 // generates compile error on msvc 2013 update 4
39 template<class T>
40 inline extents<1> dim(T arg)
41 {
42 return extents<1>(static_cast<size_t>(arg));
43 }
44 #endif // BOOST_WORKAROUND(BOOST_MSVC, <= 1800)
45
46 #else
47 // dim() function definitions for non-c++11 compilers
48 #define BOOST_COMPUTE_DETAIL_ASSIGN_DIM(z, n, var) \
49 var[n] = BOOST_PP_CAT(e, n);
50
51 #define BOOST_COMPUTE_DETAIL_DEFINE_DIM(z, n, var) \
52 inline extents<n> dim(BOOST_PP_ENUM_PARAMS(n, size_t e)) \
53 { \
54 extents<n> exts; \
55 BOOST_PP_REPEAT(n, BOOST_COMPUTE_DETAIL_ASSIGN_DIM, exts) \
56 return exts; \
57 }
58
59 BOOST_PP_REPEAT(BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_DETAIL_DEFINE_DIM, ~)
60
61 #undef BOOST_COMPUTE_DETAIL_ASSIGN_DIM
62 #undef BOOST_COMPUTE_DETAIL_DEFINE_DIM
63
64 #endif // BOOST_COMPUTE_NO_VARIADIC_TEMPLATES
65
66 /// \internal_
67 template<size_t N>
68 inline extents<N> dim()
69 {
70 return extents<N>();
71 }
72
73 } // end compute namespace
74 } // end boost namespace
75
76 #endif // BOOST_COMPUTE_UTILITY_DIM_HPP