Question

I have very few experience with GCC and libstdc++. Trying to compile a very simple program in C++11 I found compiler errors that looks STL is not implementing new C++11 interface for deque.

The sample program:

#include <deque>

int main() {
   std::deque<int> c;
   std::deque<int> d;

    c.insert(c.cbegin(), d.begin(), d.end()); // unable to match insert(const_iterator, iterator, iterator)
    auto it=c.insert(c.begin(), d.begin(), d.end()); // unable to match iterator = insert(iterator, iterator, iterator)
}

Running following command line, I get compilation error in the commented lines:

g++ -std=c++11 -o test test.cpp

(Installed version of gcc/libstdc++ are 4.8.1)

It looks STL is not implementing:

template< class InputIt > iterator insert( const_iterator pos, InputIt first, InputIt last );

(http://en.cppreference.com/w/cpp/container/deque/insert, or std. C+11 23.3.3.4 deque modifiers)

I know libstdc++ does not completely implement C++11 yet, but status page (http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2011) suggests only the allocator and propagation requirements are not completed yet.

So my questions:

  • Is actually there are not a completed implementation of C++ std::deque interface in libstdc++, or am I missing something? (maybe I'm not using the right library version, or I'm lacking some parameter in command line; I have not too experience with gcc/g++).
  • If it is my mistake, how could I do to solve it?
Was it helpful?

Solution

Your code is valid, and accepted by GCC 4.9.0's libstdc++ (and has been accepted by clang's libc++ for a while too). The status page you link to warns about that:

This page describes the C++11 support in mainline GCC SVN, not in any particular release.

So the fact that something is listed as implemented there should not be taken to imply it is implemented in the version of GCC you've got installed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top