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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:00:28+00:00 2026-05-12T16:00:28+00:00

According to Sergey Ryazanov, his Impossibly Fast C++ Delegates are not comparable: My delegates

  • 0

According to Sergey Ryazanov, his Impossibly Fast C++ Delegates are not comparable:

My delegates cannot be compared. Comparison operators are not defined because a delegate doesn’t contain a pointer to method. Pointer to a stub function can be different in various compilation units.

To which one the readers have replied:

“Pointer to a stub function can be different in various compilation units.”
AFAIK, this is not true. Compilers are required to re-use template functions generated in different compilation units (this I am sure of – but I think Borland once violated this rule). I think it is because classes (ones not in ‘nameless’ namespaces) use external linkage and the way you use the stub functions will always prevent them from being inlined (although this shouldn’t be an issue either as taking the address of the function will force a non-inline version to be generated and ‘external linkage’ performed by the linker will eliminate all but one similarly named function (they are assumed and required to be identical by the standard))…

If you define a template function one translation unit (cpp file) and then define the same function differently in another translation unit, only one of the two versions will make it into the final executable. (This actually violates the “One Definition Rule”, but works on GCC, at least… not sure about MSVC.) The point is: the address [of the stub] will be the same in different units.

I would urge you to update the article (including comparison capability) if you find this to be true for MSVC – if MSVC is standards conferment, in this regard.

Now the article is four years old and the author hasn’t replied to any of the comments during the past three years or so, so I’m wondering if there’s any merit to the above comment and whether this specific implementation can indeed be changed to support comparisons.

Does the C++ standard specifically prohibit such usage and if so, are any of the recent compilers actually standard-compliant in that regard?

  • 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-12T16:00:28+00:00Added an answer on May 12, 2026 at 4:00 pm

    The code is both standard compliant, and fine. I don’t see any place where he violates ODR, and it is true that all instantiations of a function template with the same template parameters should have “the same address” (in a sense that pointers to functions should all be equal) – how this is achieved is not important. ISO C++03 14.5.5.1[temp.over.link] describes the rules in more detail.

    So, a comparison could well be defined there in a conformant and portable way.

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

Sidebar

Related Questions

According to Firebug console, we have the following in JavaScript: >>> [''] == ''
According to PHP, locale information is maintained per process. Is my understanding correct that
According to Apple's website, the iPhone 4 is 960-by-640-pixel resolution at 326 ppi. I
According to MSDN, System.Int32 is immutable, and its members always return new instances. Some
According to a post at the very end of this thread you can replace
According to http://www.storytotell.org/blog/2008/11/14/literal-tables-and-updates-with-joins-in-sql.html the following is valid: SELECT * FROM VALUES ('Lisp', 50, true),
According to this SDK guide , unit-testing a Library project can be achieved by
According to Single-Threaded Application with Long-Running Calculation MSDN example, there is a possibility of
According to the MSDN documentation , transactional NTFS doesn't seem to allow one to
According to the information I could gather on .NET and Java execution environment, the

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.