inline bool operator!=(const malloc_allocator<t>&,
const malloc_allocator<t>&) {
return false;
}
注:
[1] you can see an example of a pool allocator in the open source sgi pro64tm compiler, http://oss.sgi.com/projects/pro64/.
[2] why the funny template keyword in that expression? it's an annoying little technicality; like typename, it helps the compiler resolve a parsing ambiguity. the problem is that when a is a template parameter, and the compiler sees an expression like a::b<t>, the compiler doesn't know anything about a's members. should it assume that b<t> is a member template, or should it assume that b is an ordinary member variable and that < is just a less than sign? a human reader knows which way to interpret it, but the compiler doesn't. you need to put in template to force the first interpretation. formally, the rule (in §14.2 of the c++ standard) is: "when the name of a member template specialization appears after . or -> in a postfix-expression, or after nested-name-specifier in a qualified-id, and the postfix-expression or qualified-id explicitly depends on a template-parameter (14.6.2), the member template name must be prefixed by the keyword template. otherwise the name is assumed to name a non-template."