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

  • Home
  • SEARCH
  • 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 8211461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:26:01+00:00 2026-06-07T10:26:01+00:00

I am using a custom Set class that is basically the same as the

  • 0

I am using a custom Set class that is basically the same as the STL Set class

The problem is that I am somehow implementing it incorrectly and the default comparison function is used rather than a comparison I defined.

Set<Lexicon::CorrectionT> Lexicon::suggestCorrections(Lexicon::MatchesT & matchSet)
{
    Set<CorrectionT> suggest(compareCorr); //ordered Set
    suggestCorrectionsHelper(root, suggest, 0, matchSet.testWord, 0, matchSet.testTime);
    return suggest;
}


int compareCorr(Lexicon::CorrectionT a, Lexicon::CorrectionT b)
{
    if (a.editDistance < b.editDistance)
        return -1;
    else if (a.editDistance == b.editDistance)
            return 0;
    else
        return 1;
}

struct CorrectionT {
    int editDistance; //stackItems
    string suggestedWord; //stackItems
};

Some research:

  • The class library
  • An issue with the same class – suggested that the STL Set class is used, in this case I might still need help understanding how to define the comparison function, so posting question

I have 19 C2784 errors all relating to some form of “error C2784: ‘bool std::operator ==(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)’ : could not deduce template argument for ‘const std::_Tree<_Traits> &’ from ‘Lexicon::CorrectionT’

and referencing this code

template <typename Type>
int OperatorCmp(Type one, Type two) {
    if (one == two) return 0;
    if (one < two) return -1;
    return 1;
}

My question: how do you suggest correcting this?

Attempt at changing default definition type:

#include "lexicon.h"

//template <typename Type>
int OperatorCmp(Lexicon::CorrectionT one, Lexicon::CorrectionT two) {
    if (one.editDistance == two.editDistance) return 0;
    if (one.editDistance < two.editDistance) return -1;
    return 1;
}

#endif
  • 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-07T10:26:03+00:00Added an answer on June 7, 2026 at 10:26 am

    The comparison function for STL set must be a Strict Weak Ordering, so that class is not the same as an STL set.

    The error indicates the default OperatorCmp is being used, I don’t know why, but you could make that default one work by defining operator< and operator== for your CorrectionT type.

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

Sidebar

Related Questions

I'm using custom class that subclass from UILabel. It works fine unless I change
This question is kind of the next level of F# Set using custom class
I'm using a custom JsonpResult class that I found in my searching here on
We're using a custom class that uses XmlSchemaProviderAttribute in order to make it seem
I have a custom class that is basically a SortedList with a few extra
I have a class that implements IAuthorizationPolicy. I set up a custom Principal object
I want to set up data binding using a custom component. Basically, I'd like
I'm trying to set some custom AWS CloudWatch metrics using the Java SDK. I
I am using wordpress latest version. Currently my blog is set to custom permalink
I've set up a custom AlertDialog (actually, a custom TimePickerDialog). I'm using an OnShowListener,

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.