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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:14:02+00:00 2026-05-30T13:14:02+00:00

Pretty sure I know the answer to this one (thinking no), but could one

  • 0

Pretty sure I know the answer to this one (thinking no), but could one safely accept/return std::function by value in an API (across module boundaries)?

I’m thinking ‘no’ as I don’t think there are any guarantees that one vendor’s std::function implementation is compatible with the other’s. Is that the case?

If the answer is no as I suspect, how do you all deal with this kind of thing? I might have to resort to implementing my own or just avoid things like std::function all together (ex: work with function pointers or functionoids). 🙁 I’ve found myself doing that in many cases before (reinventing a lot of the standard C++ library and certainly regrettably as even making our own STL-compliant vector type with support for both range ctor and fill ctor, custom allocators, etc. was certainly not fun and I doubt it was as good as standard implementations) simply because one might dynamically link to a library that has, say, MSVC 2010’s implementation of std::function from a binary written in mingw, e.g.

The alternative, of course, is to not use these kinds of C++ features at all in our API and use, say, a C interface, but that would come at a rather heavy cost to us since we use our API as the central API for both internal and third party development.

  • 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-30T13:14:04+00:00Added an answer on May 30, 2026 at 1:14 pm

    You can do it, so long as everyone’s playing by the same rules, and your standard library is dynamically linked. If third-parties know that they must use a certain compiler, and a certain version of that compiler, with certain specific build flags, then there’s no problem.

    Even if you write your own wrapper, they have to use a specific version of that wrapper, though obviously that’s a bit easier to enforce.

    But really, that’s the price you pay for trying to inter-operate via DLLs: everyone has to be on the same page, or else it won’t work. Or you have to stick with basic types or home-grown, controlled interfaces.

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

Sidebar

Related Questions

I'm pretty sure I know the answer to this, but short of a virtual
So I'm pretty sure i already know the answer to this, but does the
OK, I'm pretty sure I know the answer to this but just in case.
Pretty sure there is an easy answer to this, but just can't find the
I'm pretty sure I already know the answer, but would like some confirmation... We
I'm pretty sure I know the answer but I'm wondering if there's a way
Pretty sure this question counts as blasphemy to most web 2.0 proponents, but I
I am pretty sure I have seen this before, but I haven't found out
I couldn't find an answer but I am pretty sure I am not the
I've run into a problem that I'm pretty sure I know the answer to,

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.