
On Thu, Sep 22, 2011 at 10:25 PM, Brent Spillner <spillner@acm.org> wrote:
For example, the following code asserts back() == value only when can_call_equal<T>::value is true. However, is there a better way to do
On Thu, 22 Sep 2011 08:03:09 lcaminiti wrote: this
that does not require the extra function call to post1?
Unless I'm missing something, you should be able to replace the post1() calls with
assert(boost::can_call_equal<T>::value && std::clog << "actual assertion\n" == std::clog && back() == value || std::clog << "trivial assertion\n" == std::clog);
Unfortunately, the compiler can't do a "syntactic short-circuit" when !can_call_equal<T>::value and simply skip over the "back() == value" expression; "back() == value" still needs to be a valid expression, i.e., if an appropriate operator== isn't found, you'll still get a compiler error :( Compare to false && (pretty-sure*the==compiler&wont^like%this) ...at least most of the time, anyway... - Jeff