chromium / subspace

A concept-centered standard library for C++20, enabling safer and more reliable products and a more modern feel for C++ code.; Also home of Subdoc the code-documentation generator.
https://suslib.cc
Apache License 2.0
89 stars 15 forks source link

compat_ headers are an ODR nightmare #443

Open danakj opened 10 months ago

danakj commented 10 months ago

Collapse these headers or include them from the concept-defining location?

But we don't want to include every container header from the from_iterator.h header. However it's real bad if some places see FromIterator to be true and others see it to be false. The compiler can cache the answer and get false everywhere unexpectedly.

The right thing to do is to ensure the concept knows the right answer where the concept is defined, or where the std::vector (etc) type is defined. We can't do the latter so... how do we do the former?

Or, once sus::Vec is backed by std::vector do we just say you'd it.collect<sus::Vec<T>>() and then you can convert for ~free to std::vector? That feels bad though. It would be better to it.collect<std::vector<T>>().

Notably we avoided this issue for option/result and numerics, so this does not block the numerics milestone.

danakj commented 10 months ago

My brain came up with an answer here this morning.

define concepts that match the shape of std containers, like a ReservePushBackContainer for vector. Then provide from_iter impls for those concepts beside the FromIterator concept.