Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 26-10-2009
Member
 
Join Date: Jun 2009
Posts: 3,960
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)) 
};
What is F:: template?
Reply With Quote
  #2  
Old 26-10-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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
Reply With Quote
  #3  
Old 26-10-2009
Member
 
Join Date: Jun 2009
Posts: 3,960
Re: Syntax: typedef typename F:: template

Metaproduction function? Can you give me an example of code that apply
Reply With Quote
  #4  
Old 26-10-2009
Member
 
Join Date: Feb 2008
Posts: 1,848
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;
}
Once in your sample before you took your arguments in a meta-function and a type to which you apply your meta-function. So you use it like this:

Code:
int main() {
    AddPointer::apply<int>::type TPInt;
    // and here TPInt is a pointer to int... 
    twice<AddPointer, int>::type TDPInt;
    return 0;
}
So the syntax is that when you want to call a structure in a generic type F, you do F:: template apply (apply with your structure is in F). To access IT F:: apply
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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 28-01-2012 03:50 PM
Difference between Macros and typedef Mithun Seth Software Development 6 18-01-2010 02:55 PM
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
Syntax for SQL query in JSP. elldeegee Software Development 3 04-06-2009 10:44 AM


All times are GMT +5.5. The time now is 06:17 PM.