Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7430761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:11:29+00:00 2026-05-29T09:11:29+00:00

#include<iostream> #include<vector> std::vector<std::string> vector1; int main() { vector1.push_back(adadad); std::vector<std::string> vector2; vector2.push_back(adadd); if (vector1==vector2) {

  • 0
#include<iostream>
#include<vector>
std::vector<std::string> vector1;
int main() {
    vector1.push_back("adadad");
    std::vector<std::string> vector2;
    vector2.push_back("adadd");
    if (vector1==vector2) {
        std::cout<<"success";
    } else {
       vector1.swap(vector2);
       vector2.clear();
       vector2.push_back("adadd");
       if (vector1==vector2) {
           std::cout<<"success_swap";
       }
    }
}

Now this works in g++ but not in visual studio. The operator == doesn’t work here and throws compilation error in visual studio 2010(ultimate). The same works if the vector is of a integer type.Am I missing something here ? This is not a linux native thing that they have omitted. Why there is a implementation in gcc but not in vc++ ?

The error message that it shows is:

[snip]\vc\include\xutility(2990): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'const std::basic_string<_Elem,_Traits,_Ax>' (or there is no acceptable conversion)
          with
          [
              _Elem=char,
              _Traits=std::char_traits<char>,
              _Ax=std::allocator<char>
          ]
          [snip]\vc\include\exception(470): could be 'bool std::operator ==(const std::_Exception_ptr &,const std::_Exception_ptr &)'
          [snip]\vc\include\exception(475): or       'bool std::operator ==(std::_Null_type,const std::_Exception_ptr &)'
          [snip]\vc\include\exception(481): or       'bool std::operator ==(const std::_Exception_ptr &,std::_Null_type)'
          [snip]\vc\include\system_error(408): or       'bool std::operator ==(const std::error_code &,const std::error_condition &)'
          [snip]\vc\include\system_error(416): or       'bool std::operator ==(const std::error_condition &,const std::error_code &)'
          while trying to match the argument list '(const std::basic_string<_Elem,_Traits,_Ax>, const std::basic_string<_Elem,_Traits,_Ax>)'
          with
          [
              _Elem=char,
              _Traits=std::char_traits<char>,
              _Ax=std::allocator<char>
          ]
          [snip]\vc\include\xutility(3030) : see reference to function template instantiation 'bool std::_Equal<_InIt1,_InIt2>(_InIt1,_InIt1,_InIt2)' being compiled
          with
          [
              _InIt1=const std::basic_string<char,std::char_traits<char>,std::allocator<char>> *,
              _InIt2=std::_Vector_const_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>
          ]
          [snip]\vc\include\xutility(3051) : see reference to function template instantiation 'bool std::_Equal1<const std::basic_string<_Elem,_Traits,_Ax>*,_InIt2>(_InIt1,_InIt1,_InIt2,std::tr1::true_type)' being compiled
          with
          [
              _Elem=char,
              _Traits=std::char_traits<char>,
              _Ax=std::allocator<char>,
              _InIt2=std::_Vector_const_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>,
              _InIt1=const std::basic_string<char,std::char_traits<char>,std::allocator<char>> *
          ]
          [snip]\vc\include\vector(1489) : see reference to function template instantiation 'bool std::equal<std::_Vector_const_iterator<_Myvec>,std::_Vector_const_iterator<_Myvec>>(_InIt1,_InIt1,_InIt2)' being compiled
          with
          [
              _Myvec=std::_Vector_val<std::string,std::allocator<std::string>>,
              _InIt1=std::_Vector_const_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>,
              _InIt2=std::_Vector_const_iterator<std::_Vector_val<std::string,std::allocator<std::string>>>
          ]
          [snip]\test\main.cpp(8) : see reference to function template instantiation 'bool std::operator ==<std::string,std::allocator<_Ty>>(const std::vector<_Ty> &,const std::vector<_Ty> &)' being compiled
          with
          [
              _Ty=std::string
          ]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:11:30+00:00Added an answer on May 29, 2026 at 9:11 am

    The error happens because in MSVC, std::string‘s equality operator (==) is not included by <iostream> or <vector>. You have to include <string> as well.

    The key line in the message is; “error C2678: binary ‘==’ : no operator found which takes a left-hand operand of type ‘const std::basic_string<_Elem,_Traits,_Ax>’ (or there is no acceptable conversion)”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int main(void) {
#include <iostream> #include <vector> #include <list> using namespace std; int main() { vector<list<string> >
My compiler complains. #include <iostream> #include <vector> using namespace std; int main(){ vector<string> vec[2];
#include <iostream> #include <vector> using namespace std; int main() { vector< vector<int> > dp(50000,
#include <iostream> #include <vector> using namespace std; int main(void) { int i, s, g;
#include <iostream> #include <algorithm> #include <vector> #include <boost/array.hpp> #include <boost/bind.hpp> int main() { boost::array<int,
#include <iostream> #include <string> #include <fstream> #include <vector> using namespace std; class Dict {
For the following code: #include<iostream> #include<vector> #include<string> using namespace std; struct Test { string
#include <iostream> #include <vector> using namespace std; typedef struct Record { std::string name; bool
I've got this code: #include <iostream> #include <string> #include <vector> using namespace std; vector<string>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.