« first day (2146 days earlier)      last day (698 days later) » 

1:26 AM
@PeterT Then a question arises, how std::string::operator== is implemented? By comparing byte one by one?Or by comparing hash?
I understand why the outputs of the two different hash functions are same now. Becasue `hash_value ^= ((hasher(*itr))<<1);` is just left shift each hash value of the string other than the `hash_value` itself. It's different from ` hash_value ^= (hasher(*itr));
hash_value <<=1;`
 
 
3 hours later…
4:53 AM
string comparison is effectively byte-for-byte. I mean you first check if they're the same size and only if they are you probably run strcmp on it and that's probably guaranteed to be optimized on your platform, with SIMD and whatnot
Didn't ARM8 get like an optional instruction set extension that was essentially just strcmp
 
 
6 hours later…
10:29 AM
hi all, having recently started using lambdas I have some problems. If anyone want to help I can't understand why in this line: if(find_if(C1.begin()+i, C1.end(), [&](int x){return x==C2[k];})) the compiler tells me he can't convert lambda to bool, i'll send the complete error message. And if the complete part of the code is necessary tell me. Thanks a lot
error: could not convert ‘std::find_if<__gnu_cxx::__normal_iterator<int*, std::vector<int> >, Population::crossover(Chromosome&, Chromosome&)::<lambda(int)> >((& C1)->std::vector<int>::begin().__gnu_cxx::__normal_iterator<int*, std::vector<int> >::operator+(((__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)i)), (& C1)->std::vector<int>::end(), <lambda closure object>Population::crossover(Chromosome&, Chromosome&)::<lambda(int)>{(* & C2), k})’ from ‘__gnu_cxx::__normal_iterator<int*, std::vector<int> >’ to ‘bool’
 
11:23 AM
2 messages moved from Lounge<C++>
 
 
2 hours later…
12:58 PM
@Ratman it doesn't say that it can't convert the lambda to bool, it says that it can't convert the iterator to bool
you probably meant if(C1.end() != find_if(C1.begin()+i, C1.end(), [&](int x){return x==C2[k];}))
 
1:30 PM
@PeterT yes thanks a lot, I trusted my memory thinking find_if should return a bool, instead returns the iterator, thanks a lot.
 
that would be std::any_of() I think
 
nice, i'll look it up, thanks again
 

« first day (2146 days earlier)      last day (698 days later) »