Код: Выделить всё
template
class PtrC {
public:
constexpr PtrC(const T* const p) : ptr{p} {}
constexpr auto getMutable() requires(not IsConst) {
return const_cast(ptr);
}
public:
const T* ptr;
};
template
PtrC(T* const) -> PtrC;
template
PtrC(const T* const) -> PtrC;
template
using Ptr2PtrC = PtrC;
auto main() -> int {
Ptr2PtrC ptr2ptrc{new int* const{nullptr}};
}
Код: Выделить всё
error: ambiguous deduction for template arguments of 'Ptr2PtrC' 22 | Ptr2PtrC ptr2ptrc{new int*const{nullptr}};- Какое правильное решение и почему?
- Как работает CTAD для второго параметра шаблона — Const в моем случае?
- Как трансформируются направляющие вывода для шаблона псевдонима?
Подробнее здесь: https://stackoverflow.com/questions/798 ... s-template