serenity
serenity copied to clipboard
AK: Difference in const-ness doesn't compile when used in iterators
The following snippets don't compile with AK::Vector, but do using std:: equivalents.
const int* object = nullptr;
Vector<int*> vector;
auto it = vector.find(object);
And in web land:
JS::GCPtr<JS::Object const> object;
Vector<JS::GCPtr<JS::Object>> vector;
auto it = vector.find(object)
etc. for all iterators
It would be nice if these could compile to avoid messiness with casting of const.
Looks like const int* cannot be bind to int* const&
std::vector has no find function, only algorithm has std::find
Yup, but I mean the equivalent way of writing this in std. To give a more clear example then, here's a serenity version that doesn't compile:
int* y = nullptr;
Vector<int const*> vector;
auto it = find(vector.begin(), vector.end(), y);
And equivalent std:: version that does compile.
int* y = nullptr;
std::vector<int const*> vector;
auto it = std::find(vector.begin(), vector.end(), y);