hof icon indicating copy to clipboard operation
hof copied to clipboard

Consider using {} instead of () when constructing objects in samples

Open tzlaine opened this issue 9 years ago • 0 comments

For example, in this:

struct id
{
    template<class T>
    T operator()(T x) const
    {
        return x;
    }
};

auto int_result = boost::fit::result<int>(id());
static_assert(std::is_same<decltype(int_result(true)), int>::value, "Not the same type");

Consider changing the second-to-last line to:

auto int_result = boost::fit::result<int>(id{});

This makes it obvious that the use of "id" is a construction, not a call.

tzlaine avatar Feb 09 '16 14:02 tzlaine