[cfe-commits] [C++0x Patch] Failed attempt at handling instantiation of non-type template parameter packs whose type is a pack expansion

Douglas Gregor dgregor at apple.com
Tue Jan 18 16:31:46 PST 2011

The attached patch is an aborted attempt to implement support for code such as

  template<typename ...Types>
  struct X {
	template<Types ...Values>
	struct Y { /* whatever */ };

where the type of a non-type template parameter pack is a pack expansion. Therefore, for example, X<short, int, long>::Y would effectively have three non-type template parameters, with types 'short', 'int', and 'long', respectively.

This implementation attempted to address this problem by instantiating 'Values' into three separate non-type template parameters, then keeping around a mapping from those instantiated non-type template parameters back to the parameter pack. However, doing so meant that these parameters had a strange existence, being neither a real parameter pack nor a real parameter, and this dual role broke many invariants expected of Sema and the AST. Thus, I'm sending this failed attempt to cfe-commits to remind myself not to do it again

I plan to attempt a completely different approach, which keeps 'Values' as a parameter pack whose "type" is just a placeholder storing N different types. It'll require updates to more code, and NonTypeTemplateParmDecl::getType() won't make sense for such parameter packs, but it should maintain the AST and Sema invariants better.

	- Doug

-------------- next part --------------
A non-text attachment was scrubbed...
Name: non-type-template-parameter-of-pack-expansion-type.patch
Type: application/octet-stream
Size: 21665 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110118/b3205953/attachment.obj>

More information about the cfe-commits mailing list