Overview
Features
Download
Documentation
Community
Add-Ons & Services

difference between use and useRef in Poco::Data [solved]

Please post support and help requests here.

difference between use and useRef in Poco::Data [solved]

Postby mkaut » 09 Jan 2013, 10:50

Hello,

could someone try to explain the difference between use and useRef in Poco::Data, please?
In particular, I would like to know what is the difference in what they do, their speed, and also what is the difference between them when used (a) in statements that are executed immediately and (b) statements that are stored and then used repeatedly (while changing the values in the data pointed to).

Thanks a lot in advance.
Last edited by mkaut on 11 Jan 2013, 15:41, edited 1 time in total.
mkaut
 
Posts: 19
Joined: 17 Oct 2012, 15:22

Re: difference between use and useRef in Poco::Data

Postby alex » 11 Jan 2013, 05:09

There is no difference in performance between the two. The only difference is that use() does not allow passing in const reference and prevents compilation of such attempt. Reason being, const references are often passed to functions and are forwarded to use() but statement is executed at some later point in time when passed reference does not exist anymore. We've got bitten sufficient number of times long time ago that we decided to prohibit it and allow passing const refs through more obvious useRef(). I've been considering removal of this safety net for some time, not quite sure whether it's worth it - this is C++ after all. Will probably re-think it in the context of C++11.
alex
 
Posts: 1105
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: difference between use and useRef in Poco::Data

Postby mkaut » 11 Jan 2013, 15:41

Thanks a lot for the explanation. :-)
mkaut
 
Posts: 19
Joined: 17 Oct 2012, 15:22


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron