Ventacademy
  • Socials
  • Business Fundamentals
    • Investments
  • High Income Skills
  • Programming
  • Software Review
  • Website Development
    • WordPress
    • Search Engine Optimization
    • Free Templates and Plugins
      • Support
  • Finance
No Result
View All Result
Knowledge base
No Result
View All Result
Home Support

c++ – std::sort doesn’t work with custom value_type

admin by admin
January 30, 2021
Share on FacebookShare on Twitter


Closed. This question needs debugging details. It is not currently accepting answers.



Want to improve this question? Update the question so it’s on-topic for Stack Overflow.

Closed 36 mins ago.



I have custom C++ container class representing my table class (MyTable). Each row of such table has a wrapper class MyRow containing some private members and a pointer to the actual data buffer for this row, located inside some continuous buffer, that is property of MyTable.

I want to implement a sort method for MyTable using std::sort. I have defined my iterator class knowing to work with MyTable.

After testing my application, I noticed that the sort execution damages all data in the table overriding all rows with the data belonging to 1st row. After debugging this issue, I figured out, that the following pointer dereference operator is core of the problem:

MyRow& MyTableIterator::operator* () const;

When sort engine tries to swap data in 2 rows of MyTable, it introduces temporary variable of MyRow type. The problem is that MyRow is only wrapper class around actual data, and 2 cloned MyRow objects simply point to the same data. As result, the swap is not working.

My questing is what can I do in this case? Is it possible to overcome my problem and still to use std::sort or do I need to implement my own sort method?

admin

admin

Related Posts

c++ – Is the std::function object itself thread safe? If no, what ways can I make it thread safe?

April 21, 2021

c++ – Why do STL algorithms require two iterators explicitly?

April 21, 2021

c++ – Can insert into vector Out of order?

April 21, 2021

c++ – Sorting the std::list of structures by rule

April 21, 2021
Next Post

I Married My Daughter, Fathered Two Kids With Her, While My Dad Married Her Mum - Family

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended.

Gunmen Abduct Rivers Councillor, Demand N50m From Family

December 29, 2020

WP User Frontend Pro 3.4.5 – Ultimate Frontend Solution For WordPress

January 23, 2021

Subscribe.

Trending.

No Content Available

About Us

Knowledge base

We bring you the best technology news, Finance news and lots more. you can download premium themes, plugins scripts, courses and lots more here.

Follow Us

Categories

  • All
  • Books
  • Business Fundamentals
  • Finance
  • Free Course
  • Free download
  • Free Templates and Plugins
  • Health
  • High Income Skills
  • Investments
  • NSFW
  • Photography
  • Search Engine Optimization
  • Software Review
  • Support
  • Technical Analysis
  • Website Development
  • Wordpress
  • World

Activity

FREEDOWNLOAD

Profile Builder Pro 3.4.3 Nulled – Profile Plugin for WordPress

Automatically generates native code for adding splash screens in Android and iOS

Vikinger 1.5.1 – BuddyPress and GamiPress Social Community

EduMall 2.7.1 – Professional LMS Education Center WordPress Theme

Admin Columns Pro – BuddyPress Addon 1.5.1

Microsoft Dynamics AX 2012 R3 Programming – Level 3 – Download Udemy Courses For Free

YITH Deals for WooCommerce Premium 1.0.21

Front End Web Design UX, CSS, FLEXBOX & SASS Complete Course – Download Udemy Courses For Free

Learn Python 3 programming | Become job ready using Pycharm – Download Udemy Courses For Free

Oxygen 5.9 – WooCommerce WordPress Theme

Preston 1.2.1 – Real Estate WordPress Theme

Support Board 3.2.4 – WordPress Chat Plugin

YITH WooCommerce Customize My Account Page 3.1.1 Nulled

YITH Cost of Goods for WooCommerce 1.2.13 Nulled

BoomBox 2.7.7 Nulled – Viral Magazine WordPress Theme

  • Socials
  • About
  • Advertise
  • Privacy & Policy
  • Contact

© 2020 Ventacademy

No Result
View All Result
  • Socials
  • Business Fundamentals
    • Investments
  • High Income Skills
  • Programming
  • Software Review
  • Website Development
    • WordPress
    • Search Engine Optimization
    • Free Templates and Plugins
      • Support

© 2020 Ventacademy