From: Andrew S. <ver...@ya...> - 2013-07-10 19:58:29
|
Hi Arbol, I suppose you could benchmark each method in a loop a few million times. You need to randomly select characters somehow otherwise the caching will kick in and reduce the execution time to almost zero if its the same string put through a "meatgrinder" so to speak. Copy constructors are slower to process compared to passing something by reference. I'm not sure if there is a way to pass std::string by reference though. I think this would be one way however void pass_string(std::string &STRING) { STRING = OTHER_STRING;//the OTHER_STRING is initialized to begin with } I'm not entirely sure if that would be truly by reference though. I don't think that would use a copy constructor. Best, Andrew Somorjai ________________________________ From: Arbol One <Arb...@ho...> To: MinGW <min...@li...> Sent: Wednesday, July 10, 2013 12:05 PM Subject: [Mingw-users] std::string The std::string has different ways to pass values from one string to another string, for instance, swap, assign, the equal operator and of course the copy constructor. Is there a benefit that one has over the other? TIA ------------------------------------------------------------------------------ See everything from the browser to the database with AppDynamics Get end-to-end visibility with application monitoring from AppDynamics Isolate bottlenecks and diagnose root cause in seconds. Start your free trial of AppDynamics Pro today! http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk _______________________________________________ MinGW-users mailing list Min...@li... This list observes the Etiquette found at http://www.mingw.org/Mailing_Lists. We ask that you be polite and do the same. Disregard for the list etiquette may cause your account to be moderated. _______________________________________________ You may change your MinGW Account Options or unsubscribe at: https://lists.sourceforge.net/lists/listinfo/mingw-users Also: mailto:min...@li...?subject=unsubscribe |