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 » errors re strings
errors re strings [message #46364] Fri, 29 April 2016 08:46 Go to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
(647): error C2664: 'std::basic_string<char,std::char_traits<char>,std::allocator <char>>::basic_string(std::initializer_list<_Elem>,const std::allocator<ch
ar> &)': cannot convert argument 1 from 'Upp::String' to 'const std::basic_string<char,std::char_traits<char>,std::allocator <char>> &'


A previous topic similar to this error was only when compiling with MINGW

This error is when recompiling an older app with upp 7901 and even with MSC15

Has the changes that causes this with C++11? or was this changes in the upp code?

Do I need to change all the 'string' to upp::String or is there an easier way ??
There are several apps that I may run into with this error as they are updated from a few years back.

here are a few lines of code:
line 647 string Min (Tm, 2,2);
string Sec (Tm, 4,2);
String Tmz = Hr + ":" + Min + ":" + Sec;
count<<=Tmz;


Neil

[Updated on: Fri, 29 April 2016 09:01]

Report message to a moderator

Re: errors re strings [message #46365 is a reply to message #46364] Fri, 29 April 2016 10:44 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
std::string and Upp::String are two completely different classes.

So the question is, why do you even use std::string in U++ application (or the other way around, why don't you stick solely to std::string, if you want to keep usage of U++ low and having that part of source usable without U++ Core too).

If your app is strongly U++ dependent, I would go for Upp::String only (except places where you call some external library, which has input as std::string, at that single point I would convert the String to string, but otherwise I would keep internally everything in String).

I often write clean C++ libraries in TheIDE (to be compiled on phone platforms, so I don't use Upp at all), then I use std::string only.

Your mixed way is certainly possible too, but I think it's not giving you any advantage, just confusing.
Re: errors re strings [message #46366 is a reply to message #46364] Fri, 29 April 2016 10:59 Go to previous messageGo to next message
omari is currently offline  omari
Messages: 264
Registered: March 2010
Experienced Member
Hi,

the conversion from Upp::String to std::string is explicit by the function member ToStd()
String s_upp;
std::string s_std = s_upp.ToStd();

IMO the easier way is to avoid std::string, Upp::String is simpler, faster.

here a solution for this error:
String Min = Tm.Mid(2,2);
String Tmz = Hr + ":" + Min + ":" + Tm.Mid(4,2);
count<<=Tmz;


regards
omari.
Re: errors re strings - SOLVED [message #46367 is a reply to message #46365] Fri, 29 April 2016 13:24 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Hi mr ped thanks I did not know there was such a difference and that mixing them could lead to errors,
Most of my apps depend on several header .h 'apps' so I will try and remember what could cause problems.
I have no preference for which string or String, whatever works but I will try to use just one.



mr_ped wrote on Fri, 29 April 2016 01:44
std::string and Upp::String are two completely different classes.

So the question is, why do you even use std::string in U++ application (or the other way around, why don't you stick solely to std::string, if you want to keep usage of U++ low and having that part of source usable without U++ Core too).

If your app is strongly U++ dependent, I would go for Upp::String only (except places where you call some external library, which has input as std::string, at that single point I would convert the String to string, but otherwise I would keep internally everything in String).

I often write clean C++ libraries in TheIDE (to be compiled on phone platforms, so I don't use Upp at all), then I use std::string only.

Your mixed way is certainly possible too, but I think it's not giving you any advantage, just confusing.


Neil

[Updated on: Thu, 05 May 2016 09:30]

Report message to a moderator

Re: errors re strings - [message #46368 is a reply to message #46366] Fri, 29 April 2016 13:33 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
omari wrote on Fri, 29 April 2016 01:59
Hi,

the conversion from Upp::String to std::string is explicit by the function member ToStd()
String s_upp;
std::string s_std = s_upp.ToStd();

IMO the easier way is to avoid std::string, Upp::String is simpler, faster.

here a solution for this error:
String Min = Tm.Mid(2,2);
String Tmz = Hr + ":" + Min + ":" + Tm.Mid(4,2);
count<<=Tmz;




Hi Omari Thanks Your solution code worked first time and I appreciate the explanation, that is how I learn the most, code that works and then the reason behind it.

Neil

[Updated on: Wed, 25 May 2016 12:02]

Report message to a moderator

Re: errors re strings again or still [message #46552 is a reply to message #46364] Wed, 25 May 2016 12:29 Go to previous messageGo to next message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
I am still getting errors this time when compiling with MS15 or MINGW

Under upp 9701 it compiles OK with either compiler.
Under upp 9801 or 9861 it does not and I get
: error C2676: binary '<<=': 'Upp::String' does not define this operator or a conversion to a type acceptable to the predefined operator

ln<<= GGA2decAng(ln);

Re: errors re strings again or still [message #46554 is a reply to message #46552] Wed, 25 May 2016 21:56 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi,

Quote:

I am still getting errors this time when compiling with MS15 or MINGW

Under upp 9701 it compiles OK with either compiler.
Under upp 9801 or 9861 it does not and I get
: error C2676: binary '<<=': 'Upp::String' does not define this operator or a conversion to a type acceptable to the predefined operator

ln<<= GGA2decAng(ln);


Normally
ln<<GGA2decAng(ln);

should solve your problem

Regards

Biobytes


Re: errors re strings again or still [message #46555 is a reply to message #46554] Wed, 25 May 2016 23:45 Go to previous message
nlneilson is currently offline  nlneilson
Messages: 644
Registered: January 2010
Location: U.S. California. Mojave &...
Contributor
Thanks Biobytes

Just deleting the '=' character got rid of the error
Previous Topic: gui , how to switch between the visual dlg.lay to the text view
Next Topic: Network remote control
Goto Forum:
  


Current Time: Fri Mar 29 00:20:17 CET 2024

Total time taken to generate the page: 0.00988 seconds