473,419 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,419 developers and data experts.

to_wstring is not a member of std (A work-around) C++11

SwissProgrammer
220 128KB
Not .net anything.
Not Visual Studio anything.

In a C++11 program I intend to use Unicode and wstring and wchar_t. I am doing some bit parsing and bit manipulations for something and I want to have some results of that parsing in wstring or wchar_t. Thus, I want to put the 0's and 1's from some process into a wstring.

Example:
The Binary of [办] is [101001010011110].
I can input 办 and I can get 101001010011110.
I can parse into bits the 101001010011110 and do things with the result.
But,
I want to see the result in wstring.


Here is a test example:

If I used:
wstring x;
and if I tried to then use:
x = std::to_wstring(101001010011110);
I received an error similar to:
to_wstring is not a member of std
The problem seems to be in my compiler.
I do not want to change my compiler.

I chose that compiler for specific reasons and I intend to use that particular compiler. Therefore I needed a work around for going from a number (1010101010) to a wide string. In this case, the number is ASCII.

So, I am going from ASCII to a string to a wide string.

The following is an actual part of my code that does work.
With notes.

Expand|Select|Wrap|Line Numbers
  1.     int ix = 1010101010;
  2.     std::string f_str = std::to_string(ix);     // From int to wstring is not working with std::to_wstring on this compiler even though it is set to C++11
  3.                                                 //    therefore going from int to string then from string to wstring.
  4.     wstring wstr (f_str.begin(), f_str.end());  // Since it starts with an integer, which is in ASCII then
  5.                                                 //    since this only works well if the string being converted contains only ASCII characters
  6.                                                 // Therefore, it is OK to use here.
  7.  

A work around to get past "to_wstring is not a member of std" .
Dec 29 '20 #1
3 4317
weaknessforcats
9,208 Expert Mod 8TB
Where is your

#include <string>

?
Dec 29 '20 #2
SwissProgrammer
220 128KB
Thank you.

I might have pointed out, more clearly, that this post is about just a little part of the entire program where I changed it to work around a difficulty. With some explanations.

Mostly I wanted to post this since I had searched a lot for how to force a compiler to do as I desired even if it has difficulty and tells me "to_wstring is not a member of std". I looked and did not find any other satisfactory fix for that problem. This does not use "to_wstring". It works with my compiler (GNU GCC) that I received along with Code::Blocks 17.12, which I have been told does use "to_wstring" (which it seems to not use for me). But it works.

Elsewhere in the code is #include <string> along with lots of other stuff.

This is just a "part of my code" where I was talking about a change in it.

At your level of experience, I expect you to probably know a better way to fix this via code only (without changing my compiler). But, in my searching I did not find even this much of a way to fix this. So, here it is.

Thank you weaknessforcats.
Dec 30 '20 #3
SwissProgrammer
220 128KB
weaknessforcats,

Thank you.

I now realize that you were helping me in how to post usefully.

I gave you excuses.

I should have just said thank you and included the code in my post.
Jan 1 '21 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jeff | last post by:
/* -------------------------------------------------------------------------- Hello, I was experimenting with class templates and specializing member functions and came across a simple problem...
0
by: Shailesh | last post by:
If I'm not mistaken, C++ doesn't have support for dynamic class members. I'm considering if such a facility would be useful, and what method would make a good workaround. I have a generic...
6
by: Mike Alexeev | last post by:
What is the correct syntax for default values to member function templates? Here is my example: 1 struct A 2 { 3 typedef int typeA; 4 }; 5 6 struct...
7
by: Srini | last post by:
Hello, Rules for inline functions say that they have to be defined in the same compilation unit as their declarations. For class member functions this means that the inline member functions must...
4
by: Lionel B | last post by:
Greetings, The following code: <code> template<typename T> class A { protected:
5
by: Levent | last post by:
Hi, Why doesn't this work? (tried with gcc 3.3.3 and VC++ 7.1): #include <iostream> template<class T, unsigned N> struct Foo { void func(); }; template<class T, unsigned N>
9
by: tropostropos | last post by:
On Solaris, using the Sun compiler, I get annoying warnings from the following code. The problem is that I am passing a C++ member function pointer to the C library function qsort. Is there a...
4
by: Rubbrecht Philippe | last post by:
Hi there, I would like to develop an interface that when implemented in a class requires a number of shared properties or methods to be available. It seems a Shared Member can not be used as...
40
by: Steve Rencontre | last post by:
I can't for the life of me see how to do pointer-to-member when the member is actually part of an embedded structure. That is, if I have: struct S1 { int a; }; struct S2 { S1 s; int b; }; ...
5
by: =?Utf-8?B?SGVyYg==?= | last post by:
My long-running ASP application just stopped working today. I rebuilt and republished, but to no avail. The full error is: Server Error in '/NuclearDedication' Application....
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.