tanghong123 / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Passing functor as condition #121

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm not sure if this is expected behavior.

struct functor
{
    bool operator ()() const
    {
        return true;
    }
};

EXPECT_TRUE(functor()); gives:

error C2451: conditional expression of type 'functor' is illegal

EXPECT_EQ(true, functor()); gives:

error C2784: 'bool testing::internal::operator ==(T *,const
testing::internal::linked_ptr<T> &)' : could not deduce template argument
for 'T *' from 'const bool' (gtest.h line 617)

Both cases work if I declare functor func; and pass it to macros.

Happens on msvc9

Original issue reported on code.google.com by popiz...@gmail.com on 22 Feb 2009 at 7:36

GoogleCodeExporter commented 9 years ago
My mistake, functor() is calling constructor and creating new object, not 
calling
operator(). Somebody should delete this issue :)

Original comment by popiz...@gmail.com on 24 Feb 2009 at 6:07

GoogleCodeExporter commented 9 years ago

Original comment by zhanyong...@gmail.com on 26 Feb 2009 at 4:06