c++ - On platforms where pthread_t is numeric, is 0 guaranteed to be an invalid value? -
this question has answer here:
- is there invalid pthread_t id? 5 answers
pthread_t
(as returned pthread_self()
) opaque type, on platforms numeric, example typedef
ed unsigned long
. on these platforms, 0
invalid pthread_t
value? -1
?
if wanted value either pthread_t
or invalid, i'd use boost::optional<pthread_t>
or std::optional<pthread_t>
c++1y.
this has little overhead (bytes), expresses want (this value may or may not pthread_t
), , doesn't rely on platform-specific behavior.
Comments
Post a Comment