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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:49:23+00:00 2026-05-14T21:49:23+00:00

UPDATE: After some additional reading, what I really wanted was guaranteed early binding (which

  • 0

UPDATE: After some additional reading, what I really wanted was guaranteed early binding (which should translated to an immediate call for non-virtual functions and non-PIC code), which can be done by passing a (member) function as a template parameter. The problem I had was that gcc < 4.5 and icc 11.1 can generate some funky instructions for member function pointer template parameter calls. AFAICT, gcc >= 4,5 and vs2008 handle these template parameter calls fine.

First of all, maybe literals is not the right term for this concept, but its the closest I could think of (not literals in the sense of functions as first class citizens).

The idea is that when you make a conventional function call, it compiles to something like this:

callq <immediate address>

But if you make a function call using a function pointer, it compiles to something like this:

mov    <memory location>,%rax
callq  *%rax

Which is all well and good. However, what if I’m writing a template library that requires a callback of some sort with a specified argument list and the user of the library is expected to know what function they want to call at compile time? Then I would like to write my template to accept a function literal as a template parameter. So, similar to

template <int int_literal> 
struct my_template {...};` 

I’d like to write

template <func_literal_t func_literal>
struct my_template {...};

and have calls to func_literal within my_template compile to callq <immediate address>.

Is there a facility in C++ for this, or a work around to achieve the same effect? If not, why not (e.g. some cataclysmic side effects)? How about C++0x or another language?

  • 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-14T21:49:24+00:00Added an answer on May 14, 2026 at 9:49 pm

    If you use a function pointer type in your template and instantiate it with a fixed function, then the compiler should use a direct call for that function pointer call.

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

Sidebar

Related Questions

Update: After some more reading I see that this problem is totally general, you
Update: I updated this after doing some digging and realizing that this might be
Im trying to update the contents of an element after running some php code.
Is it possible to add some additional attributes to my components which are then
UPDATE: I've come across this question I did after some years: now I know
UPDATE: After searching a bit I don't seem to be alone about this problem:
UPDATE: After updating to stylus 0.7.4 and express 2.3.12 I can no longer reproduce
Update: After playing around with this for a few hours, went with a multi-query
Because of min time betwwen update it display the location update after 1 sec
Is it possible to update the same view with new data? Using UPDATE after

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.