0

I am trying something which I would think is relatively simple but am at a loss how to do it. I have a function which as an argument takes a boost::numeric::ublas::vector, instead of having to declare the vector beforehand I want to be able to just declare it inside the function as rvalue, is this possible with boost::numeric::ublas::vector?

Now I do it like this

 boost::numeric::ublas::vector<double> point(3);
 point <<= 1, 2, 3;
 test(point);

I would like to do it something like this, which is possible for normal std::vectors with list initialization.

 test( {1,2,3} )

Is this possible or can't you do it with boost::numeric::ublas::vector this way?

D.J. Klomp
  • 2,429
  • 1
  • 15
  • 30

1 Answers1

1

Quoting from the uBLAS FAQ:

uBLAS is more than 10 years old and missed all new stuff from C++11.

So it seems unlikely that list initialization will be added.

If you need to use uBLAS and want list-initialization, I suggest implementing a helper function for that.

chtz
  • 17,329
  • 4
  • 26
  • 56
  • Thanks for your answer, I do not specifically want list initialization, I just want to be able to call a function with a boost vector as inline created rvalue in the function argument. – D.J. Klomp May 10 '17 at 12:48
  • Or are you saying that this can only be done via list-initialization, and so in principle cannot be done in older version of C++? – D.J. Klomp May 10 '17 at 12:50
  • I'd suggest writing a small helper function for that. [Here](http://stackoverflow.com/questions/27459318/how-to-create-a-nonempty-boost-ublasvector-inside-an-initializer-list) is an example how one can do it. – chtz May 10 '17 at 15:15