Count purely an exercise; C++0x’s sizeof…does the same thing:
Unpack (…) and sizeof…only two operations for parameter packs.
Unpacking Patterns:
Unpacking uses the pattern of the expression being unpacked:
Call to print expands to:
The ellipsis is always at the end of the pattern.
Call to func expands to:
Ts is not a type; vs is not a value!
• Ts is an alias for a list of types
• vs is an alias for a list of values
• Either list may be potentially empty
• Both obey only specific actions
• Apply sizeof... to it, this will return how many class type in Ts, e.g , number of Arguments
• Expand back
Expansion rules:
Be aware! ... is not , operator!
But expanded to a argument list!
http://stackoverflow.com/a/16012355
Thus:
• Initializer lists
• Base specifiers
• Member initializer lists
• Template argument lists
• Exception specifications
◦ On second thought, scratch that
• Attribute lists
• Capture lists
CRAZY!!
Multiple expansions
• Expansion proceeds outwards
• These are different expansions!
---------------
How to use variadics?
• Pattern matching!
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.