c++ - Iterator over a unique element without construction a container -


i have framework has requires input iterator. sometime, have single element, constructing container seems work.

t obj; // unique object  std::vector<t> vec; // want avoid vec.push_back(t);  // because use of container call call(std::begin(vec), std::end(vec));  // want call(beginfakesingletonit<t>(obj), endfakesingletonit<t>()); 

i create special type of iterator, doesn't exist in standard library or boost?

a single element can thought of array of size one. if use pointer object pointer(iterator) start of array , pointer 1 past end of array pointer incremented once. can use

call(&object, &object + 1) 

and process single object.


Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

c# - Update a combobox from a presenter (MVP) -

android - Unable to generate FCM token from dynamically instantiated Firebase -