Commit d306585a authored by Victor Zverovich's avatar Victor Zverovich

Don't inject internal names into std (#1120)

parent 544b9279
...@@ -257,9 +257,12 @@ namespace internal { ...@@ -257,9 +257,12 @@ namespace internal {
#endif #endif
// A fallback implementation of uintptr_t for systems that lack it. // A fallback implementation of uintptr_t for systems that lack it.
namespace uintptr {
struct uintptr_t { struct uintptr_t {
unsigned char value[sizeof(void*)]; unsigned char value[sizeof(void*)];
}; };
}
using uintptr::uintptr_t;
typedef std::numeric_limits<uintptr_t> numutil; typedef std::numeric_limits<uintptr_t> numutil;
template <typename T> inline bool use_grisu() { template <typename T> inline bool use_grisu() {
...@@ -312,7 +315,7 @@ typename Allocator::value_type* allocate(Allocator& alloc, std::size_t n) { ...@@ -312,7 +315,7 @@ typename Allocator::value_type* allocate(Allocator& alloc, std::size_t n) {
FMT_END_NAMESPACE FMT_END_NAMESPACE
namespace std { namespace std {
using namespace fmt::v5::internal; using namespace fmt::v5::internal::uintptr;
// Standard permits specialization of std::numeric_limits. This specialization // Standard permits specialization of std::numeric_limits. This specialization
// is used to detect presence of uintptr_t. // is used to detect presence of uintptr_t.
template <> template <>
......
...@@ -2540,6 +2540,11 @@ TEST(FormatTest, EmphasisNonHeaderOnly) { ...@@ -2540,6 +2540,11 @@ TEST(FormatTest, EmphasisNonHeaderOnly) {
} }
TEST(FormatTest, CharTraitsIsNotAmbiguous) { TEST(FormatTest, CharTraitsIsNotAmbiguous) {
// Test that we don't inject internal names into the std namespace.
using namespace std; using namespace std;
char_traits<char>::char_type c; char_traits<char>::char_type c;
#if __cplusplus >= 201103L
std::string s;
begin(s);
#endif
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment