Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7794197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:42:43+00:00 2026-06-01T22:42:43+00:00

There are many object of std::wstring created in my program as, std::wstring mystr(Ltest string);

  • 0

There are many object of std::wstring created in my program as,

std::wstring mystr(L"test string");

As the input wchar string is string constant, it would save some heap usage if mystr is constructed as mystr.c_str() equals to the address of L”test string”. Is it possible to construct such wstring?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T22:42:45+00:00Added an answer on June 1, 2026 at 10:42 pm

    There are indeed valid use-cases for this but the C++ string class flat out doesn’t support it. If you really need it you are required to write your own string class which supports interning.

    Note that several other languages support this natively; the C++ string classes unfortunately cover a rather specific use-case (lots of modifications) instead of the general one (lots of copies of essentially immutable strings).

    To simplify the task, consider whether it’s enough for you to use a thin wrapper class around a pair of (const) iterators which could just point to the beginning and end of the wchar_t buffer in static memory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are many ways of converting a String to an Integer object. Which is
There are many Cocoa methods that require an NSError object as a parameter to
I have an object with a std::string field notes that allows a maximum of
I am reading existing code. I noticed that there are many data object files
I've got a function that returns a std::string object. I'm working with Cocoa/CoreGraphics and
While there are many guides for Browser Helper Objects, i have a hard time
There are many ASP.MVC blog post bits and pieces scattered over different web sites,
There are many ways of doing debugging, using a debugger is one, but the
There are many techniques to enforce strong passwords on website: Requesting that passwords pass
There are many tools out there for writing and managing requirements, but are there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.