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 » Newbie corner » Error: use of deleted function ...
Error: use of deleted function ... [message #49205] Sun, 07 January 2018 15:48 Go to next message
idkfa46 is currently offline  idkfa46
Messages: 153
Registered: December 2011
Experienced Member
Dears,
I'm here back to you after long time without coding and without UPP Sad because I have to modify my little software

I just made the following steps:
-I re-installed UPP (latest Nightly builds from website);
-I set up my old assembly;
-I tryed to compile it (both debug/release mode);

but i receive the following errors:
C:\Users\Matteo\Dropbox\2_Sviluppo++\Workspace_upp\LibVerifi che\Layout.h (147): error: use of deleted function 'Relazione::RelazioneFormat& Relazione::RelazioneFormat::operator=(const Relazione::RelazioneFormat&)'
C:\Users\Matteo\Dropbox\2_Sviluppo++\Workspace_upp\LibVerifi che\Materiali.cpp (1): In file included from C:\Users\Matteo\Dropbox\2_Sviluppo++\Workspace_upp\LibVerifi che\Materiali.cpp:1:0:
C:\Users\Matteo\Dropbox\2_Sviluppo++\Workspace_upp\LibVerifi che\Layout.h (136): note: 'Relazione::RelazioneFormat& Relazione::RelazioneFormat::operator=(const Relazione::RelazioneFormat&)' is implicitly
deleted because the default definition would be ill-formed:
...

Can you help me to undestand what is happinging please?

here is the code about class Relazioni()

class Relazione {
public:
	class RelazioneFormat : public Moveable<RelazioneFormat> {
		public:
			String Titolo;
			String IconaTitolo;
			Vector<String> Corpo;
			RelazioneFormat();
	};
private:
	RelazioneFormat format;

public:
	Relazione &Clear() 			{ RelazioneFormat f; format = f; return *this;}
	Relazione &Titolo(String s = "")	{ format.Titolo = s; return *this; }
	Relazione &Icona(String s = "")		{ format.IconaTitolo = s; return *this; }
	Relazione &AddCorpo(String s = "")	{ format.Corpo.Add(s); return *this; }
	Relazione &NewLine()			{ format.Corpo.Add("&"); return *this; }

	String GeneraRelazione();

	typedef Relazione CLASSNAME;
	Relazione(){};
};


thank you and happy new year!

Regards,
Matteo
Re: Error: use of deleted function ... [message #49206 is a reply to message #49205] Sun, 07 January 2018 16:40 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 822
Registered: September 2012
Location: Poland, Kraków
Experienced Contributor
Hello,

It seems that the compiler cannot generate operator= for some reasons. The following solution should fix your compilation problem:
Relazione &Clear() 			{ f = {}; return *this;}

// or
Relazione &Clear() 			{ f = RelazioneFormat(); return *this;}


If I will know more about this issue I will let you know. It would be good if you will migrate your code base to English Smile However, I understand a lot from your current code.

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.

[Updated on: Sun, 07 January 2018 16:41]

Report message to a moderator

Re: Error: use of deleted function ... [message #49207 is a reply to message #49206] Sun, 07 January 2018 17:45 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 153
Registered: December 2011
Experienced Member
Hi Klugier and thanks for your reply.

Your solution can't work because 'f' was not declared in the scope.

I tryed the following option too but without success:
Relazione &Clear() 	{ RelazioneFormat f; format = f.RelazioneFormat(); return *this;}


The problem should be about 'format = f' but I really can not understand why... Sad

Regards,
Matteo
Re: Error: use of deleted function ... [message #49208 is a reply to message #49205] Sun, 07 January 2018 17:51 Go to previous messageGo to next message
Oblivion is currently offline  Oblivion
Messages: 827
Registered: August 2007
Experienced Contributor
Hello Matteo, and welcome!

Klugier has already proposed a solution, yet another solution and explanation is as follows:

The reason seems to be that the RelazioneFormat class (in C++11 and above) has a implicitly defined move constructor;

Solution is easy, use pick():

Relazione &Clear()			{ RelazioneFormat f; format = pick(f); return *this;}
                                                                      -------
                                                                         ^


It is all explained here:

http://en.cppreference.com/w/cpp/language/move_constructor


Best regards,
Oblivion


Re: Error: use of deleted function ... [message #49209 is a reply to message #49208] Sun, 07 January 2018 20:42 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 822
Registered: September 2012
Location: Poland, Kraków
Experienced Contributor
Hello,

Of course it should be:
Relazione &Clear() 			{ format = {}; return *this;}


Please read what "{}" means in c++11 if you are not familiar with this notation.

Declaring variable and picking it seems like over engineering here. We want simply reset variable to it's default state.

Sincerely,
Klugier


Ultimate++ - one framework to rule them all.

[Updated on: Sun, 07 January 2018 20:44]

Report message to a moderator

Re: Error: use of deleted function ... [message #49210 is a reply to message #49208] Sun, 07 January 2018 20:50 Go to previous messageGo to next message
idkfa46 is currently offline  idkfa46
Messages: 153
Registered: December 2011
Experienced Member
Thank you guys,
pick() function seams to be the right solution for me and the message error disappeared... btw, I have to read your link again because I didn't get the point at all yet!

If I understood well the problem is that now my build method is MINGW; if I go back to MSC9, the ones I used to build up the software, I should avoid this kind of error. Is it right?

In your opinion is better to update my code to the new methods? ...This error seems to be first of many many others! Smile

thanks,
Matteo


Re: Error: use of deleted function ... [message #49242 is a reply to message #49205] Wed, 10 January 2018 11:31 Go to previous message
idkfa46 is currently offline  idkfa46
Messages: 153
Registered: December 2011
Experienced Member
Thank you guys,
I understood it a bit more now and

Relazione &Clear() 		{ format = {}; return *this;}


should be the best solution for my case!

Regards,
Matteo
Previous Topic: Accessing Index structure elements
Next Topic: build methods
Goto Forum:
  


Current Time: Tue Jan 19 10:43:55 CET 2021

Total time taken to generate the page: 0.01578 seconds