X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FRange.h;h=4a06491684549db077af179fb49270e4223375f8;hp=db2de699df4dffe87000bb1034c6a24a505306b8;hb=8cb615a27594078056b2e4ec2350660e594f5a89;hpb=67a55881d21e8359640c86a0486de2f0da44390f diff --git a/folly/Range.h b/folly/Range.h index db2de699..4a064916 100644 --- a/folly/Range.h +++ b/folly/Range.h @@ -353,8 +353,13 @@ public: reset(str.data(), str.size()); } - size_type size() const { - assert(b_ <= e_); + constexpr size_type size() const { + // It would be nice to assert(b_ <= e_) here. This can be achieved even + // in a C++11 compatible constexpr function: + // http://ericniebler.com/2014/09/27/assert-and-constexpr-in-cxx11/ + // Unfortunately current gcc versions have a bug causing it to reject + // this check in a constexpr function: + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71448 return e_ - b_; } size_type walk_size() const {