Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » MakeOne
Re: MakeOne [message #50054 is a reply to message #47662] Sat, 30 June 2018 14:45 Go to previous messageGo to previous message
Klugier is currently offline  Klugier
Messages: 1076
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

I have a problem with current MakeOne implementation. It doesn't work greate with auto:
One<Foo> CreateFoo() {
	auto pFoo = MakeOne<Foo>();
	
	int i = 0;
	if (i == 0) {
		return nullptr;
	}
	
	return pFoo; // Compilation error - /home/klugier/MyApps/MakeOneTest/MakeOneTest.cpp (19): error: use of deleted function 'Upp::One<T>::One(const Upp::One<T>&) [with T = Foo]'
}


The below example works as expected:
One<Foo> CreateFoo() {
	One<Foo> pFoo = MakeOne<Foo>();
	
	int i = 0;
	if (i == 0) {
		return nullptr;
	}
	
	return pFoo;
}


I am not sure it is the good design to limit it to only explicit types. std::make_shared and std::make_unique works in above case.

Sincerely,
Klugier


U++ - one framework to rule them all.

[Updated on: Sat, 30 June 2018 14:45]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Pdf signing
Next Topic: New verion of msbt2017 openssl library for win32
Goto Forum:
  


Current Time: Fri May 10 10:15:34 CEST 2024

Total time taken to generate the page: 0.02119 seconds