On Saturday, 28 December 2013 at 17:23:38 UTC, Ola Fosheim Grøstad wrote:
What you want is a (mild) warning if you use a templated algorithm and that algorithm use a O(N) primitive where it is invisible to the library user. A warning you should be able to suppress (basically telling the compiler "trust me, this is deliberate").

How is that significantly different than the current situation?

If you use walkLength, then that's you telling the compiler "trust me, this is deliberate". The only difference is that the current behavior doesn't use a warning, it just errors out with "this thing doesn't define a length", which is reasonable behavior.

FYI, if your thing defines length, then walkLength calls it. So it's effectively as fast to use when your thing has length defined, otherwise it suggests that you understand that a relaxed constraint of O(N) is acceptable and will do that for you if length doesn't exist.

Reply via email to