boostorg / locale

Boost.Locale
Boost Software License 1.0
32 stars 70 forks source link

install_all/install_by does "nothing" #75

Closed Flamefire closed 2 years ago

Flamefire commented 2 years ago

@artyom-beilis What exactly are the install_all/install_by structs supposed to do?

They call has_facet on the classic locale at e.g. https://github.com/boostorg/locale/blob/9259845c6fd95ce6b8bf11e8ec5d8bdf38836c4e/src/shared/ids.cpp#L71

However as it ignores the return value the compiler rightfully warns on such lines as they do nothing.

What is the intended purpose of those has_facet calls? I'd like to at least rename them to reflect what they do. And "install" is not the right word as they do effectively nothing.

artyom-beilis commented 2 years ago

It initializes special counters in locale::id() per facet. On some systems this initialization isn't thread safe and will fail in multi-threaded environment unless it is initialized once. Has facet uses the id and thus allows proper iniitalization.