|
| |||||||||
| Tags: cpp, syntax, template |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Syntax: typedef typename F:: template Code: template <class F, class X>
struct twice
{
typedef typename F::template apply<X>::type once; // f(x)
typedef typename F::template apply<once>::type type; // f(f(x))
}; |
|
#2
| ||||
| ||||
| Re: Syntax: typedef typename F:: template
Its when "apply" is a meta-function of the class defined by F. We will have a tendency to write F::apply, but the syntax is F::template apply There is a brief explanation here: http://www.boost.org/doc/libs/1_40_0...her-order.html |
|
#3
| |||
| |||
| Re: Syntax: typedef typename F:: template
Metaproduction function? Can you give me an example of code that apply |
|
#4
| ||||
| ||||
| Re: Syntax: typedef typename F:: template
A meta-function is a function that applies to types. For example, you can define the meta-function AddPointer which skips the type int at "int*" like this: Code: struct AddPointer {
template<typename T>
struct apply {
typedef T* type;
};
};
int main() {
typedef AddPointer::apply<int>::type TPInt;
// And here TPInt is a pointer to int...
return 0;
} Code: int main() {
AddPointer::apply<int>::type TPInt;
// and here TPInt is a pointer to int...
twice<AddPointer, int>::type TDPInt;
return 0;
} |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Syntax: typedef typename F:: template" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Where can I find bank check template for Microsoft Word or Template | aMADeO! | MS Office Support | 2 | 2 Weeks Ago 03:50 PM |
| Difference between Macros and typedef | Mithun Seth | Software Development | 6 | 18-01-2010 02:55 PM |
| What is a syntax error? | Chrisch | Software Development | 3 | 24-11-2009 09:53 AM |
| How to create a template of template | Harmony60 | Software Development | 3 | 21-11-2009 05:17 PM |
| Syntax/Semantics for a C++ "Function Template"? | Juan-Carlos | Software Development | 3 | 11-11-2009 06:44 PM |