Does it make sense to have a constexpr move constexpr ?
For example, consider the following:
#include <array> class C { public: constexpr C(std::array<int, 3> ar) : m_ar{ar} {} constexpr C(C&& other) : m_ar{std::move(other.m_ar)} { } private: std::array<int, 3> m_ar; }; int main() { constexpr C c1 {{{1, 2, 3}}}; constexpr C c2{std::move(c1)}; return 0; }
This does not compile because, despite calling std::move on c1 , the compiler infers that it needs to use the constructor (implicitly deleted), and not the move constructor. I'm not sure why.
But if I remove constexpr from c1 , then it will become unsuitable for the constexpr move constexpr .
Is there any way to make this work? Or this is a bad example for a constexpr displacement constexpr , but are there any good examples? Or is it just always wrong to have a constexpr move constexpr ?
Danra source share