Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:44:38

0001 //---------------------------------------------------------------------------//
0002 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 // See http://boostorg.github.com/compute for more information.
0009 //---------------------------------------------------------------------------//
0010 
0011 #ifndef BOOST_COMPUTE_UTILITY_DIM_HPP
0012 #define BOOST_COMPUTE_UTILITY_DIM_HPP
0013 
0014 #include <boost/compute/config.hpp>
0015 #include <boost/compute/utility/extents.hpp>
0016 
0017 namespace boost {
0018 namespace compute {
0019 
0020 #ifndef BOOST_COMPUTE_NO_VARIADIC_TEMPLATES
0021 /// The variadic \c dim() function provides a concise syntax for creating
0022 /// \ref extents objects.
0023 ///
0024 /// For example,
0025 /// \code
0026 /// extents<2> region = dim(640, 480); // region == (640, 480)
0027 /// \endcode
0028 ///
0029 /// \see \ref extents "extents<N>"
0030 template<class... Args>
0031 inline extents<sizeof...(Args)> dim(Args... args)
0032 {
0033     return extents<sizeof...(Args)>({ static_cast<size_t>(args)... });
0034 }
0035 
0036 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1800)
0037 // for some inexplicable reason passing one parameter to 'dim' variadic template 
0038 // generates compile error on msvc 2013 update 4
0039 template<class T>
0040 inline extents<1> dim(T arg)
0041 {
0042     return extents<1>(static_cast<size_t>(arg));
0043 }
0044 #endif // BOOST_WORKAROUND(BOOST_MSVC, <= 1800)
0045 
0046 #else
0047 // dim() function definitions for non-c++11 compilers
0048 #define BOOST_COMPUTE_DETAIL_ASSIGN_DIM(z, n, var) \
0049     var[n] = BOOST_PP_CAT(e, n);
0050 
0051 #define BOOST_COMPUTE_DETAIL_DEFINE_DIM(z, n, var) \
0052     inline extents<n> dim(BOOST_PP_ENUM_PARAMS(n, size_t e)) \
0053     { \
0054         extents<n> exts; \
0055         BOOST_PP_REPEAT(n, BOOST_COMPUTE_DETAIL_ASSIGN_DIM, exts) \
0056         return exts; \
0057     }
0058 
0059 BOOST_PP_REPEAT(BOOST_COMPUTE_MAX_ARITY, BOOST_COMPUTE_DETAIL_DEFINE_DIM, ~)
0060 
0061 #undef BOOST_COMPUTE_DETAIL_ASSIGN_DIM
0062 #undef BOOST_COMPUTE_DETAIL_DEFINE_DIM
0063 
0064 #endif // BOOST_COMPUTE_NO_VARIADIC_TEMPLATES
0065 
0066 /// \internal_
0067 template<size_t N>
0068 inline extents<N> dim()
0069 {
0070     return extents<N>();
0071 }
0072 
0073 } // end compute namespace
0074 } // end boost namespace
0075 
0076 #endif // BOOST_COMPUTE_UTILITY_DIM_HPP