Why aren’t std::algorithms constexpr and which could be?

It could be constexpr, but cannot be evaluated as a constant expression, since in this case, for example for compile-time find it is required that:
begin/end should be constexpr, the * operator of the iterator should be constexpr, operator == should be constexpr, operator != for the iterator should be constexpr, operator ++ for the iterator should be constexpr. But, if all functions are constexpr, then many algorithms can be implemented with constexpr.

You can look at the SPROUT library for the implementation of constexpr containers/algorithms.

And related talk on the isocpp.org forums

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)