Boost logo

Boost :

Subject: Default value of pixel channel (homogeneous_color_base)
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2019-03-01 00:38:20


Hi,

Is there any particular reason channel values of pixel, i.e. elements of
homogeneous_color_base [1] have indetermined value if default-constructed?

For example, AFAIU, because of essentially this [1]

struct homogeneous_color_base<Element,Layout,1> {
    Element _v0;
    homogeneous_color_base() {}
};

the following is not guaranteed, is it?

rgb8_pixel_t{} == rgb8_pixel_t{}

[2] "[if] they should be default constructible, they should initialize their
contents with some sensible values. If they decide that they should not be
default constructible, they should delete the constructors to avoid issues."

[1] https://github.com/boostorg/gil/blob/develop/include/boost/gil/color_base.hpp
[2] https://blog.tartanllama.xyz/initialization-is-bonkers/

Best regards,

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

Boost list run by Boost-Gil-Owners