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

  • SEARCH
  • Home
  • 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 6748681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:35:40+00:00 2026-05-26T12:35:40+00:00

In learning c++, I first use Qt library instead of the standard C++, STL

  • 0

In learning c++, I first use Qt library instead of the standard C++, STL and all that (Ok, so I’m new with c++ and spoiled by Qt). On Qt, QString used implicit sharing, thus enabling me to just copy assign it to another variable like:

QString var1=QString("Hi there!");
QString var2=var1

And that would do nicely without much overhead. But now, i’m trying std::string so, should I do

std::string var1=std::string()

or

std::string* var1=new std::string()

And also, how about QVector and std::vector. And If I do have to use the pointer… any tips?

  • 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-05-26T12:35:41+00:00Added an answer on May 26, 2026 at 12:35 pm

    Whether std::string uses copy-on-write depends on the implementation (i.e. your standard library vendor decides that). However, most std::string implementations will not use COW, largely due to the fact that most if not all read operations force a copy — operator[] returns a reference, c_str() and data() return a pointer. Compare this to QString::operator[], which returns a proxy object.

    In spite of the above, don’t use pointers to std::string, unless you determine (by measuring) that string copies are the bottleneck in your application.

    Also, beware that QString stores UTF-16 strings, whereas std::string stores a sequence of chars — QByteArray would be the Qt equivalent.

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

Sidebar

Related Questions

I used to use JavaBlackBelt a lot when I was first learning java, I
I remember first learning about vectors in the STL and after some time, I
When learning C# for the first time, I was astonished that they had no
I'm learning how to use Draggable Views for Drupal 6 for the first time,
I'm learning to use SIMD capabilities by re-writing my personal image processing library using
so I have a project that requires Weka machine learning library (weka.jar) and the
I'm a beginner programmer and I'm learning my first language, C. I'm learning mostly
Here is a problem I've struggled with ever since I first started learning object-oriented
When I first started reading about and learning ruby, I read something about the
I'm learning javascript and xhtml for the first time at the moment and I

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.