mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #108, added CContainerBase::to, for converting between different container types
This commit is contained in:
@@ -27,6 +27,18 @@ namespace BlackMisc
|
||||
class CContainerBase : public CValueObject
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Return a new container of a different type, containing the same elements as this one.
|
||||
* \tparam Other the type of the new container.
|
||||
* \param other an optional initial value for the new container; will be copied.
|
||||
*/
|
||||
template <template <class> class Other>
|
||||
Other<T> to(Other<T> other = Other<T>()) const
|
||||
{
|
||||
for (auto it = derived().cbegin(); it != derived().cend(); ++it) { other.push_back(*it); }
|
||||
return other;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return a copy containing only those elements for which a given predicate returns true.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user