Not all containers I use have a (begin, end) constructor:
#include
#include <algorithm>
#include
#include
#include
namespace detail {
template
struct construct_from_range_impl {
cont_t operator() (range const& r) {
return cont_t (boost::begin (r), boost::end (r));
}
};
template
struct construct_from_range_impl {
typedef typename boost::numeric::ublas::vector<T> ret_t;
ret_t operator() (range const& r) {
ret_t v (boost::size (r));
std::copy (boost::begin (r), boost::end (r), v.begin());
return v;
}
};
template
struct construct_from_range_impl, range> {
typedef typename boost::multi_array ret_t;
ret_t operator() (range const& r) {
ret_t v (r);
return v;
}
};
template
struct construct_from_range_impl {
typedef typename pyublas::numpy_vector<T> ret_t;
ret_t operator() (range const& r) {
ret_t v (r);
return v;
}
};
}
template
cont_t inline construct_from_range (range const& r) {
return detail::construct_from_range_impl() (r);
}