New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ssize has not been declared in std #246
Comments
Thank you.
Edit: There is the |
Me personally, I would write a local https://github.com/ned14/quickcpplib/blob/master/include/quickcpplib/start_lifetime_as.hpp#L33 |
That technique is prone to ADL hijacking: struct Evil : std::array<int, 1>{ };
constexpr int ssize(Evil) { return 2; }
static_assert(gsl::ssize(Evil{ }) == 1); Also, unlike |
I don't think that technique is prone to ADL hijacking. For something like: namespace std_or_emulation
{
using namespace std;
template <class C>
constexpr auto ssize(const C& c, ...) // inferior overload
-> std::common_type_t<std::ptrdiff_t,
std::make_signed_t<decltype(c.size())>>
{
using R = std::common_type_t<std::ptrdiff_t,
std::make_signed_t<decltype(c.size())>>;
return static_cast<R>(c.size());
}
}
template<class T> constexpr auto ssize(const T&v) { return std_or_emulation::ssize(v); } Here it would select the best available overload in namespace ADL never comes into play here, because all lookup is namespace-qualified. |
Right. But please note that the example you referenced is prone to hijacking because you don't use a qualified name there. Nevertheless, what is the benefit of delegating to |
To get early notification of when your standard library implementator has done something weird, mainly. Otherwise, none. |
Hello everyone. I have a project, which uses -std=gnu++17 flag. so, 17th standard. someday we will move to 2a, but now not about it. upon compilation, I'm getting mentioned above error:
@mbeutel mentioned that std::ssize_t is for gcc 10+; and standard 2a+. so, it should not include std::ssize_t, right? cmake generated me such a line:
|
The fix for this issue was committed in 913e86d which found its way into version 0.37, released May 13, 2020. The latest version of gsl-lite in Conan Center seems to be 0.36.0. I guess one could open an issue in their repo to have the package updated. |
Sorry for off-topic |
No, that was unintentional. Thanks for bringing this up; I just pushed an additional "v0.37.0" tag. |
Cause:
However
ssize()
is a C++ 20 only feature, not a GCC 10 feature. So this is the wrong check to do.The text was updated successfully, but these errors were encountered: