mercredi 5 mai 2021

Specific implementation of a member function for when the instance is a rvalue? [duplicate]

In C++, I can provide an alternative implementation of a member function called when the instance is constant.

class Foo
{
  public:
    void bar();
    void bar() const;
};

Obvious !

My question is: In C++11, is it possible to provide an alternative implementation of a member function called when the instance is a rvalue ?

The context is the following: In a constant member function of a matrix class, I call a lapack function modifying the input array (lapack uses it as a working temporary array). Then, in my C++03 implementation, I duplicate the input array before giving it to lapack. But now in C++11, if my instance is a rvalue, I can accept that lapack destroys my data. In this case, I would like to provide an alternative implementation.

Aucun commentaire:

Enregistrer un commentaire