[Rcpp-devel] Is the order of initializations within a data type defined?
Dirk Eddelbuettel
edd at debian.org
Wed Mar 24 20:47:35 CET 2010
On 24 March 2010 at 13:31, Douglas Bates wrote:
| I find myself writing code like
|
| Rcpp::NumericVector mu(arg);
| Rcpp::NumericVector eta(mu.size());
| ...
|
| because I need to ensure that mu is constructed from the argument SEXP
| before its size can be used to construct eta. Is the order of
| initializations compiler-dependent or defined by the standard? If
| defined by the standard I could write
|
| Rcpp::NumericVector mu(arg), eta(mu.size());
|
| and expect it to work as intended. Does anyone know if I can count on
| left-to-right ordering of initializations?
Interesting question, and I can't offer more than a firm 'not sure'. You
could for now put some of our conditional logging in the constructor as some
other classes (that take a string as well and then print that string, say) so
that you could at least test with the compiler you happen to using today.
Strictly personally speaking I quite like
Rcpp::NumericVector mu(arg);
Rcpp::NumericVector eta(mu.size());
as it gives me ample space to the right comment.
Dirk
--
Registration is open for the 2nd International conference R / Finance 2010
See http://www.RinFinance.com for details, and see you in Chicago in April!
More information about the Rcpp-devel
mailing list