std::inserter не работает

Я пишу код, в котором один из файлов использует функцию set_intersection, а последним параметром этой функции должен быть вставщик. Но когда я компилирую код, я вижу следующие ошибки:

error C2039: 'inserter' : is not a member of 'std'
error C2873: 'inserter' : symbol cannot be used in a using-declaration
error C3861: 'inserter': identifier not found

Ниже приведен код в файле, который использует функцию set_intersection

#include "Query.h"
#include "TextQuery.h"
#include <set>
#include <algorithm>
#include <iostream>

using std::set;
using std::ostream;
using std::inserter; 
using std::set_intersection;

// returns intersection of its operands' result sets
set<TextQuery::line_no>
AndQuery::eval(const TextQuery& file) const
{
    // virtual calls through the Query handle to get result sets for the operands
    set<line_no> left = lhs.eval(file), 
                 right = rhs.eval(file);

    set<line_no> ret_lines;  // destination to hold results 

    // writes intersection of two ranges to a destination iterator
    // destination iterator in this call adds elements to ret
    set_intersection(left.begin(), left.end(), 
                  right.begin(), right.end(),
                  inserter(ret_lines, ret_lines.begin()));
    return ret_lines;
}

2 ответа

Решение

Вы должны включить <iterator> заголовок.

Ты забыл #include <iterator>,

Другие вопросы по тегам