Hi,
This function rests in fbstring.h header from facebook folly library.
Link:
https://github.com/facebook/folly/blob/master/folly/FBString.h#L434
I didn't see why this code casts p back and forth to void*?
static RefCounted * fromData(Char * p) {
return static_cast<RefCounted*>(
static_cast<void*>(
static_cast<unsigned char*>(static_cast<void*>(p))
- sizeof(refCount_)));
}
Why can't it be written like this? Can anyone see a logical reason?
static RefCounted * fromData(Char * p) {
return static_cast<RefCounted*>(
static_cast<unsigned char*>(p)
- sizeof(refCount_));
}