From 5888de9f349a41f653e3291f01b432fa2a3c75d3 Mon Sep 17 00:00:00 2001 From: Alexey Ochapov Date: Fri, 27 Aug 2021 00:55:21 +0300 Subject: [PATCH] make detail::make_checked() constexpr --- include/fmt/format.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 1710cf03..82ddb407 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -339,12 +339,15 @@ inline auto get_data(Container& c) -> typename Container::value_type* { #if defined(_SECURE_SCL) && _SECURE_SCL // Make a checked iterator to avoid MSVC warnings. template using checked_ptr = stdext::checked_array_iterator; -template auto make_checked(T* p, size_t size) -> checked_ptr { +template +constexpr auto make_checked(T* p, size_t size) -> checked_ptr { return {p, size}; } #else template using checked_ptr = T*; -template inline auto make_checked(T* p, size_t) -> T* { return p; } +template constexpr auto make_checked(T* p, size_t) -> T* { + return p; +} #endif // Attempts to reserve space for n extra characters in the output range.