This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -Wextra and unsigned template parameters


On 10/05/06, Joe Buck <Joe.Buck@synopsys.com> wrote:

But then I just thought of another case:

template <typename Container>
struct foo {
   foo(const Container& bar) { if (bar.size() >= 0) use(bar); }
};

For any STL-compliant container the test is redundant.  But if
we put in a rule saying to suppress the warning if the type
depends on a template, we lose the warning in this case as well;
after all, nothing stops someone from writing

class C {
public:
        int size() const;
...
};

void use(const C&);


My STL may be a bit rusty...if you don't define size(), what is its return type?. Also, there should be no warning in this example, am I wrong?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]