[optional] move constructor of Std::optional<const T>
The following code does not compile:
Dune::Std::optional<const int> o(42);
Dune::Std::optional<const int> p(std::move(o));
giving the message:
/home/nils/workbench/dune-devel/dune-common/dune/common/std/optional.hh:145:11: error: invalid conversion from ‘const void*’ to ‘void*’ [-fpermissive]
new( &value_ ) value_type( std::move( other.value_ ) );
Is that expected?
For my understanding the value in p
should by initialized with std::move(*o)
. Also with std::optional
in C++17 it works:
http://coliru.stacked-crooked.com/a/ffd377cbcc33c3fc
You can find a corresponding test here: https://gitlab.dune-project.org/nils.dreier/dune-common/commits/move_optional_of_const