Topic: Group of template declarations


Author: kprateek88@yahoo.com (Prateek R Karandikar)
Date: Sat, 15 May 2004 17:29:38 +0000 (UTC)
Raw View
Many times, we have a sequence of templated declarations, with the
same template<template-parameter-list[opt]>. For example, a class
definition and the definition of member functions defined outside the
class body. It is tedious (both while reading and writing code) to
repeat the template<template-parameter-list[opt]> before each
declaration. Consider:

template-group:
 template<template-parameter-list[opt]> { declaration-seq[opt] }


This can be defined to have the same effect as the code produced by
preceding each declaration in the declaration-seq with the
template<template-parameter-list[opt]>. If any declaration in the
declaration in the declaration-seq cannot be templated (eg. int x;),
the result would be the same as if it was outside a template-group and
preceded by a template<template-parameter-list[opt]> -- a compile
error.

This is analogous to applying a linkage specification to a group of
declarations( eg. extern "C" {/*...*/}).

The only purpose of a template-group would be as a synctatic
convnience.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]