diff --git a/include/fmt/color.h b/include/fmt/color.h index 3044aaab..d4b55a05 100644 --- a/include/fmt/color.h +++ b/include/fmt/color.h @@ -15,21 +15,33 @@ FMT_BEGIN_NAMESPACE #ifdef FMT_DEPRECATED_COLORS // color and (v)print_colored are deprecated. -enum color { black, red, green, yellow, blue, magenta, cyan, white }; -FMT_API void vprint_colored(color c, string_view format, format_args args); -FMT_API void vprint_colored(color c, wstring_view format, wformat_args args); +enum FMT_DEPRECATED color { + black, + red, + green, + yellow, + blue, + magenta, + cyan, + white +}; +FMT_DEPRECATED FMT_API void vprint_colored(color c, string_view format, + format_args args); +FMT_DEPRECATED FMT_API void vprint_colored(color c, wstring_view format, + wformat_args args); template -inline void print_colored(color c, string_view format_str, - const Args&... args) { +FMT_DEPRECATED inline void print_colored(color c, string_view format_str, + const Args&... args) { vprint_colored(c, format_str, make_format_args(args...)); } template -inline void print_colored(color c, wstring_view format_str, - const Args&... args) { +FMT_DEPRECATED inline void print_colored(color c, wstring_view format_str, + const Args&... args) { vprint_colored(c, format_str, make_format_args(args...)); } -inline void vprint_colored(color c, string_view format, format_args args) { +FMT_DEPRECATED inline void vprint_colored(color c, string_view format, + format_args args) { char escape[] = "\x1b[30m"; escape[3] = static_cast('0' + c); std::fputs(escape, stdout); @@ -37,7 +49,8 @@ inline void vprint_colored(color c, string_view format, format_args args) { std::fputs(internal::data::RESET_COLOR, stdout); } -inline void vprint_colored(color c, wstring_view format, wformat_args args) { +FMT_DEPRECATED inline void vprint_colored(color c, wstring_view format, + wformat_args args) { wchar_t escape[] = L"\x1b[30m"; escape[3] = static_cast('0' + c); std::fputws(escape, stdout); diff --git a/include/fmt/core.h b/include/fmt/core.h index fcc6a666..0005cada 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -143,6 +143,21 @@ # endif #endif +#ifndef FMT_DEPRECATED +# if (FMT_HAS_CPP_ATTRIBUTE(deprecated) && __cplusplus >= 201402L) || \ + FMT_MSC_VER >= 1900 +# define FMT_DEPRECATED [[deprecated]] +# else +# if defined(__GNUC__) || defined(__clang__) +# define FMT_DEPRECATED __attribute__((deprecated)) +# elif FMT_MSC_VER +# define FMT_DEPRECATED __declspec(deprecated) +# else +# define FMT_DEPRECATED /*deprecated*/ +# endif +# endif +#endif + #ifndef FMT_BEGIN_NAMESPACE # if FMT_HAS_FEATURE(cxx_inline_namespaces) || FMT_GCC_VERSION >= 404 || \ FMT_MSC_VER >= 1900 @@ -911,10 +926,9 @@ FMT_CONSTEXPR typename internal::result_of::type visit_format_arg( return vis(monostate()); } -// DEPRECATED! template -FMT_CONSTEXPR typename internal::result_of::type visit( - Visitor&& vis, const basic_format_arg& arg) { +FMT_DEPRECATED FMT_CONSTEXPR typename internal::result_of::type +visit(Visitor&& vis, const basic_format_arg& arg) { return visit_format_arg(std::forward(vis), arg); } @@ -972,9 +986,8 @@ class basic_parse_context : private ErrorHandler { typedef basic_parse_context format_parse_context; typedef basic_parse_context wformat_parse_context; -// DEPRECATED! -typedef basic_parse_context parse_context; -typedef basic_parse_context wparse_context; +FMT_DEPRECATED typedef basic_parse_context parse_context; +FMT_DEPRECATED typedef basic_parse_context wparse_context; namespace internal { // A map from argument names to their values for named arguments. @@ -1063,7 +1076,7 @@ class context_base { public: basic_parse_context& parse_context() { return parse_context_; } - basic_format_args args() const { return args_; } // DEPRECATED! + FMT_DEPRECATED basic_format_args args() const { return args_; } basic_format_arg arg(unsigned id) const { return args_.get(id); } internal::error_handler error_handler() { @@ -1074,7 +1087,7 @@ class context_base { // Returns an iterator to the beginning of the output range. iterator out() { return out_; } - iterator begin() { return out_; } // deprecated + FMT_DEPRECATED iterator begin() { return out_; } // Advances the begin iterator to ``it``. void advance_to(iterator it) { out_ = it; } @@ -1163,9 +1176,10 @@ class basic_format_context // specified name. format_arg arg(basic_string_view name); - // DEPRECATED! - format_arg get_arg(unsigned arg_id) { return arg(arg_id); } - format_arg get_arg(basic_string_view name) { return arg(name); } + FMT_DEPRECATED format_arg get_arg(unsigned arg_id) { return arg(arg_id); } + FMT_DEPRECATED format_arg get_arg(basic_string_view name) { + return arg(name); + } }; template struct buffer_context { diff --git a/include/fmt/format.h b/include/fmt/format.h index 4be16c05..f2179da3 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2222,8 +2222,7 @@ class arg_formatter explicit arg_formatter(context_type& ctx, format_specs* spec = FMT_NULL) : base(Range(ctx.out()), spec, ctx.locale()), ctx_(ctx) {} - // Deprecated. - arg_formatter(context_type& ctx, format_specs& spec) + FMT_DEPRECATED arg_formatter(context_type& ctx, format_specs& spec) : base(Range(ctx.out()), &spec), ctx_(ctx) {} using base::operator(); @@ -2892,11 +2891,11 @@ class format_int { std::string str() const { return std::string(str_, size()); } }; -// DEPRECATED! // Formats a decimal integer value writing into buffer and returns // a pointer to the end of the formatted string. This function doesn't // write a terminating null character. -template inline void format_decimal(char*& buffer, T value) { +template +FMT_DEPRECATED inline void format_decimal(char*& buffer, T value) { typedef typename internal::int_traits::main_type main_type; main_type abs_value = static_cast(value); if (internal::is_negative(value)) {