How to make_shared count times, with different areas allocated without recur to a loop?
I have the following code:
for( unsigned int count = 0; count < demandedSize; ++count )
{
m_connectionList.push_back( std::make_shared< Foo >( m_ip, m_port ));
}
How to shorten this without a loop?
I know std::vector receaves a second argument as const T&, but in that case all shared_ptr
s points to the same address (value is copied).
std::vector< std::shared_ptr<Foo> > vet( demandedSize, std::make_shared<Foo>( m_ip, m_port ) );
How to execute make_shared count times, with different areas allocated as result without recur to a loop
Aucun commentaire:
Enregistrer un commentaire