FMT_EXPLICIT -> explicit, FMT_NULL -> nullptr

This commit is contained in:
Victor Zverovich
2019-05-30 07:42:36 -07:00
parent 4a7966c773
commit d07cc2026b
25 changed files with 163 additions and 193 deletions
+5 -5
View File
@@ -42,7 +42,7 @@ inline std::tm localtime(std::time_t time) {
return handle(localtime_r(&time_, &tm_));
}
bool handle(std::tm* tm) { return tm != FMT_NULL; }
bool handle(std::tm* tm) { return tm != nullptr; }
bool handle(internal::null<>) {
using namespace fmt::internal;
@@ -56,7 +56,7 @@ inline std::tm localtime(std::time_t time) {
using namespace fmt::internal;
std::tm* tm = std::localtime(&time_);
if (tm) tm_ = *tm;
return tm != FMT_NULL;
return tm != nullptr;
}
#endif
};
@@ -79,7 +79,7 @@ inline std::tm gmtime(std::time_t time) {
return handle(gmtime_r(&time_, &tm_));
}
bool handle(std::tm* tm) { return tm != FMT_NULL; }
bool handle(std::tm* tm) { return tm != nullptr; }
bool handle(internal::null<>) {
using namespace fmt::internal;
@@ -92,7 +92,7 @@ inline std::tm gmtime(std::time_t time) {
bool fallback(internal::null<>) {
std::tm* tm = std::gmtime(&time_);
if (tm) tm_ = *tm;
return tm != FMT_NULL;
return tm != nullptr;
}
#endif
};
@@ -157,7 +157,7 @@ template <typename Char> struct formatter<std::tm, Char> {
namespace internal {
template <typename Period> FMT_CONSTEXPR const char* get_units() {
return FMT_NULL;
return nullptr;
}
template <> FMT_CONSTEXPR const char* get_units<std::atto>() { return "as"; }
template <> FMT_CONSTEXPR const char* get_units<std::femto>() { return "fs"; }
+6 -36
View File
@@ -89,28 +89,6 @@
# endif
#endif
#if FMT_HAS_FEATURE(cxx_explicit_conversions) || FMT_GCC_VERSION >= 405 || \
FMT_MSC_VER >= 1800
# define FMT_USE_EXPLICIT 1
# define FMT_EXPLICIT explicit
#else
# define FMT_USE_EXPLICIT 0
# define FMT_EXPLICIT
#endif
#ifndef FMT_NULL
# if FMT_HAS_FEATURE(cxx_nullptr) || \
(FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) || FMT_MSC_VER >= 1600
# define FMT_NULL nullptr
# define FMT_USE_NULLPTR 1
# else
# define FMT_NULL NULL
# endif
#endif
#ifndef FMT_USE_NULLPTR
# define FMT_USE_NULLPTR 0
#endif
// Check if exceptions are disabled.
#ifndef FMT_EXCEPTIONS
# if (defined(__GNUC__) && !defined(__EXCEPTIONS)) || \
@@ -220,11 +198,6 @@
# define FMT_STRING_VIEW std::experimental::basic_string_view
#endif
// std::result_of is defined in <functional> in gcc 4.4.
#if FMT_GCC_VERSION && FMT_GCC_VERSION <= 404
# include <functional>
#endif
// An enable_if helper to be used in template parameters. enable_if in template
// parameters results in much shorter symbols: https://godbolt.org/z/sWw4vP.
#define FMT_ENABLE_IF_T(...) typename std::enable_if<(__VA_ARGS__), int>::type
@@ -272,7 +245,7 @@ template <typename T> class buffer {
// Don't initialize ptr_ since it is not accessed to save a few cycles.
buffer(std::size_t sz) FMT_NOEXCEPT : size_(sz), capacity_(sz) {}
buffer(T* p = FMT_NULL, std::size_t sz = 0, std::size_t cap = 0) FMT_NOEXCEPT
buffer(T* p = nullptr, std::size_t sz = 0, std::size_t cap = 0) FMT_NOEXCEPT
: ptr_(p),
size_(sz),
capacity_(cap) {}
@@ -379,7 +352,7 @@ typedef char no[2];
template <typename T, typename V> struct is_constructible {
template <typename U> static yes& test(int (*)[sizeof(new U(declval<V>()))]);
template <typename U> static no& test(...);
enum { value = sizeof(test<T>(FMT_NULL)) == sizeof(yes) };
enum { value = sizeof(test<T>(nullptr)) == sizeof(yes) };
};
#else
template <typename... T>
@@ -404,7 +377,7 @@ template <typename Char> class basic_string_view {
typedef Char char_type;
typedef const Char* iterator;
FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(FMT_NULL), size_(0) {}
FMT_CONSTEXPR basic_string_view() FMT_NOEXCEPT : data_(nullptr), size_(0) {}
/** Constructs a string reference object from a C string and a size. */
FMT_CONSTEXPR basic_string_view(const Char* s, size_t count) FMT_NOEXCEPT
@@ -850,10 +823,7 @@ FMT_MAKE_VALUE(string_type, const std::basic_string<typename C::char_type>&,
basic_string_view<typename C::char_type>)
FMT_MAKE_VALUE(pointer_type, void*, const void*)
FMT_MAKE_VALUE_SAME(pointer_type, const void*)
#if FMT_USE_NULLPTR
FMT_MAKE_VALUE(pointer_type, std::nullptr_t, const void*)
#endif
// Formatting of arbitrary pointers is disallowed. If you want to output a
// pointer cast it to "void *" or "const void *". In particular, this forbids
@@ -953,7 +923,7 @@ template <typename Context> class basic_format_arg {
FMT_CONSTEXPR basic_format_arg() : type_(internal::none_type) {}
FMT_CONSTEXPR FMT_EXPLICIT operator bool() const FMT_NOEXCEPT {
FMT_CONSTEXPR explicit operator bool() const FMT_NOEXCEPT {
return type_ != internal::none_type;
}
@@ -1041,7 +1011,7 @@ template <typename Context> class arg_map {
}
public:
arg_map() : map_(FMT_NULL), size_(0) {}
arg_map() : map_(nullptr), size_(0) {}
void init(const basic_format_args<Context>& args);
~arg_map() { delete[] map_; }
@@ -1061,7 +1031,7 @@ class locale_ref {
friend class locale;
public:
locale_ref() : locale_(FMT_NULL) {}
locale_ref() : locale_(nullptr) {}
template <typename Locale> explicit locale_ref(const Locale& loc);
template <typename Locale> Locale get() const;
+11 -11
View File
@@ -98,7 +98,7 @@ typedef void (*FormatFunc)(internal::buffer<char>&, int, string_view);
// Buffer should be at least of size 1.
int safe_strerror(int error_code, char*& buffer,
std::size_t buffer_size) FMT_NOEXCEPT {
FMT_ASSERT(buffer != FMT_NULL && buffer_size != 0, "invalid buffer");
FMT_ASSERT(buffer != nullptr && buffer_size != 0, "invalid buffer");
class dispatcher {
private:
@@ -650,9 +650,9 @@ template <int GRISU_VERSION> struct grisu_shortest_handler {
// Decrement the generated number approaching value from above.
void round(uint64_t d, uint64_t divisor, uint64_t& remainder,
uint64_t error) {
while (remainder < d && error - remainder >= divisor &&
(remainder + divisor < d ||
d - remainder >= remainder + divisor - d)) {
while (
remainder < d && error - remainder >= divisor &&
(remainder + divisor < d || d - remainder >= remainder + divisor - d)) {
--buf[size - 1];
remainder += divisor;
}
@@ -782,7 +782,7 @@ void sprintf_format(Double value, internal::buffer<char>& buf,
*format_ptr = '\0';
// Format using snprintf.
char* start = FMT_NULL;
char* start = nullptr;
for (;;) {
std::size_t buffer_size = buf.capacity();
start = &buf[0];
@@ -839,7 +839,7 @@ FMT_FUNC internal::utf8_to_utf16::utf8_to_utf16(string_view s) {
}
int length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(),
s_size, FMT_NULL, 0);
s_size, nullptr, 0);
if (length == 0) FMT_THROW(windows_error(GetLastError(), ERROR_MSG));
buffer_.resize(length + 1);
length = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, s.data(), s_size,
@@ -865,12 +865,12 @@ FMT_FUNC int internal::utf16_to_utf8::convert(wstring_view s) {
return 0;
}
int length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, FMT_NULL, 0,
FMT_NULL, FMT_NULL);
int length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, nullptr, 0,
nullptr, nullptr);
if (length == 0) return GetLastError();
buffer_.resize(length + 1);
length = WideCharToMultiByte(CP_UTF8, 0, s.data(), s_size, &buffer_[0],
length, FMT_NULL, FMT_NULL);
length, nullptr, nullptr);
if (length == 0) return GetLastError();
buffer_[length] = 0;
return 0;
@@ -894,9 +894,9 @@ FMT_FUNC void internal::format_windows_error(internal::buffer<char>& out,
for (;;) {
wchar_t* system_message = &buf[0];
int result = FormatMessageW(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, FMT_NULL,
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr,
error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), system_message,
static_cast<uint32_t>(buf.size()), FMT_NULL);
static_cast<uint32_t>(buf.size()), nullptr);
if (result != 0) {
utf16_to_utf8 utf8_message;
if (utf8_message.convert(system_message) == ERROR_SUCCESS) {
+12 -13
View File
@@ -285,8 +285,7 @@ FMT_CONSTEXPR T* end(T (&array)[N]) FMT_NOEXCEPT {
}
// An implementation of iterator_t for pre-C++20 compilers such as gcc 4.
template <typename T>
struct iterator_t {
template <typename T> struct iterator_t {
typedef decltype(internal::begin(internal::declval<const T&>())) type;
};
@@ -2101,7 +2100,7 @@ inline bool find<false, char>(const char* first, const char* last, char value,
const char*& out) {
out = static_cast<const char*>(
std::memchr(first, value, internal::to_unsigned(last - first)));
return out != FMT_NULL;
return out != nullptr;
}
template <typename Handler, typename Char> struct id_adapter {
@@ -2123,7 +2122,7 @@ FMT_CONSTEXPR void parse_format_string(basic_string_view<Char> format_str,
FMT_CONSTEXPR void operator()(const Char* begin, const Char* end) {
if (begin == end) return;
for (;;) {
const Char* p = FMT_NULL;
const Char* p = nullptr;
if (!find<IS_CONSTEXPR>(begin, end, '}', p))
return handler_.on_text(begin, end);
++p;
@@ -2304,8 +2303,8 @@ class arg_formatter
\endrst
*/
explicit arg_formatter(context_type& ctx,
basic_parse_context<char_type>* parse_ctx = FMT_NULL,
format_specs* spec = FMT_NULL)
basic_parse_context<char_type>* parse_ctx = nullptr,
format_specs* spec = nullptr)
: base(Range(ctx.out()), spec, ctx.locale()),
ctx_(ctx),
parse_ctx_(parse_ctx) {}
@@ -3040,7 +3039,7 @@ template <typename T, typename Char>
struct formatter<T, Char,
typename std::enable_if<internal::format_type<
typename buffer_context<Char>::type, T>::value>::type> {
FMT_CONSTEXPR formatter() : format_str_(FMT_NULL) {}
FMT_CONSTEXPR formatter() : format_str_(nullptr) {}
// Parses format specifiers stopping either at the end of the range or at the
// terminating '}'.
@@ -3104,7 +3103,7 @@ struct formatter<T, Char,
typedef output_range<typename FormatContext::iterator,
typename FormatContext::char_type>
range_type;
return visit_format_arg(arg_formatter<range_type>(ctx, FMT_NULL, &specs_),
return visit_format_arg(arg_formatter<range_type>(ctx, nullptr, &specs_),
internal::make_arg<FormatContext>(val));
}
@@ -3160,7 +3159,7 @@ template <typename Char = char> class dynamic_formatter {
typedef output_range<typename FormatContext::iterator,
typename FormatContext::char_type>
range;
visit_format_arg(arg_formatter<range>(ctx, FMT_NULL, &specs_),
visit_format_arg(arg_formatter<range>(ctx, nullptr, &specs_),
internal::make_arg<FormatContext>(val));
return ctx.out();
}
@@ -3329,14 +3328,14 @@ arg_join<It, wchar_t> join(It begin, It end, wstring_view sep) {
\endrst
*/
template <typename Range>
arg_join<typename internal::iterator_t<Range>::type, char>
join(const Range& range, string_view sep) {
arg_join<typename internal::iterator_t<Range>::type, char> join(
const Range& range, string_view sep) {
return join(internal::begin(range), internal::end(range), sep);
}
template <typename Range>
arg_join<typename internal::iterator_t<Range>::type, wchar_t>
join(const Range& range, wstring_view sep) {
arg_join<typename internal::iterator_t<Range>::type, wchar_t> join(
const Range& range, wstring_view sep) {
return join(internal::begin(range), internal::end(range), sep);
}
#endif
+5 -5
View File
@@ -133,7 +133,7 @@ class buffered_file {
public:
// Constructs a buffered_file object which doesn't represent any file.
buffered_file() FMT_NOEXCEPT : file_(FMT_NULL) {}
buffered_file() FMT_NOEXCEPT : file_(nullptr) {}
// Destroys the object closing the file it represents if any.
FMT_API ~buffered_file() FMT_NOEXCEPT;
@@ -144,13 +144,13 @@ class buffered_file {
public:
buffered_file(buffered_file&& other) FMT_NOEXCEPT : file_(other.file_) {
other.file_ = FMT_NULL;
other.file_ = nullptr;
}
buffered_file& operator=(buffered_file&& other) {
close();
file_ = other.file_;
other.file_ = FMT_NULL;
other.file_ = nullptr;
return *this;
}
@@ -295,7 +295,7 @@ class Locale {
public:
typedef locale_t Type;
Locale() : locale_(newlocale(LC_NUMERIC_MASK, "C", FMT_NULL)) {
Locale() : locale_(newlocale(LC_NUMERIC_MASK, "C", nullptr)) {
if (!locale_) FMT_THROW(system_error(errno, "cannot create locale"));
}
~Locale() { freelocale(locale_); }
@@ -305,7 +305,7 @@ class Locale {
// Converts string to floating-point number and advances str past the end
// of the parsed input.
double strtod(const char*& str) const {
char* end = FMT_NULL;
char* end = nullptr;
double result = strtod_l(str, &end, locale_);
str = end;
return result;
+1 -1
View File
@@ -297,7 +297,7 @@ class prepared_format {
check_prepared_specs(specs, arg.type());
advance_parse_context_to_specification(parse_ctx, part);
ctx.advance_to(
visit_format_arg(arg_formatter<Range>(ctx, FMT_NULL, &specs), arg));
visit_format_arg(arg_formatter<Range>(ctx, nullptr, &specs), arg));
} break;
}
}
+2 -2
View File
@@ -82,7 +82,7 @@ template <typename T> class is_like_std_string {
public:
static FMT_CONSTEXPR_DECL const bool value =
is_string<T>::value || !std::is_void<decltype(check<T>(FMT_NULL))>::value;
is_string<T>::value || !std::is_void<decltype(check<T>(nullptr))>::value;
};
template <typename Char>
@@ -113,7 +113,7 @@ template <typename T> class is_tuple_like_ {
public:
static FMT_CONSTEXPR_DECL const bool value =
!std::is_void<decltype(check<T>(FMT_NULL))>::value;
!std::is_void<decltype(check<T>(nullptr))>::value;
};
// Check for integer_sequence