Solved

What does this  TN Map<T, TN>(T src) mean?

Posted on 2016-10-21
5
32 Views
Last Modified: 2016-10-22
Please explain TN Map<T, TN>(T src)

        public static TN Map<T, TN>(T src)
        {
            return Instance.Map<T, TN>(src);
        }

        public static TN Map<T, TN>(T src, TN dest)
        {
            return Instance.Map(src, dest);
}

Open in new window

0
Comment
Question by:JRockFL
  • 2
  • 2
5 Comments
 
LVL 32

Accepted Solution

by:
sarabande earned 250 total points
ID: 41855206
they are template member functions named Map returning type TN.

the first function takes one input argument src of type T. the second one takes two arguments T and TN both by value.

template functions can be arbitrary change their template types. for example, T may be 'int' and TN may be 'std::string'. if the compiler detects a call using the Map member functions, it instantiates the (inlined) template code by replacing the placeholders T and TN with int and std::string. in the current code the Instance.Map function must support the chosen template types, or the compiler will complain.

Sara
1
 
LVL 8

Author Comment

by:JRockFL
ID: 41855259
Ok, I think that makes. I have not used them before. Ultimately, I'm trying to make a basic mapper that will map two lists. I didn't want to code try and code something too fancy that I don't understand.
0
 
LVL 32

Assisted Solution

by:ste5an
ste5an earned 250 total points
ID: 41855266
As your post is tagged C#:

These are Generics.

TN Map<T, TN>(T src) means you have a function where you pass in a parameter named src of type T and you'll get a return value of type TN.
The actual types are defined when you invoke your function.

And last but not least: The return Instance.Map<> indicates that a singelton is used (for whatever reason).
0
 
LVL 8

Author Closing Comment

by:JRockFL
ID: 41855293
Thank you!
0
 
LVL 32

Expert Comment

by:ste5an
ID: 41855352
Templates in C++, while being similar, are not equivalent to Generics in C#.

So are you using C# or C++?
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now