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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:03:57+00:00 2026-05-23T00:03:57+00:00

What is the preferred method of using std::rel_ops to add the full set of

  • 0

What is the preferred method of using std::rel_ops to add the full set of relational operators to a class?

This documentation suggests a using namespace std::rel_ops, but this seems to be deeply flawed, as it would mean that including the header for the class implemented in this way would also add full relational operators to all other classes with a defined operator< and operator==, even if that was not desired. This has the potential to change the meaning of code in surprising ways.

As a side note – I have been using Boost.Operators to do this, but I am still curious about the standard library.

  • 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-23T00:03:58+00:00Added an answer on May 23, 2026 at 12:03 am

    I think that the preferred technique is not to use std::rel_ops at
    all. The technique used in boost::operator (link) seems to be the usual
    solution.

    Example:

    #include "boost/operators.hpp"
    
    class SomeClass : private boost::equivalent<SomeClass>, boost::totally_ordered<SomeClass>
    {
    public:
        bool operator<(const SomeClass &rhs) const
        {
            return someNumber < rhs.someNumber;
        }
    private:
        int someNumber;
    };
    
    int main()
    {
        SomeClass a, b;
        a < b;
        a > b;
        a <= b;
        a >= b;
        a == b;
        a != b;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the preferred method for implementing such geometric distortions as pinch/fisheye/etc. using the
What's your preferred method of providing a search facility on a website? Currently I
What is your preferred method for reading through the contents of zipped directories with
What is your preferred method of traversing a tree data structure, since recursive method
What is the preferred method to achieve the C++ equivalent of java's instanceof ?
We're currentlly thinking about secureity in our applications. Our preferred method of getting data
Which method is preferred? Session.Remove(foo); Session[foo] = null; Is there a difference?
I'm used to Atlas where the preferred (from what I know) method is to
What is people's prefered method of storing application configuration data in a database. From
What is the prefered method for creating a byte array from an input stream?

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.