Make `if` statements `constexpr` for flags known at compile time
I am trying to move-assign one container to the other:
void func(boost::container::deque<T>& deque1){
boost::container::deque<T> deque2;
// Fill deque2 with elements.
...
deque1 = std::move(deque2);
}
If T is neither move nor copy constructable, this code does not compile. However, it should and compiles for std containers, because it is possible to just pass memory ownership from deque2 to deque1 since their allocators are the same. The problem is that the choice between transferring resources or moving the elements one by one is written using ordinary if. The compiler generates the error when checking the second option even though it is not used. With if constexpr instead of if the statement is resolved at compile time and no error is generated.
I propose changing if statements for flags known at compile time to if constexpr using BOOST_IF_CONSTEXPR.