Hi,
I prepared a lenghty MWE which reproduces my problem with
type manipulation using MP11 that for some reason looses
const-qualification on a ::type result
Here it is at https://godbolt.org/z/eCsakP
and copied below.
I hope the XXXXXX comments make sense and important static
assertions in the main() at the bottom explain what
is the expected result.
```
#include
#include <cstdint>
#include
namespace mp11 = boost::mp11;
template
struct bit_range_reference { /* long definition, irrelevant */ };
template
struct bit_range_reference_type
{
using type = bit_range_reference
<
BitField, FirstBit::value, NumBits::value, true
> const; // XXXXXX Why this const gets lost with GCC 4.8 XXXXXX
};
template
class bit_range_reference_list
{
template
using reference_type = typename bit_range_reference_type
<
BitField, FirstBit, NumBits
>::type; // XXXXXX Should carry the const, shouldn't? GCC >4.8 do.
// If RangeBitSizes is mp11::mp_list_c
// then first_bit_list will be mp11::mp_list_c
using first_bit_list = mp11::mp_fold_q
<
RangeBitSizes,
mp11::mp_list>,
mp11::mp_bind
<
mp11::mp_push_back,
mp11::_1,
mp11::mp_bind
<
mp11::mp_plus,
mp11::mp_bind,
mp11::_2
>
>
>;
static_assert(mp11::mp_at_c::value == 0,
"first bit must be 0");
public:
using type = mp11::mp_transform
<
reference_type,
mp11::mp_pop_back,
RangeBitSizes
>;
};
using reference3_list = typename bit_range_reference_list
<
std::uint8_t,
mp11::mp_list_c
::type;
int main()
{
using r1_t = mp11::mp_at_c;
using r2_t = bit_range_reference;
using r2c_t= bit_range_reference const;
//#if defined(__GNUC__) && (__GNUC__ == 4)
// GCC 4.8 compiles, later versions of GCC fail to compile
static_assert(std::is_same::value,
"GCC says r1_t is const-qualified");
//#else
// GCC 4.9, 5, 6, 7, 8 versions compile, GCC 4.8 fail to compile
static_assert(std::is_same::value,
"GCC says r1_t is NOT const-qualified");
//#endif
}
```
To summary, I expect this to yield true:
std::is_same
<
mp11::mp_at_c
bit_range_reference const
I got this confirmed by all GCC versions but GCC 4.8.
(clang and MSVC also seem to agree with the GCC >= 4.9)
Is mp11::mp_transform loosing const-qualification
or have I made a mistake somewhere?
I'm using Boost.MP11 from Boost 1.70 and from current develop branch
Best regards,
--
Mateusz Loskot, http://mateusz.loskot.net