473,289 Members | 1,923 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,289 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 4261
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
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.