Привет всем,
нужно сделать что-то типа такого:
template<class Container, typename T>
class CContainerP
{
Container m_c;
public:
template<typename TpRefValue, class fieldName>
bool findElement(TpRefValue &refValue, const T* &elem) const
{
for (auto it = m_c.begin(); it != m_c.end(); ++it)
{
auto element = *it;
if (element ->fieldName == refValue)
{
elem = element;
return true;
}
}
return false;
}
};
int main()
{
CContainerP<std::vector<Test*>, Test> o;
int iRef = 0;
const Test *p = nullptr;
bool bFound = o.findElement(iRef, p);// не компилируется
return 0;
}
понятно что тут еще деструктор CContainerP нужен чтобы разрушать элементы...
Как?