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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:32:53+00:00 2026-05-19T12:32:53+00:00

I have a function with a signature void Foo(list<const A*>) and I want to

  • 0

I have a function with a signature

void Foo(list<const A*>)

and I want to pass it a

list<A*>

How do I do this?
(plz note – the list isn’t constant, only the member of the list)

  • 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-19T12:32:54+00:00Added an answer on May 19, 2026 at 12:32 pm

    The problem you have is that even though T * can be implicitly converted to a T const *, the template system isn’t “aware” of that, so a whatever<T *> and whatever<T const *> are completely unrelated types, and there’s no implicit conversion from one to the other.

    To avoid the problem, I’d probably avoid passing a collection at all. Instead I’d have the function take a pair of iterators. A list<A *>::iterator can be implicitly converted to a list<A *>::const_iterator. For that matter, I’d probably make the function a template, so it can take iterators of arbitrary type.

    This is likely to save you quite a bit of trouble — a list is only rarely a good choice of container, so there’s a very large chance that someday you’ll want to change from list<A *> to vector<A *> or perhaps deque<A *> — and if you make your function generic, you’ll be able to do that without rewriting the function at all.

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

Sidebar

Related Questions

I have function whose signature is something like so: void someFunc(ifstream ifile) { This
I have this function signature I have to match typedef int (*lua_CFunction) (lua_State *L);//target
In AS3 you have a function on a string with this signature: function replace(pattern:*,
Say I have : class Foo { public: Foo(std::function< void(std::shared_ptr< Foo >) > callback);
Let's say I have the following signature: static extern void External(int foo, IntPtr bar);
I have a function with following signature char requestApiCall(int num, const wchar_t* pParams =
I have to store a list of different boost::function objects. To provide this I'm
I have a function with the same name, but with different signature in a
I have a C function with the following signature: int my_function(int n, struct player
Let's say we have a method signature like public static function explodeDn($dn, array &$keys

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.