If in CLion 2016.3.2 you start a new project and modify the main.cpp file as follows:

#include <utility> #include <vector> int main() { int a=0,b=1; std::swap(a,b); return 0; } 

That IDE will report an error: that it cannot find the std::swap function with the correct signature, while offering options from stl_bvector.h , for example, inline void swap(_Bit_reference __x, _Bit_reference __y) noexcept . The code is obviously compiled normally. If you remove the second line, then there will be no error.

It is also impossible to “suppress” this error, Alt + Enter on the line with an error does not work.

How to get rid of this error?

  • #include <algorithm> forgot - Sublihim
  • @Sublihim it says here that with c ++ 11 this function in <utility> ru.cppreference.com/w/cpp/algorithm/swap In any case, the error remains. - Im ieee
  • added C ++ label 11. You can try to clarify: std::swap<int,int>(a,b) And which compiler in CLion? - Sublihim
  • @Sublihim, thanks, so there is no error. Only there, just <int> . Write the answer, I will accept it. CLion uses the system compiler, and, for error analysis, apparently, its parser. - Im ieee
  • Yes, apparently a CLion error. You can try to report them a bug :) - Sublihim

1 answer 1

You can try to clarify:

 std::swap<int>(a,b) 

But, if even without specifying the template everything was compiled normally, maybe this is the IDE error itself?

  • I also discovered that if you add #include <tuple> additionally, you will get an error for this option. But it seems to work this way: std::swap<int>((int&)a,(int&)b); - Im ieee
  • @Imieee just need to report in zhetbryns - Sublihim
  • already, in my opinion, there is: youtrack.jetbrains.com/issue/CPP-8423 - Im ieee
  • for sure. Well, now wait until they fix it) - Sublihim