c++11 - Why isn't std::array's operator==() marked constexpr? -
it's very natural want compare std::array
's @ compile time; , operator==()
constexpr
'able. yet - isn't marked constexpr
. intentional or oversight? , - what's reason left way (apparently in c++17 well)?
p0031 explained why didn't propose constexpr
comparisons:
currently comparisons ,
swap
/fill
may implemented of algorithms<algorithm>
header. marking comparisons constexpr break ability , potentially lead performance degradations.
for example, ==
can implemented in terms of std::equal
, - in appropriate cases - can call highly-optimized-but-decidedly-not-constexpr
memcmp
. making constexpr
==
rule out optimization without special compiler assistance.
Comments
Post a Comment