Results 1 to 13 of 13

Thread: Implicit sharing vs. c++ refereces

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Implicit sharing vs. c++ refereces

    I agree with last sentence. I was using stl containers for quite some time before I even saw the Qt hello world example, I loved Qt and the benefits of its container classes, but still I'm using const references to pass QStrings, QImages etc. even if I know that its not really needed. Thats ok if I had to work with "regular" container classes.
    But I really like the simplicity that comes with copy-on-write. If I had a choice, I think I'd use implicit shared containers instead of regular ones.
    adds code, memory and runtime overhead to your container classes
    Code overhead ? You can write code that manages implicit shared data once, and then reuse it for most of your containers.
    What do you mean with memory overhead, a pointer to data and integer counter ? I failed to see a big runtime overhead either.
    In the end, it's your design decision. If you are implementing a set of classes only for yourself, you are free to do whatever you want. But if you want other programmers to use it, I guess more people will enjoy your code if its easy to use - and I think implicit sharing guarantees it.
    Last edited by stampede; 9th November 2011 at 14:21. Reason: typo

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.