https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116366
Bug ID: 116366
Summary: the const specifier is dropped when using member
object as template parameter
Product: gcc
Version: 14.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: niqingliang2003 at gmail dot com
Target Milestone: ---
Created attachment 58929
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58929&action=edit
test code
when using member object as template parameter, the const of function parameter
is dropped when deducing function prototype.
error: no matches converting function ‘set_mem’ to type ‘void (struct test::*
const)(int&)’
#include <type_traits>
struct test {
int x;
template<auto test::* M>
using mem_type = decltype(std::declval<test>().*M);
template<auto test::* M, typename T = mem_type<M>>
void set_mem(const T& v)
{
this->*M = v;
}
};
static constexpr auto p = &test::set_mem<&test::x>;