Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide an argument forwarding construct method in object_pool #22

Open
octopus-prime opened this issue Aug 18, 2018 · 4 comments
Open

Comments

@octopus-prime
Copy link

Given an actual compiler there should be a construct method in object_pool like

template<typename... Args>
element_type * construct(Args&&... args);

See https://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared

@jeking3
Copy link
Collaborator

jeking3 commented Aug 20, 2018

Pull requests with unit tests are welcome. :)

@octopus-prime
Copy link
Author

You still want to support C++03?
With C++11 the construct boiler-plate could be replaced by ONE method!

What kind of test do you mean? Something like

struct foo
{
	int i;
	double d;
	std::string s;
	foo* f;
};

void test_construct()
{
	boost::object_pool<foo> pool;
	auto element = pool.construct(1, 3.14, "bar", nullptr);
	BOOST_TEST_EQ(element->i, 1);
	BOOST_TEST_EQ(element->d, 3.14);
	BOOST_TEST_EQ(element->s, "bar");
	BOOST_TEST_EQ(element->f, nullptr);
}

@jeking3
Copy link
Collaborator

jeking3 commented Aug 29, 2018

Boost.Pool supports C++03 at this time, yes.

@jbherdman
Copy link

@jeking3 Can you have a look at my pull request to solve this issue? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants