back_inserter explained

back_inserter stl iterator class is an adapter class. So what is an adapter? If you buy a laptop in India and then take it to the US/Europe, plugs given won’t fit into the sockets there, so what we do is buy an adapter, which adapts our laptop’s plug to the sockets there. Adapter pattern based […]
Continue reading…

 

Dumping contents of a vector/list to cout

Is it possible to do this with just one line of code? Oh yes! Have a look… [sourcecode language=”cpp”]typedef int VT; typedef std::vector VTVec; void Dump( VTVec& VecToPrint, std::ostream& stream, const char* lpszMsg ) { // We will be wrapping every element within a square bracket. // In the end output looks like this… [123] […]
Continue reading…