diff --git a/include/exiv2/types.hpp b/include/exiv2/types.hpp index efec54b1..75904ce3 100644 --- a/include/exiv2/types.hpp +++ b/include/exiv2/types.hpp @@ -95,7 +95,7 @@ enum TypeId { xmpSeq = 0x10008, //!< XMP sequence type. langAlt = 0x10009, //!< XMP language alternative type. invalidTypeId = 0x1fffe, //!< Invalid type id. - lastTypeId = 0x1ffff //!< Last type id. + lastTypeId = 0x1ffff, //!< Last type id. }; //! Container for binary data @@ -447,17 +447,26 @@ EXIV2API Rational floatToRationalCast(float f); */ template const T* find(T (&src)[N], const K& key) { - const T* rc = std::find(src, src + N, key); + auto rc = std::find(src, src + N, key); return rc == src + N ? nullptr : rc; } //! Utility function to convert the argument of any type to a string template -std::string toString(const T& arg) { +std::string toStringHelper(const T& arg, std::true_type) { + return std::to_string(arg); +} + +template +std::string toStringHelper(const T& arg, std::false_type) { std::ostringstream os; os << arg; return os.str(); } +template +std::string toString(const T& arg) { + return toStringHelper(arg, std::is_integral()); +} /*! @brief Utility function to convert a string to a value of type \c T.