unterumarmung / fixed_string

C++17 string with fixed size

Home Page:https://unterumarmung.github.io/fixed_string/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ambiguous deduction guides in C++23 mode

jwt27 opened this issue · comments

Just trying this with gcc 14, any use of the fixed_string "alias" type fails to compile with -std=c++23:

#include <fixed_string.hpp>

template<fixstr::fixed_string>
struct stringy_type { };

using foo = stringy_type<"hello">;
$ g++-14 -I include -std=c++23 -c test.cpp
test.cpp:6:33: error: class template argument deduction failed:
    6 | using foo = stringy_type<"hello">;
      |                                 ^
test.cpp:6:33: error: call of overloaded ‘fixed_string(const char [6])’ is ambiguous
In file included from test.cpp:1:
include/fixed_string.hpp:518:1: note: candidate: ‘fixstr::basic_fixed_string(const char (&)[N])-> fixed_string<(N - 1)> [with long unsigned int N = 6]’
  518 | basic_fixed_string(const TChar (&)[N]) -> basic_fixed_string<TChar, N - 1>;
      | ^~~~~~~~~~~~~~~~~~
include/fixed_string.hpp:529:1: note: candidate: ‘fixstr::fixed_string(const char (&)[N])-> fixed_string<(N - 1)> [with long unsigned int N = 6]’
  529 | fixed_string(const char (&)[N]) -> fixed_string<N - 1>;
      | ^~~~~~~~~~~~

Oh I'm sorry for the long response. I've not seen the notification from GitHub.

To be honest, I've never tested this library with newer compilers. I wrote it when C++20 wasn't very well supported and that's why there are some workarounds...

I'm not sure when I'll be able to test the issue and come up with a solution, but if you have one, I'll be glad to review it and merge.

// Early GCC versions that support cNTTP were not able to deduce size_t parameter

I guess these lines should be rewritten to type aliases and the support for the old GCC versions to be dropped