2016-09-21 6 views
3

Я пытаюсь написать алгоритм, который должен работать с различными контейнерами (станд :: вектор, QVector), содержащих тот же тип:функция общего контейнера конкретной специализации

template<class Container> 
boolean findpeaks(cv::Mat &m, Container<std::pair<int, double>> &peaks) { 
    // do stuff 
    peaks.push_back(std::make_pair(1, 1.0)); 

    return true; 
} 

Это один дает мне

'Container' is not a template

template<template<typename> class Container> 

я получаю:

error: no matching function for call to 'findpeaks(cv::MatExpr, std::vector >&)'

...

note: template argument deduction/substitution failed:

error: wrong number of template arguments (2, should be 1)

Телефонный код:

cv::Mat m(data, true); 
std::vector<std::pair<int, double>> peaks; 

QVERIFY(daf::findpeaks(m.t(), peaks)); 

Я также пытался что-то вроде этого:

template<template< template<typename, typename> typename > class Container> 

warning: ISO C++ forbids typename key in template template parameter; use -std=c++1z or -std=gnu++1z [-Wpedantic]

И еще несколько ошибок ...

+1

«тот же тип» показан не тип. Это функция. 'template