Make convert_to_int public (#818)

This commit is contained in:
Victor Zverovich
2018-08-22 07:40:06 -07:00
parent ba95e36a58
commit 987514761e
5 changed files with 32 additions and 28 deletions

View File

@@ -341,6 +341,13 @@ class basic_format_args;
template <typename T, typename Char = char, typename Enable = void>
struct formatter;
template <typename T, typename Char, typename Enable = void>
struct convert_to_int {
enum {
value = !std::is_arithmetic<T>::value && std::is_convertible<T, int>::value
};
};
namespace internal {
/** A contiguous memory buffer with an optional growing ability. */
@@ -490,13 +497,6 @@ FMT_CONSTEXPR bool is_arithmetic(type t) {
return t > internal::none_type && t <= internal::last_numeric_type;
}
template <typename T, typename Char, bool ENABLE = true>
struct convert_to_int {
enum {
value = !std::is_arithmetic<T>::value && std::is_convertible<T, int>::value
};
};
template <typename Char>
struct string_value {
const Char *value;

View File

@@ -71,15 +71,6 @@ class is_streamable {
static const bool value = result::value;
};
// Disable conversion to int if T has an overloaded operator<< which is a free
// function (not a member of std::ostream).
template <typename T, typename Char>
class convert_to_int<T, Char, true> {
public:
static const bool value =
convert_to_int<T, Char, false>::value && !is_streamable<T, Char>::value;
};
// Write the content of buf to os.
template <typename Char>
void write(std::basic_ostream<Char> &os, basic_buffer<Char> &buf) {
@@ -106,6 +97,15 @@ void format_value(basic_buffer<Char> &buffer, const T &value) {
}
} // namespace internal
// Disable conversion to int if T has an overloaded operator<< which is a free
// function (not a member of std::ostream).
template <typename T, typename Char>
struct convert_to_int<T, Char, void> {
static const bool value =
convert_to_int<T, Char, int>::value &&
!internal::is_streamable<T, Char>::value;
};
// Formats an object of type T that has an overloaded ostream operator<<.
template <typename T, typename Char>
struct formatter<T, Char,