Quick A: With a lambda function. Try const mytype myobj{ []{ /* compute value */ return value; } }
.
How would you initialize a const vector of function results using C++11?
Is it possible to use something like
generate_n
to create aconst vector
of, say, random numbers? I couldn't think of a way to do it without derivingvector
and doing the assignment in the constructor.
Add a Comment
Comments are closed.