Boost logo

Boost :

Subject: [boost] [Compute] array support
From: Fabian Bösch (boeschf_at_[hidden])
Date: 2015-09-18 07:05:29


Hi,

I've been using Boost.Compute for some tests in the last couple of days.
So far, it has proven very useful and I came to like it quite a bit. One
thing I would add to it, though, is support for arrays when adapting
your own classes for OpenCl through the Macro
BOOST_COMPUTE_ADAPT_STRUCT. A simple overload would do the trick in my
opinion:

namespace boost {
namespace compute {
namespace detail {

template<class Struct, class T>
inline std::string adapt_struct_insert_member(T Struct::*, const char
*name)
{
    std::stringstream s;
    s << " " << type_name<T>() << " " << name << ";\n";
    return s.str();
}

template<class Struct, class T, int N>
inline std::string adapt_struct_insert_member(T (Struct::*)[N], const
char *name)
{
    std::stringstream s;
    s << " " << type_name<T>() << " " << name << "[" << N << "]" <<
";\n";
    return s.str();
}

} // end detail namespace
} // end compute namespace
} // end boost namespace

Hope something along this lines can be added, thanks,

Fabian


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk