samedi 20 janvier 2018

Does 'const' disqualify universal reference?

I have a human class with ctor using universal reference

class Human {
 public:
  template<typename T>
  explicit Human(T&& rhs) {
    // do some initialization work
  }

  Human(const Human& rhs);  // the default ctor I don't care about
}

Now if I have a const Human object

const Human one_I_do_not_care; // then play with that
Human the_human_I_care(one_I_do_not_care)  // now create another one

Does the last line use the template ctor or the default ctor? My understanding is the "const" will disqualify the template ctor, am I correct?

Human the_human_I_care(one_I_do_not_care)  // line in question

Aucun commentaire:

Enregistrer un commentaire