Boost logo

Boost :

From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2020-04-02 15:54:13


On Mon, 30 Mar 2020 at 20:38, Mateusz Loskot <mateusz_at_[hidden]> wrote:
>
> image& operator=(image&& img)
> {
> if (this == std::addressof(img))
> return *this;
>
> auto const exchange_memory = [](image& lhs, image& rhs)
> {
> lhs._memory = boost::exchange(rhs._memory, nullptr);
> lhs._align_in_bytes = boost::exchange(rhs._align_in_bytes, 0);
> lhs._allocated_bytes = boost::exchange(rhs._allocated_bytes, 0);
> lhs._view = boost::exchange(rhs._view, image::view_t{});
> };
>
> constexpr bool pocma =
> std::allocator_traits<Alloc>::propagate_on_container_move_assignment::value;
> if (pocma)
> {

This obviously is not good as non-constexpr will require _Alloc::operator=
but there is no `if constexpr` in C++11 to discard instantiation.

Is there any BOOST_IF_CONSTEXPR magic for such a situation?
Since we are stuck at C++11, we can't use hana::eval_if
and looks like we only can do the old-school tag dispatching.

p.s. Sorry if my initial C++ question w/o strict reference to Boost
was off-topic,
or perhaps I made a non-commentable terrible C++ blunder :)

Best regards,

-- 
Mateusz Loskot, http://mateusz.loskot.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk