
on Fri Nov 02 2012, Mathias Gaunard <mathias.gaunard-AT-ens-lyon.org> wrote:
On 31/10/12 19:02, Dave Abrahams wrote:
namespace wrapper { struct value;
template <class T, class U> struct mymap : std::map<T,U> { enum { _size = sizeof(T)+sizeof(U) }; // error if T or U are incomplete }; typedef mymap<std::string, value> object;
This line instantiates the declaration of std::map<std::string, value>,
If by the declaration you mean template <class K, class V, class C, class A> struct map; then yes.
but not its definition, which is why you don't get any error (doing those sizeofs inside the declaration itself will yield errors though of course).
You mean like this? --8<---------------cut here---------------start------------->8--- template <class T, class U, unsigned n = sizeof(T)+sizeof(U)> struct mymap : std::map<T,U> {}; --8<---------------cut here---------------end--------------->8--- If so, then, as you say... "of course."
I'm no expert at standardese but it seems class template instantiation usually refers to instantiating the definition, which would mean that this is indeed allowed.
-- Dave Abrahams BoostPro Computing Software Development Training http://www.boostpro.com Clang/LLVM/EDG Compilers C++ Boost