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 9155121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:32:17+00:00 2026-06-17T12:32:17+00:00

Consider the following class #include <set> #include <vector> using namespace std; class foo {

  • 0

Consider the following class

#include <set>
#include <vector>
using namespace std;
class foo {
public:
  struct spatial {
    bool block;
    char status;  // H, M, Z
  };

  typedef pair< int, vector<spatial> > way;  // tag + spatial vector
  typedef set< way > one_set;


  void bar() 
  {
     way theWay;
     theWay.first = 10;

     one_set theSet;
     one_set::iterator sit = theSet.end();
     if (theSet.size() == 16) {
        sit = theSet.begin();
     }
     theSet.insert(sit, theWay);
  }
};

For the insert function, I receive these errors and I don’t know what does that mean

error C2784: 'bool std::operator <(const std::vector<_Ty,_Ax> &,const std::vector<_Ty,_Ax> &)' : could not deduce template argument for 'const std::vector<_Ty,_Ax> &' from 'const foo::spatial'    c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility

error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const foo::spatial'   c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility 3144

error C2784: 'bool std::operator <(const std::unique_ptr<_Ty,_Dx> &,const std::unique_ptr<_Ty2,_Dx2> &)' : could not deduce template argument for 'const std::unique_ptr<_Ty,_Dx> &' from 'const foo::spatial'  c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility 3144

error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt2> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const foo::spatial'    c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility 3144

error C2784: 'bool std::operator <(const std::_Revranit<_RanIt,_Base> &,const std::_Revranit<_RanIt2,_Base2> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'const foo::spatial'  c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility 3144    

error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const foo::spatial'    c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility 3144

error C2676: binary '<' : 'const foo::spatial' does not define this operator or a conversion to a type acceptable to the predefined operator    c:\program files (x86)\microsoft visual studio 10.0\vc\include\xutility 3144

Stuck at this point. Appreciate any help.

  • 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-06-17T12:32:19+00:00Added an answer on June 17, 2026 at 12:32 pm

    Your way type must have an operator< defined to be used in an std::set.

    std::pair has operator< if both types has operator<. int has operator<, that is ok, but vector<spatial> has operator< only if its element type has operator<. Your spatial class has none and therefore your way typedef has no operator< as well.

    Create an operator< for your spatial class and you’re ok.

    If you think that spatial classes should not be comparable but insist on having way in a set, you can also create your own comparator (a functor/lambda with two const way& parameters that return true if the first is less than the second) and pass that as the second template parameter of your set.

    Anyway, because std::set stores its elements sorted, to use it you have to define the ordering of your elements at some point.

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

Sidebar

Related Questions

Consider the following code: #include<iostream> #include<vector> using namespace std; class Foo { public: template<
Consider the following program #include <iostream> #include<cstdlib> using namespace std; class E { public:
Consider the following code: #include <iostream> using namespace std; class B{ public: B(){} };
Consider the following minimal example: #include <iostream> using namespace std; class myostream : public
Consider the following program. #include<iostream> using namespace std; class base { public: int _bval;
Consider the following sample code. #include <iostream> using namespace std; class base { public:
Consider the following program: #include <iostream> #include <algorithm> using namespace std; template<class T> struct
Consider the following sample code: #include <iostream> using namespace std; class base { public:
Consider the following minimal example. #include <vector> class Data { std::vector<int>& v; public: Data(std::vector<int>&
Consider the following code: #include <iostream> class Bar { public: void foo(bool b =

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.