#include
template class CombineI;
template class CombineI {
public:
template
requires(i == I)
const T &get() const {
return data;
}
private:
T data;
};
template
class CombineI : public CombineI {
public:
using CombineI::get; // use the parent get member
template
requires(i == I)
const T &get() const {
return data;
}
private:
T data;
};
template class Combine : public CombineI {};
int main() {
Combine c;
c.get(); // works
c.get(); // works
c.get(); // does not compile, why? "No matching member function for call to 'get'"
}
< /code>
Я не понимаю, почему функция участника самого старого родителя в иерархии можно назвать c.get (); // работает
, но не члена родителя в середине иерархии c.get (); (
private: T data; }; template class Combine : public CombineI {};
int main() { Combine c; c.get(); // works c.get(); // works c.get(); // does not compile, why? "No matching member function for call to 'get'" } < /code> Я не понимаю, почему функция участника самого старого родителя в иерархии можно назвать c.get (); // работает [/code], но не члена родителя в середине иерархии c.get (); ([code]No matching member function for call to 'get'[/code]). Я компилируется с -std = c ++ 20 . может кто -нибудь это объяснить?
class cls { ... template bool func(...) { // Do something depending on } ... } I want to change func to be private and instead have only the relevant instantiations of func public, e.g something like...
Я пытаюсь использовать int member of a constexpr object as a template parameter. The idea is that I create a constexpr Symbol and then have that converted into a SymbolRef (in the real code that 1 is different for different objects).
template...
Есть ли другой путь, чем вручную перегружать соответствующую функцию члена, и вызов первой перегрузки с членом в качестве аргумента?class test
{
string t1= test ;
testfun( string& val = this->t1 )
{ /* modify val somehow */ }
};