5 ms·
I think any attempt at defining a strict subset of a language is going to face some pushback like yours, but I do agree that while I agree with most choices thi
by simias 6y ago
I think any attempt at defining a strict subset of a language is going to face some pushback like yours, but I do agree that while I agree with most choices this one seems strange. Rolling your own containers is boring and error-prone and won't have all the features of the STL.
Also, while iostream is a bit of a mess, having it be strongly typed means that it's, in my opinion, well worth using over cstdio.
One thing I was surprised not to see mentioned here is multiple inheritance. In my experience it gets really messy really fast.
Also I really recommend reading the linked archived Boost discussion about a geometry library, it's quite funny. It starts with:
double distance(mypoint const& a, mypoint const& b)
{
double dx = a.x - b.x;
double dy = a.y - b.y;
return sqrt(dx * dx + dy * dy);
}
And after a couple of pages of refinements ends up with:
template <typename G1, typename G2>
double distance(G1 const& g1, G2 const& g2)
{
typedef typename strategy_distance
<
typename coordinate_system<G1>::type,
typename coordinate_system<G2>::type,
typename point_type<G1>::type,
typename point_type<G2>::type,
dimension<G1>::value
>::type strategy;
return dispatch::distance
<
typename tag<G1>::type,
typename tag<G2>::type,
G1, G2, strategy
>::apply(g1, g2, strategy());
}
But hey, it can compute distances in non-cartesian hyperspaces so that's pretty cool.
- deleted 6y ago[deleted]
- zabzonk 6y agoAnd it doesn't depend on whatever the heck "mypoint" is.
- kllrnohj 6y ago> One thing I was surprised not to see mentioned here is multiple inheritance. There's nuance to banning that since implementating multiple interfaces is technically multiple inheritance in C++. So I think I'd agree with you but with an exception for pure-virtual classes. > Also, while iostream is a bit of a mess, having it be strongly typed means that it's, in my opinion, well worth using over cstdio. Orthodox C++ would ban this but you can have both printf-style with type safety with https://github.com/fmtlib/fmt https://github.com/fmtlib/fmt Which inspired C++20's std::format: https://en.cppreference.com/w/cpp/utility/format https://en.cppreference.com/w/cpp/utility/format Which is also banned by Orthodox C++