https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103755
--- Comment #6 from Dmitry Prokoptsev <dprokoptsev at gmail dot com> --- That would also work, I suppose (it even outperforms my original approach by a tiny bit -- 33 ns for v2 vs 36 for my original implementation). There are a few build errors in the alternative implementations, however: is_convertible<locale::facet*, _Facet*>::value is false, as it tries to downcast the facet -- did you mean is_base_of<>, which would also better align with the static assert message? Also, despite the always_inline attribute of __try_use_facet, my attempts to build the library with -O0 -ggdb and link my benchmark yielded a bunch of errors like ld: /home/av/prgs/gcc/debug/x86_64-pc-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so: undefined reference to `std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > const* std::__try_use_facet<std::num_get<char, std::istreambuf_iterator<char, std::char_traits<char> > > >(std::locale const&)' Suggest explicitly instantiating __try_use_facet where has_facet() and use_facet() is instantiated. See attached fix for build problems I discovered.