1

I have a class

class A : public B
{
public:
    // 1st copy assignment with parameter pack
    template<class Arg>
    A& operator=(Arg&& arg)
    {
        B::operator=(std::forward<Args>(arg));
        return *this;
    }

    // 2nd copy assignment with const A&
    A& operator=(const A& arg)
    {
        // some code
    }
};

The 2nd one is not called for the following

A a, b;
a = b;

How to make compiler call the 2nd one for the above code?

user1899020
  • 13,167
  • 21
  • 79
  • 154
  • 1
    What kind of an `operator=` takes anything other than exactly one parameter. Why do you need a parameter pack for the first `operator=`? Looks like you're looking for a solution in search of a problem. – Sam Varshavchik Feb 20 '20 at 02:18
  • @SamVarshavchikS you are right. I will edit it. – user1899020 Feb 20 '20 at 02:30

0 Answers0