Make ranges-test available with C++11#2114
Conversation
There was a problem hiding this comment.
Some points for the PR.
| template <typename Container, FMT_ENABLE_IF(is_contiguous<Container>::value)> | ||
| #if FMT_CLANG_VERSION | ||
| #if FMT_CLANG_VERSION >= 307 | ||
| __attribute__((no_sanitize("undefined"))) |
There was a problem hiding this comment.
Looks like there is no no_sanitize attribute prior to Clang 3.7
Maybe a bit unrelated to this PR, but it was found while I was working on it
| static constexpr const char left_padding_shifts[] = {31, 31, 0, 1, 0}; | ||
| static constexpr const char right_padding_shifts[] = {0, 31, 0, 1, 0}; | ||
| static constexpr const char left_padding_shifts[5] = {31, 31, 0, 1, 0}; | ||
| static constexpr const char right_padding_shifts[5] = {0, 31, 0, 1, 0}; |
There was a problem hiding this comment.
Some GCC versions fail to determine the size of this array - https://godbolt.org/z/KbhMGb
Maybe a bit unrelated to this PR, but it was found while I was working on it
There was a problem hiding this comment.
This is a gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66921.
|
|
||
| tuple_arg_join(const std::tuple<T...>& t, basic_string_view<Char> s) | ||
| : tuple{t}, sep{s} {} | ||
| : tuple(t), sep{s} {} |
There was a problem hiding this comment.
GCC 4.8 fails to initialize tuple ref by braces - https://godbolt.org/z/qxq5eK
| # include <vector> | ||
| #if FMT_GCC_VERSION == 0 || FMT_GCC_VERSION >= 601 | ||
| # define FMT_ENABLE_C_STYLE_ARRAY_TEST | ||
| #endif |
There was a problem hiding this comment.
It's strange but looks like GCC <6 unable to pass C-style array correctly, so {fmt} is unable right now to format them - https://godbolt.org/z/MYYf6W
| } | ||
| template <size_t N> | ||
| fmt::enable_if_t<N == 1, fmt::string_view> get() const noexcept { | ||
| return {str}; |
There was a problem hiding this comment.
No C++14 decltype(auto) (probably was unneeded anyway) and C++17 constexpr if, only C++11 code
| TEST(RangesTest, FormatTo) { | ||
| char buf[10]; | ||
| auto end = fmt::format_to(buf, "{}", std::vector{1, 2, 3}); | ||
| auto end = fmt::format_to(buf, "{}", std::vector<int>{1, 2, 3}); |
There was a problem hiding this comment.
No C++17 template deduction
|
Looks great, thanks! |
I noticed here this strange check:
fmt/test/ranges-test.cc
Lines 16 to 18 in acef0bb
So I decided to do it right - by using
__cpp_if_constexprfeature macro. But later I realized that since there is no mention in docs that ranges are supported only with C++14 (or C++17 because ofconstexpr if) it's strange to me that test doesn't check C++11, especially when this check is not necessary at all with only few changes in the test.With this PR
ranges-testcompiles with C++11 on probably most ancient supported compilers - gcc-4.8 and clang-3.5 (couldn't test 3.4).