Howard Hinnant's data library is what is suitable for C ++ 20. It was proposed through p0355r4 and approved for C ++ 20 in November 2017. Is it thread safe? Unfortunately, neither the documentation nor the proposal seems to be clear about this. However, some functions, such as get_tzdb_list , are explicitly called Thread Safety. Your best option is to ask Hinnant for a gitter chat. However, the discussion in Why is there no alternative to stf :: localtime and std :: gmtime? in C ++ 11 threadsafe, it seems that it is thread safe (even though it never explicitly spoke). As Nicol Bolas points out , you can just wrap it behind a mutex.
If this is not the case, you can get data races again and therefore undefined behavior. If you code large projects in which coding work is divided into teams, you should constantly remind everyone that they should not (!) Use the functions provided by the C ++ standard, but instead use their own shell (or risk undefined behavior) .
At a shallow level, this is what the codes say. Facebook has this problem for junior developers, where they continue to make the same mistakes over and over again. If your team has โcurious repetitive errorsโ, you need to access it somehow (for example, add checks for linter: Clang comes to mind).
At a much more direct level, Google is the epitome of this. The problem they encountered was using the old implementation of COW string and switching to string based SSO. However, since they relied on third-party libraries that used a COW-based string , they needed to maintain them in their code base. Telling developers about using Google wrappers was a futile effort. The solution that the developer came up with was hacked using inline namespaces . A bit extreme, but if you are dealing with an equally large code base, this can do the trick.
user9168101
source share