Map file contains entry only for the first instantiation of template function?

98 views Asked by At

Let's suppose I have the following template function in a.h file

#include <iostream>

template <class T>
void foo(T arg)
{
   ...some code...
   std::cout<< arg <<std::endl;
}

And the following code in a.cpp

#include "Header.h"
#include <string>
int main(int argc, char* argv[])
{
    foo<int>(5);
    foo<double>(5.25);
    foo<std::string>("Hello World");
    return 0;
}

When I look into .map file generated by linker (set /MAP (Generate Mapfile) option in VS) for this executable I see only one entry for foo function, which is

0001:000006f0       ??$foo@H@@YAXH@Z           004016f0 f i main.obj

However my assumption was that it should have contained 3 separate entries for foo function (one per instantiation). Viewing map file with Amap shows that this entry corresponds to

 void foo<int>(int) 

function. Can someone please explain why there are no entries for

void foo<std::string>(std::string) 
void foo<double>(double)

functions?

Thank you

0

There are 0 answers