>> Imagine the simplest case when the iterator is simply a pointer
>> internally. Moving a pointer has the same cost on todays CPUs
>> than a bool.
> I understand that imagination was ground to your shallow claim.
> But fruits of imagination are better dismissed in engineering.
You're arrogant and stupid.
Look at this code:
#include <unordered_map>
#include <utility>
using namespace std;
using umi_t = unordered_map<int, int>;
using umi_it = umi_t::iterator;
pair<umi_it, bool> f123( umi_t &um )
{
return pair<umi_it, bool>( um.begin(), true );
}
umi_it f456( umi_t &um )
{
return um.begin();
}
This results in this:
.file "x.cpp"
.text
.p2align 4,,15
.globl
_Z4f123RSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE
.type
_Z4f123RSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE,
@function
_Z4f123RSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE:
.LFB1603:
.cfi_startproc
movq 16(%rdi), %rax
movl $1, %edx
ret
.cfi_endproc
.LFE1603:
.size
_Z4f123RSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE,
.-_Z4f123RSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE
.p2align 4,,15
.globl
_Z4f456RSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE
.type
_Z4f456RSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE,
@function
_Z4f456RSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE:
.LFB1621:
.cfi_startproc
movq 16(%rdi), %rax
ret
.cfi_endproc
.LFE1621:
.size
_Z4f456RSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE,
.-_Z4f456RSt13unordered_mapIiiSt4hashIiESt8equal_toIiESaISt4pairIKiiEEE
.ident "GCC: (Debian 6.3.0-18+deb9u1) 6.3.0 20170516"
.section .note.GNU-stack,"",@progbits
So the difference is just one move as I told.
And as you can see from the abvove, an iterator is just a pointer
for this container. And passing a hint-iterator would be just an
additional move. So the additional bool is outweight by the hint.