Simple programs like the following do not compile under -std=c++0x on GCC 4.5.0
- due to the new GCC enforcement of C++0x rules regarding l-values not being
allowed to bind to "&&".

#include <iostream>
#include <math.h>

int main(int argc, char** argv)
{
    std::pair< std::string, std::string > x("hello", "world");
    std::pair< std::string, std::string > y("test", "123");
    std::swap(x, y);
    std::cout << x.first << ' ' << x.second << std::endl;
    return 0;
}

Compiler output:
In function ‘void std::swap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&) [with
_T1 = std::basic_string<char>, _T2 = std::basic_string<char>]’:
error: cannot bind ‘std::pair<std::basic_string<char>, std::basic_string<char>
>’ lvalue to ‘std::pair<std::basic_string<char>, std::basic_string<char> >&&’
error:   initializing argument 1 of ‘void std::pair<_T1,
_T2>::swap(std::pair<_T1, _T2>&&) [with _T1 = std::basic_string<char>, _T2 =
std::basic_string<char>, std::pair<_T1, _T2> =
std::pair<std::basic_string<char>, std::basic_string<char> >]’

Likely related to bug# 43785


-- 
           Summary: std::swap not working with -std=c++0x
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: navin dot kumar at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43916

Reply via email to