https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125096
Bug ID: 125096
Summary: [reflection] Const disappears during some reflection
programming
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: barry.revzin at gmail dot com
Target Milestone: ---
Reduced example from a library I'm working on:
#include <meta>
#include <vector>
namespace ctp {
template <class T> struct Reflect;
namespace impl {
template <class T> using custom_target = Reflect<T>::target_type;
}
template <class T>
using target = [: is_scalar_type(^^T) ? ^^T :
substitute(^^impl::custom_target, {^^T}) :];
template <class T>
struct Reflect<std::vector<T>> {
using underlying = target<T> const;
using target_type = std::span<target<T> const>;
};
}
static_assert(dealias(^^ctp::target<int>) == ^^int); // yes
static_assert(dealias(^^ctp::target<std::vector<int>>) == ^^std::span<int
const>); // no
static_assert(dealias(^^ctp::Reflect<std::vector<int>>::underlying) == ^^int
const); // yes
static_assert(dealias(^^ctp::Reflect<std::vector<int>>::target_type) ==
^^std::span<int const>); // no
gcc agrees that `ctp::target<int>` is `int` and
`ctp::Reflect<std::vector<int>>::underlying` is `int const`.
Nevertheless, gcc thinks `ctp::Reflect<std::vector<int>>::target_type` is
`std::span<int>` instead of `std::span<int const>`. Where did the `const` go?