
1 Mar
2007
1 Mar
'07
2:56 p.m.
shunsuke wrote:
Thorsten Ottosen wrote:
Only for random access iterators. std::size() would only accept random access iterators.
Hmm, when should I use 'std::size'? Whenever the argument is known to be RandomAccessRange, the 'std::distance' is known to be O(1) complexity. Thus, I will always use 'std::distance'. (I actually replaced all the 'boost::size' in my codes by 'boost::distance'.)
Right, but size() adds a compile time check to that. Of course, you may get that with a concept check in the beginning too. -Thorsten