UPD: next( &c ) is a valid address for dereference. There will be a data character or a null-terminator. basic_string is implemented as: [ size_t __cap_ ][ size_t __size_ ][ char* __data_ (ends with \0) ]
UPD: After some research and tests, I've noticed, that Clang 8 implements strings with a null-terminator in the memory layout. Technically, I dereference not std::string::end (which would be UB), but the address in memory, where \0 is located.
return "no";
thank( you );
Another great kata from you. Thanks, DM!
Haha! You know it is possible, but your cached bitset works better. Bravo!
👍
C-style cast makes it 98% close. XD
Your idea with ranges sounds great.
No, using xor does not make the function redundant.
The trick with implicit conversion (boolean to integer):
👍 Very interesting kata. Thanks!
Why? Test several sequences and find a pattern.
This comment is hidden because it contains spoiler information about the solution
UPD:
next( &c )
is a valid address for dereference. There will be a data character or a null-terminator.basic_string
is implemented as:[ size_t __cap_ ][ size_t __size_ ][ char* __data_ (ends with \0) ]
UPD: After some research and tests, I've noticed, that Clang 8 implements strings with a null-terminator in the memory layout. Technically, I dereference not
std::string::end
(which would be UB), but the address in memory, where\0
is located.thank( you );
NB: if the sizes are different,
at()
throws an exception.Loading more items...