使用VS2013 x64为libmimetic(mimetic)库构建exbin示例时出现C2784错误

时间:2015-09-04 19:58:18

标签: c++ templates visual-studio-2013 stl compiler-errors

使用VS2013 x64为 libmimetic 库构建 exbin 示例时,我遇到了几个错误,这些错误与第一个错误相同:

exbin.cxx:202: error: C2784: 'std::_Vb_iterator<_Alloc>
std::operator +(_Alloc::difference_type, std::_Vb_iterator<_Alloc>)' :
could not deduce template argument for 'std::_Vb_iterator<_Alloc>' from 'unsigned __int64'

麻烦的功能如下:

template<typename Iterator>
void parse(Iterator bit, Iterator eit, string& fqn)
{
    string sep = "From ";
    Iterator it = utils::find_bm(bit, bit + sep.length(), sep);   //<<<<ERROR
    if(it == bit)
    {
        parseMboxFile(bit, eit, fqn);
    } else {
        g_messages++;
        MimeEntity me(bit, eit);
        parsePart(me, fqn);
    }
}

有什么想法吗?

编译库本身没有任何问题。

2 个答案:

答案 0 :(得分:0)

正在搜索var ProjectActions = Reflux.createActions({ getProject: {asyncResult: true} }); ProjectActions.getProject.listen(function (projectID) { // Get the project based on projectID. $.ajax({ type: 'GET', url: '/api/projects/getProject/' + projectID }).done(function(response){ ProjectActions.getProject.completed(response); }).error(function(error){ alert('GET projects failed.'); ProjectActions.getProject.failed(error); }); }); var ProjectStore = Reflux.createStore({ init: function () { // default project properties: this.data = { format: '', title: '', productionCompany: '' }; }, listenables: ProjectActions, getInitialState: function() { return this.data; }, onGetProjectCompleted: function(response) { for (var prop in response) { if (response.hasOwnProperty(prop)) { this.data[prop] = response[prop]; } } this.trigger(this.data); } }); 引导我到这里:With templates: Operator resolved first or conversion resolved first?

由于缺少标题而导致问题。确保模板函数包含标题std::_Vb_iterator,并在调用函数的文件中,确保包含数据结构的标题(例如<string>)。

答案 1 :(得分:0)

我也在同一代码行中遇到此错误(见上文):

exbin.cxx:202: error: C2676: binary '+' : 'mimetic::StdFile::iterator'
does not define this operator or a conversion to a type acceptable
to the predefined operator

在模仿的来源中有一个 mimetic / os / file_iterator.h 文件声明:

struct ifile_iterator: public std::iterator<std::input_iterator_tag, char>
{
    ifile_iterator();    
    ifile_iterator(StdFile* f);
    ifile_iterator(const ifile_iterator&);
    ifile_iterator& operator=(const ifile_iterator&);
    ~ifile_iterator();    
    inline ifile_iterator& operator++();
    inline ifile_iterator operator++(int);
    inline reference operator*();
    inline bool operator!=(const ifile_iterator& right) const;
    inline bool operator==(const ifile_iterator& right) const;
private:
    void cp(const ifile_iterator&);
    void setBufsz();
    enum { defBufsz = 4096 }; // default buffer size(4 missing getpagesize)
    void underflow();
    bool m_eof;
    value_type* m_buf;
    value_type* m_ptr;
    int m_count;
    StdFile* m_pFile;
    unsigned int m_read; //bytes read so far
    unsigned int m_bufsz;
};

inline
ifile_iterator ifile_iterator::operator++(int) // postfix
{
    ifile_iterator cp = *this;
    operator++();
    return cp;
}

//...

缺少什么?