template template parameters with container and default allocator: can I make my declaration more compact?

Viewed 1142

I was looking at this interesting thread: https://stackoverflow.com/a/16596463/2436175

My specific case concerns declaring a templated function using a std container of cv::Point_ and cv::Rect_ from opencv. I want to template against:

  • the type of std container I will use
  • the basic data types to complete the definition of cv::Point_ and cv::Rect_

I ended up with the following declaration:

template <typename T, template <typename, typename> class Container_t>
    void CreateRects(const Container_t<cv::Point_<T>,std::allocator<cv::Point_<T> > >& points,
                     const T value,
                     Container_t<cv::Rect_<T>,std::allocator<cv::Rect_<T> > >& rects) {

    }

which compiles fine with this:

void dummy() {

const std::vector<cv::Point_<double> > points;
std::vector<cv::Rect_<double> > rects;
CreateRects(points,5.0,rects);

}

(I have also seen that I can also use, for example, CreateRects<double>(points,5,rects))

I was wondering if there existed any way to make my declaration more compact, e.g. without the need to specify 2 times the default allocator.

2 Answers
Related