replaced "clone" with "derived" in CRTP (more usual, more flexible, more clear in its intent, and avoids copying the object twice on compilers that don't optimise return by value)

This commit is contained in:
Mathew Sutcliffe
2013-04-30 00:09:32 +01:00
parent ba70a150e0
commit a05b85135c
5 changed files with 55 additions and 29 deletions

View File

@@ -60,12 +60,21 @@ protected:
}
/*!
* \brief Polymorphic clone as concrete class
* \brief Easy access to derived class (CRTP template parameter)
* \return
*/
PQ clone() const
PQ const* derived() const
{
return static_cast<PQ const &>(*this);
return static_cast<PQ const *>(this);
}
/*!
* \brief Easy access to derived class (CRTP template parameter)
* \return
*/
PQ* derived()
{
return static_cast<PQ *>(this);
}
/*!