std :: sort에 전달할 수 있도록 compare 함수를 정의하고 싶습니다. 비교는 아래의 'compare_by_x'함수에서 설명한대로 벡터 x의 순서에 따라 수행해야합니다.템플릿 인수에 벡터 전달하기
template <std::vector<double> x>
bool compare_by_x(int i, int j){
return x[i] <= x[j];
}
다음과 같이 compare_by_x 함수를 전달하려고합니다. 이것은 작동하지 않습니다.
std::sort(some_index_vector.begin(), some_index_vector.end(), compare_by_x<x>);
''을 compare_by_x에서 x는 무엇입니까 : 여기 예를하고있다? –
mattn
컴파일 할 때 오류가 발생합니까? – satishgoda
가능한 중복 [boost zip \ _iterator 및 std :: sort] (http://stackoverflow.com/questions/9343846/boost-zip-iterator-and-stdsort) –