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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:42:50+00:00 2026-05-20T11:42:50+00:00

I have the following map type… std::map<D3DXCOLOR, ID3DXMesh*> During compilation, xfunctional complains that it

  • 0

I have the following map type…

std::map<D3DXCOLOR, ID3DXMesh*>

During compilation, xfunctional complains that it cannot resolve an ambiguity regarding the key type;

error C2593: 'operator <' is ambiguous

The candidate operators detected by the compiler are as follows;

  1. built-in C++ operator<(DWORD, DWORD)
  2. built-in C++ operator<(FLOAT, FLOAT)
  3. built-in C++ operator<(D3DCOLORVALUE, D3DCOLORVALUE)

The D3DXCOLOR struct consists of 4 floats r, g, b, and a respectively but does not define a operator <. It does however provide cast functions for DWORD FLOAT and D3DCOLORVALUE, hence the entries in the candidate list.

I am contemplating the best way to resolve this problem. I could write my own inline operator for D3DXCOLOR, wrap the colour inside a new class which provides its own operator <, or is it possible to somehow hint to the compiler which implementation should be chosen from the list of candidates? The DWORD operator < would meet my requirements adequately.

  • 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-20T11:42:51+00:00Added an answer on May 20, 2026 at 11:42 am

    You have three options. Supposing for example that you want them compared as colorvalues:

    1) Define operator<:

    bool operator<(const D3DXCOLOR &lhs, const D3DXCOLOR &rhs) {
        return static_cast<D3DCOLORVALUE>(lhs) < static_cast<D3DCOLORVALUE>(rhs);
    }
    

    2) Specialize std::less:

    namespace std {
        template <>
        struct less<D3DXCOLOR> {
            bool operator()(const D3DXCOLOR &lhs, const D3DXCOLOR &rhs) {
                return static_cast<D3DCOLORVALUE>(lhs) < static_cast<D3DCOLORVALUE>(rhs);
            }
        };
    }
    

    3) Supply a third template parameter to your map – note that this changes the type of the map, so if you pass the map around a lot this might be inconvenient. But it expresses that the ordering is to be used only for this map, not as the canonical “correct” order of colors for any other purpose.

    struct mycomparator {
        bool operator()(const D3DXCOLOR &lhs, const D3DXCOLOR &rhs) {
            return static_cast<D3DCOLORVALUE>(lhs) < static_cast<D3DCOLORVALUE>(rhs);
        }    
    };
    
    std::map<D3DXCOLOR, ID3DXMesh*, mycomparator>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a route that looks like the following: map.newsletter '/newsletter', :controller => newsletter
I have a class in C++ with the following member: map< someEnum, vector<SomeObject*>* >
In my XUL I have the following code fragments: <map name=KeypadMap> <area href=javascript:pad('A') coords=1,1,31,31
I have a question about type casting. I have the following JSON String: {server:clients,method:whoIs,arguments:[hello]}
MetaMap files have following lines: mappings([map(-1000,[ev(-1000,'C0018017','Objective','Goals',[objective],[inpr],[[[1,1],[1,1],0]],yes,no)])]). The format is explained as mappings( [map(negated overall
I have a function that checks whether a type is a subtype of another
Supposing I have the following public class Foo { private Map<Integer,SomeObject> myMap; public Foo()
I have the following code: var src, flickrImages = []; $.ajax({ type: GET, url:
Having the following code, how can I have get receive a map, and return
I have the following stored procedure that I am trying to convert to a

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.