[Rcpp-devel] Is the order of initializations within a data type defined?

Douglas Bates bates at stat.wisc.edu
Wed Mar 24 19:31:37 CET 2010


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?

Yes, I realize that I could circumvent the problem of long class names
like Rcpp::NumericVector with typedefs and
using namespace Rcpp;
but I think it improves readability to use the names defined by Rcpp
and I haven't yet sorted out the ramifications of using namespaces,
especially multiple namespaces.


More information about the Rcpp-devel mailing list