Explicit template arguments for operator()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • James Daughtry

    #1

    Explicit template arguments for operator()

    It seems impossible to explicitly specify template arguments for an
    overloaded operator() without giving the full name. I'd like to know
    where in the C++ standard this behavior is defined. I can't seem to
    find it. Here's some code the shows what I'm talking about:

    #include <iostream>

    using namespace std;

    class Foo {
    public:
    template <typename Func>
    void operator()() {
    cout << "Foo::operator( )\n";
    Func()();
    }
    };

    class Bar {
    public:
    void operator()() {
    cout << "Bar::operator( )\n";
    }
    };

    int main() {
    Foo f;

    // Cannot deduce Func
    f();

    // Illegal expression
    f<Bar>();

    // Works fine
    f.operator()<Ba r>();
    }
  • Barry

    #2
    Re: Explicit template arguments for operator()

    On 9ÔÂ17ÈÕ, ÏÂÎç9ʱ46·Ö, James Daughtry <mordoc...@hotm ail.comwrote:
    It seems impossible to explicitly specify template arguments for an
    overloaded operator() without giving the full name. I'd like to know
    where in the C++ standard this behavior is defined. I can't seem to
    find it. Here's some code the shows what I'm talking about:
    >
    14.8.1/5 give some 'note' closely on this, but not exactly,
    I wonder adding something about 'overloaded operators' here is
    approriate.

    --
    Best Regards
    Barry

    Comment

    Working...