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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:37:00+00:00 2026-06-03T01:37:00+00:00

I’m tryin to use a custom container, and in that container’s constructor i pass

  • 0

I’m tryin to use a custom container, and in that container’s constructor i pass a memory pool allocator.
The whole thing starts like this:

AllocatorFactory alloc_fac;

//Creates a CPool allocator instance with the size of the Object class
IAllocator* object_alloc = alloc_fac.GetAllocator<CPool>(1000,sizeof(Object));
//Creates a CPool allocator instance with the size of the BList<Object> class
IAllocator* list_alloc = alloc_fac.GetAllocator<CPool>(10,sizeof(BList<Object>));
//Same logic in here as well
IAllocator* node_alloc = alloc_fac.GetAllocator<CPool>(1000,sizeof(BListNode<Object>));

The IAllocator class looks like this:

 class IAllocator
{

public:

    virtual void* allocate( size_t bytes ) = 0;
    virtual void deallocate( void* ptr ) = 0;

    template <typename T>
    T* make_new()
    { return new ( allocate( sizeof(T) ) ) T (); }

    template <typename T, typename Arg0>
    T* make_new( Arg0& arg0 )
    { return new ( allocate( sizeof(T) ) ) T ( arg0 ); }

            .......
}

And the container class’s constructor looks like this:

template <class T>
class BList {
......
public:
/**
 *@brief Constructor
 */
BList(Allocators::IAllocator& alloc){
     _alloc = alloc;
    reset();
    }
/**
 *@brief Constructor
 *@param inOther the original list
 */
 BList(const BList<T>& inOther){
    reset();
    append(inOther);
    }
.....
}

And when I do this:

 BList<Object> *list = list_alloc->make_new<BList<Object>>(node_alloc);

The compiler complains about this:

Error 1 error C2664: ‘Containers::BList::BList(Allocators::IAllocator &)’ : cannot convert parameter 1 from ‘Allocators::IAllocator *’ to ‘Allocators::IAllocator &’ c:\licenta\licenta-transfer_ro-02may-430722\licenta\framework\framework\iallocator.h 21 Framework

I think i went over my head with this one….

  • 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-06-03T01:37:02+00:00Added an answer on June 3, 2026 at 1:37 am

    The existing answers are correct, but a quick note on how to read the error yourself: you just have to split it into pieces …

    Error 1 error C2664: 'Containers::BList::BList(Allocators::IAllocator &)' : cannot convert parameter 1 from 'Allocators::IAllocator *' to 'Allocators::IAllocator &'
    

    reads:

    • you’re calling Containers::BList::BList(Allocators::IAllocator &), which is a constructor taking one argument, a reference to an IAllocator
    • cannot convert parameter 1 means the compiler is having trouble with the type of that first (and only) argument
      • you’ve given it this type: ... from 'Allocators::IAllocator *'
      • and it wanted this type (to match the constructor declaration): ... to 'Allocators::IAllocator &'

    so, how do you convert from the pointer you have to the reference the constructor wants?


    OK, I’ve added the actual answer as well:

    Allocators::IAllocator *node_alloc = // ...
    Allocators::IAllocator &node_alloc_ref = *node_alloc;
    BList<Object> *list = list_alloc->make_new<BList<Object>>(node_alloc_ref);
    

    or just:

    BList<Object> *list = list_alloc->make_new<BList<Object>>(*node_alloc);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:

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.