This post already explains how adding deduction guides in the std namespace is undefined.
Now, what I would really like to do is this:
namespace std { // undefined behavior
template <class... U>
array(char const*, U...) -> array<string, 1 + sizeof...(U)>;
}
So this is what I've tried:
template <typename T, std::size_t N>
struct array : std::array<T, N> {};
template <class... U>
array(char const*, U...) -> array<std::string, 1 + sizeof...(U)>;
template <typename T, class... U>
array(T, U...) -> array<T, 1 + sizeof...(U)>;
And it works
auto const arr = array{ "hello", "world" };
// array<std::string, 2ul>
My question now is:
Q: Is this my only option for adding deduction guides for stl types? Are there other options?