vendredi 26 février 2021

ICC not recognizing stream move semantics

I have the following piece of code that works with -std=c++0x under recent GCC (9.3.1) and clang (7.0.1). It does not work under older GCC (4.8.5), but that's OK. I am now trying to get it to work under ICC (19.0.5.281 20190815).

inline std::istringstream setup_extraction_stream(const std::string buffer, const std::string searchkey)
{
    const size_t offset = buffer.find(searchkey);
    std::istringstream iss(buffer);
    if (offset != std::string::npos)
    {
        iss.seekg(offset);
    }
    return iss;
}

My understanding is that this works because std::istringstream has an implicit move constructor, so there's no copying happening here. However ICC does not seem to have such a move constructor.

error: function "std::basic_istringstream<_CharT, _Traits, _Alloc>::basic_istringstream(const std::basic_istringstream<char, std::char_traits<char>, std::allocator<char>> &) [with _CharT=char, _Traits=std::char_traits<char>, _Alloc=std::allocator<char>]" (declared implicitly) cannot be referenced -- it is a deleted function
    return iss;
           ^

How can I work around this?

Aucun commentaire:

Enregistrer un commentaire