struct base{ virtual ~base(){} virtual void foo(int&) = 0; virtual void foo(int&&) = delete;};
C++ (Qt) virtual void setParents(const parent& mother, const parent& father) noexcept = 0; virtual void setParents(const parent& mother, parent&& father) = delete; virtual void setParents(parent&& mother, const parent& father) = delete; virtual void setParents(parent&& mother, parent&& father) = delete;
C++ (Qt) virtual void setParents(gsl::not_null<const parent*> mother, gsl::not_null<const parent*> father) noexcept = 0;
node.setParents(mother, father);
node.setParents(&mother, &father);
#include <iostream>struct node{ virtual ~node(){} template<class parent1, class parent2> void setParents(parent1&& mother, parent2&& father) { static_assert( !::std::is_rvalue_reference<parent1&&>::value, "temporary objects 'mother' prohibited" ); static_assert( !::std::is_rvalue_reference<parent2&&>::value, "temporary objects 'father' prohibited" ); const auto& m = static_cast<const node&>(mother); const auto& f = static_cast<const node&>(father); this->setParents(m, f); } virtual void setParents(const node& mother, const node& father) = 0;};struct label: node{ virtual void setParents(const node&, const node&){}}; int main(){ label mother; label father; label child; node& example = child; example.setParents(mother, father);}
#include <iostream>struct node{ virtual ~node(){} template<class parent1, class parent2, dfor_lvalue(parent1), dfor_lvalue(parent2) > void setParents(parent1&& mother, parent2&& father) { const auto& m = static_cast<const node&>(mother); const auto& f = static_cast<const node&>(father); this->setParents(m, f); } virtual void setParents(const node& mother, const node& father) = 0;};struct label: node{ virtual void setParents(const node&, const node&){}}; int main(){ label mother; label father; label child; node& example = child; example.setParents(mother, father);}
#include <iostream>struct node{ virtual ~node(){} template<class p1, class p2> void setParents(lvalue<p1>& mother, lvalue<p2>& father) { const auto& m = static_cast<const node&>(mother); const auto& f = static_cast<const node&>(father); this->setParents(m, f); } virtual void setParents(const node& mother, const node& father) = 0;};struct label: node{ virtual void setParents(const node&, const node&){}}; int main(){ label mother; label father; label child; node& example = child; example.setParents(mother, father);}
virtual void setParents(const node&, const node&){}
struct node{ virtual ~node(){} virtual void setParents(const node& mother, const node& father) = 0;};
child getChild(){ parent mother("ma"); parent father("pa"); return child(mother, father);}