+namespace MapUtilsInternal {
+
+/* This dummy struct is used to introduce a conversion, making the overloaded
+operator below worse than the templated one provided in lexicalcast.h. */
+struct Any
+{
+ template<typename T>
+ Any(const T &) { }
+};
+
+/* This must be hidden in the internal namespace to avoid interfering with
+other things. */
+inline void operator<<(LexicalConverter &, Any)
+{ }
+
+template<typename T>
+static std::string stringify_key(const T &k)
+{
+ try
+ {
+ LexicalConverter conv((Fmt()));
+ conv << k;
+ return conv.get();
+ }
+ catch(const lexical_error &)
+ {
+ return "<cannot display value>";
+ }
+}
+
+} // namespace Internal
+