C++ C++;std::交换无效参数

C++ C++;std::交换无效参数,c++,c++11,C++,C++11,我一直在尝试使用C++中的std::swap函数: #include <iostream> int main(int argc, char * argv[]){ int i(2); int j(3); std::cout << i << std::endl << j << std::endl; using std::swap; swap(i,j); std::cout <<

我一直在尝试使用C++中的
std::swap
函数:

#include <iostream>

int main(int argc, char * argv[]){
    int i(2);
    int j(3);
    std::cout << i << std::endl << j << std::endl;
    using std::swap;
    swap(i,j);
    std::cout << i << std::endl << j << std::endl;
}
#包括
int main(int argc,char*argv[]){
int i(2);
int j(3);
std::cout在标题
中定义。首先包括标题,这将成功


错误中显示的重载似乎引用了其他
std::swap
实现,通过包含
可以看到这些实现。例如,
std::swap
For
std::\uuuCXX11::basic_string
std::string
)在<代码> <代码>中定义,并且您的代码< > /COD>的实现可能包含“代码>字符串(或至少向前声明相关部分)作为其实现的一部分,这使得 < Suff过载可见。< /P>您的代码为C++ 17。您编译的C++版本是什么?尝试包括适当的标题:(它是
#include
)点击“g++--version”让我得到了8.1.0版本,我尝试了#include,但它似乎没有改变任何东西。事实上,我在Linux上试过,它工作得很好,所以我的IDE可能是配置问题吗?基本上我只是为C/C++开发人员下载了Eclipse IDE,然后是MinGW的一些发行版(并且没有忘记将C:\MinGW\bin添加到路径)这可能是配置的问题(例如eclipse使用了不正确的include路径或其他东西),甚至只是需要更新的错误索引问题。Eclipse中的索引有时会过时,这需要在错误消失之前重建索引。您收到的错误消息可能仍然适用于不同的标准库和/或版本…您是否知道
\ucplusplus
符号是什么是否在Eclipse的预处理器中计算到?它有时可能被错误地设置为
199711L
(C++98)这将取决于项目的语言设置,但可以在Eclipse的设置中手动调整。C++ 98定义了<代码> SWIFT//> > <代码> <代码>,C++ 11将它移到 < /Cord>——IDE可以用不同的C++版本进行预处理,而不是我编写的,如果不是MI的话。staken,uuu cplusplus符号在201402进行评估。但我同意,我认为IDE预处理器和编译器之间肯定有问题。我尝试安装了另一个MinGW发行版,它工作得非常好。非常感谢!
Invalid arguments '
Candidates are:
std::enable_if<74 0 value 14 std::__and_ 3 14 std::__not_ 1 14 std::__is_tuple_like 1 #0 14 std::is_move_constructible 1 #0 14 std::is_move_assignable 1 #074 0 value 14 std::__and_ 3 14 std::__not_ 1 14 std::__is_tuple_like 1 #0 14 std::is_move_constructible 1 #0 14 std::is_move_assignable 1 #0,void>::type swap(#0 &, #0 &)
std::enable_if<74 0 value 14 std::__and_ 2 14 std::__is_swappable 1 #0 14 std::__is_swappable 1 #174 0 value 14 std::__and_ 2 14 std::__is_swappable 1 #0 14 std::__is_swappable 1 #1,void>::type swap(std::pair<#0,#1> &, std::pair<#0,#1> &)
std::enable_if<bool15 7 74 0 value 14 std::__and_ 2 14 std::__is_swappable 1 #0 14 std::__is_swappable 1 #1 0,void>::type swap(std::pair<#0,#1> &, std::pair<#0,#1> &)
void swap(std::__cxx11::basic_string<#0,#1,#2> &, std::__cxx11::basic_string<#0,#1,#2> &)
std::enable_if<74 0 value 14 std::__is_swappable 1 #074 0 value 14 std::__is_swappable 1 #0,void>::type swap(#0 (&)[3 #1 0], #0 (&)[3 #1 0])
'