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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:11:00+00:00 2026-06-16T01:11:00+00:00

Possible Duplicate: Clang, std::shared_ptr and std::less/operator< So yeah, the title is pretty much the

  • 0

Possible Duplicate:
Clang, std::shared_ptr and std::less/operator<

So yeah, the title is pretty much the whole problem. As you can see from the snippet below i did implement operator< so i have no idea of what’s going on.

Here is the code:

namespace {

struct Transition {
    string name;
    StatePtr toState;

    Transition(string s = string(), StatePtr state = nullptr)
      : name(move(s))
      , toState(move(state))
    {}

    friend bool operator==(Transition const& lhs, Transition const & rhs) {
      return lhs.name == rhs.name && lhs.toState == rhs.toState;
    }

    friend bool operator<(Transition const & lhs, Transition const & rhs);
  };

  struct State {
    string name;
    set<TransitionPtr> transitions;

    explicit State(string s = string())
      : name(move(s))
    {}

    void addTransition(string s, StatePtr sp = nullptr){
      TransitionPtr new_t = make_transition(s, sp);
      for(auto& t : transitions){
        if(t == new_t){
          return;
        }
      }

      transitions.insert(move(new_t)); // This is where the error happens.
    }

  };
}

bool operator<(StateMachine::Transition const & lhs, StateMachine::Transition const & rhs) {
 return lhs.toState.get() < rhs.toState.get();
}

and the error message is:

In file included from ../llvm_opt_pass/cgd.cpp:3:
In file included from /srv/scratch/sigubufo/clang/stable/3.1_src/llvm/include/llvm/Instructions.h:23:
In file included from /srv/scratch/sigubufo/clang/stable/3.1_src/llvm/include/llvm/ADT/ArrayRef.h:13:
In file included from /srv/scratch/sigubufo/clang/stable/3.1_src/llvm/include/llvm/ADT/SmallVector.h:24:
In file included from /usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/memory:85:
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/unique_ptr.h:486:14: error: no matching function for call to object of type ‘std::less<_CT>’
return std::less<_CT>()(__x.get(), __y.get());
^~~~~~~~~~~~~~~~

/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_function.h:237:20: note: in instantiation of function template specialization ‘std::operator<<::StateMachine::Transition, std::default_delete<::StateMachine::Transition>, ::StateMachine::Transition, std::default_delete<::StateMachine::Transition> >’ requested here
{ return __x < __y; }
^

/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_tree.h:1285:13: note: in instantiation of member function ‘std::less::StateMachine::Transition, std::default_delete<::StateMachine::Transition> > >::operator()’ requested here
__comp = _M_impl._M_key_compare(_KeyOfValue()(__v), _S_key(__x));
^

/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_set.h:424:9: note: > in instantiation of function template specialization ‘std::_Rb_tree::StateMachine::Transition, std::default_delete<::StateMachine::Transition> >, std::unique_ptr<::StateMachine::Transition, std::default_delete<::StateMachine::Transition> >, std::_Identity::StateMachine::Transition, std::default_delete<::StateMachine::Transition> > >, std::less::StateMachine::Transition, std::default_delete<::StateMachine::Transition> > >, std::allocator::StateMachine::Transition, std::default_delete<::StateMachine::Transition> > > ::_M_insert_unique::StateMachine::Transition, std::default_delete<::StateMachine::Transition> > >’ requested here
_M_t._M_insert_unique(std::move(__x));
^

../llvm_opt_pass/cgd.cpp:72:17: note: in instantiation of member function ‘std::set::StateMachine::Transition, std::default_delete<::StateMachine::Transition> >, std::less::StateMachine::Transition, std::default_delete<::StateMachine::Transition> > >, std::allocator::StateMachine::Transition, std::default_delete<::StateMachine::Transition> > > >::insert’ requested here
transitions.insert(move(new_t));
^

/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../include/c++/4.7/bits/stl_function.h:236:7: note: candidate function not viable: no known conversion from ‘pointer’ (aka ‘::StateMachine::Transition *’) to ‘::StateMachine::Transition *&&&’ > for 1st argument;
operator()(const _Tp& __x, const _Tp& __y) const

  • 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-16T01:11:01+00:00Added an answer on June 16, 2026 at 1:11 am

    Ok, so the solution is the same as to this question: Clang, std::shared_ptr and std::less/operator< .

    Basically it’s a bug in type_traits from libstdc++.

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

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: How to wrap a Struct into NSObject Can the new Clang Objective-C
Possible Duplicate: && operator in Javascript In the sample code of the ExtJS web
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Unable to install pg gem on ubuntu - Can’t find the 'libpq-fe.h
Possible Duplicate: Why can templates only be implemented in the header file? I just
Possible Duplicate: Can you allocate a very large single chunk of memory ( >
Possible Duplicate: Can you write object oriented code in C? Hi, can someone point
Possible Duplicate: How can a Java program use files inside the .jar for read

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.