local type in template - C2918



Could anyone please explain why a function object used in for_each or other
algorithms cannot be a local type? Sometimes performing an operation on
elements of a container only applies to one function and it would be nice to
do

CDeveloperEnvironment::CVariables::~CVariables()
{
struct Delete
{
void operator()(Developer::Types::VARIABLEMAP::value_type& vt){delete
vt.second ;}
};
std::for_each(m_mapVariables.begin(), m_mapVariables.end(), Delete()) ;
}

TIA
Priyesh.


.


Loading