prog.cpp: In function ‘int main()’:
prog.cpp:11:29: error: no matching function for call to ‘swap(std::__cxx11::string&, std::__cxx11::string)’
std::swap(s1, std::string());
^
In file included from /usr/include/c++/6/bits/nested_exception.h:40:0,
from /usr/include/c++/6/exception:173,
from /usr/include/c++/6/ios:39,
from /usr/include/c++/6/ostream:38,
from /usr/include/c++/6/iostream:39,
from prog.cpp:1:
/usr/include/c++/6/bits/move.h:179:5: note: candidate: typename std::enable_if<std::__and_<std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> >::value>::type std::swap(_Tp&, _Tp&) [with _Tp = std::__cxx11::basic_string<char>; typename std::enable_if<std::__and_<std::is_move_constructible<_Tp>, std::is_move_assignable<_Tp> >::value>::type = void] <near match>
swap(_Tp& __a, _Tp& __b)
^~~~
/usr/include/c++/6/bits/move.h:179:5: note: conversion of argument 2 would be ill-formed:
prog.cpp:11:21: error: invalid initialization of non-const reference of type ‘std::__cxx11::basic_string<char>&’ from an rvalue of type ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’
std::swap(s1, std::string());
^~~~~~~~
In file included from /usr/include/c++/6/bits/nested_exception.h:40:0,
from /usr/include/c++/6/exception:173,
from /usr/include/c++/6/ios:39,
from /usr/include/c++/6/ostream:38,
from /usr/include/c++/6/iostream:39,
from prog.cpp:1:
/usr/include/c++/6/bits/move.h:202:5: note: candidate: template<class _Tp, long unsigned int _Nm> typename std::enable_if<std::__is_swappable<_Tp>::value>::type std::swap(_Tp (&)[_Nm], _Tp (&)[_Nm])
swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
^~~~
/usr/include/c++/6/bits/move.h:202:5: note: template argument deduction/substitution failed:
prog.cpp:11:29: note: mismatched types ‘_Tp [_Nm]’ and ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’
std::swap(s1, std::string());
^
In file included from /usr/include/c++/6/bits/stl_algobase.h:64:0,
from /usr/include/c++/6/bits/char_traits.h:39,
from /usr/include/c++/6/ios:40,
from /usr/include/c++/6/ostream:38,
from /usr/include/c++/6/iostream:39,
from prog.cpp:1:
/usr/include/c++/6/bits/stl_pair.h:471:5: note: candidate: template<class _T1, class _T2> void std::swap(std::pair<_T1, _T2>&, std::pair<_T1, _T2>&)
swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
^~~~
/usr/include/c++/6/bits/stl_pair.h:471:5: note: template argument deduction/substitution failed:
prog.cpp:11:29: note: ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ is not derived from ‘std::pair<_T1, _T2>’
std::swap(s1, std::string());
^
In file included from /usr/include/c++/6/string:52:0,
from /usr/include/c++/6/bits/locale_classes.h:40,
from /usr/include/c++/6/bits/ios_base.h:41,
from /usr/include/c++/6/ios:42,
from /usr/include/c++/6/ostream:38,
from /usr/include/c++/6/iostream:39,
from prog.cpp:1:
/usr/include/c++/6/bits/basic_string.h:5302:5: note: candidate: void std::swap(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>] <near match>
swap(basic_string<_CharT, _Traits, _Alloc>& __lhs,
^~~~
/usr/include/c++/6/bits/basic_string.h:5302:5: note: conversion of argument 2 would be ill-formed:
prog.cpp:11:21: error: invalid initialization of non-const reference of type ‘std::__cxx11::basic_string<char>&’ from an rvalue of type ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’
std::swap(s1, std::string());
^~~~~~~~