473,322 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

getting Error :: explicitly instantiate functional Template

Hi All ,

i writing a shared library ,containing code in template
i trying to explicitly instantiate functional & class
template ........But i am getting Error

#include<iostream>
#include "commonfile.h"

template<typename T>
const T & min(const T & a , const T & b)
{return (a < b ? a : b );}

template<typename T>
const T & max(const T & a , const T & b)
{return (a < b ? b : a );}

template int max(int,int);
template int min(int,int);
g++ -g commonfile.h commonfile.cc
g++: compilation of header file requested
commonfile.cc:16: template-id `max<int, int>' for `int max(int, int)'
does not
match any template declaration
commonfile.cc:17: template-id `min<int, int>' for `int min(int, int)'
does not
match any template declaration
Sep 15 '08 #1
3 1387
Pallav singh wrote:
Hi All ,

i writing a shared library ,containing code in template
i trying to explicitly instantiate functional & class
template ........But i am getting Error

#include<iostream>
#include "commonfile.h"

template<typename T>
const T & min(const T & a , const T & b)
{return (a < b ? a : b );}

template<typename T>
const T & max(const T & a , const T & b)
{return (a < b ? b : a );}

template int max(int,int);
template<int max(int,int);

--
Ian Collins.
Sep 15 '08 #2
On Sep 15, 1:16*pm, Ian Collins <ian-n...@hotmail.comwrote:
Pallav singh wrote:
Hi All ,
i writing a *shared library ,containing code in template
i trying to explicitly instantiate functional & class
template *........But i am getting Error
#include<iostream>
#include "commonfile.h"
template<typename T>
const T & min(const T & a , const T & b)
{return (a < b ? a : b );}
template<typename T>
const T & max(const T & a , const T & b)
{return (a < b ? b : a );}
template int max(int,int);

template<int max(int,int);

--
Ian Collins.
+++++++++++++++++++++++++++++++++++++++++++++
Hi Ian

After using following way of expilicit Instantiation ....compilation
Error goes
But i donot find Symbol w.r.t. function's in my Object File...

Currently i am using gcc version 3.2.3

template<int,intint max(int,int);
template<int,intint min(int,int);
>nm --demangle commonfile.o
U __cxa_atexit
U __dso_handle
00000056 t _GLOBAL__I_commonfile.ccTMZ5vb
U __gxx_personality_v0
0000003e t __tcf_0
00000000 t __static_initialization_and_destruction_0(int, int)
U std::ios_base::Init::Init[in-charge]()
U std::ios_base::Init::~Init [in-charge]()
00000000 b std::__ioinit
Sep 15 '08 #3
Pallav singh wrote:
On Sep 15, 1:16 pm, Ian Collins <ian-n...@hotmail.comwrote:
>Pallav singh wrote:
>>Hi All ,
i writing a shared library ,containing code in template
i trying to explicitly instantiate functional & class
template ........But i am getting Error
#include<iostream>
#include "commonfile.h"
template<typename T>
const T & min(const T & a , const T & b)
{return (a < b ? a : b );}
template<typename T>
const T & max(const T & a , const T & b)
{return (a < b ? b : a );}
template int max(int,int);
template<int max(int,int);
Hi Ian

After using following way of expilicit Instantiation ....compilation
Error goes
But i donot find Symbol w.r.t. function's in my Object File...

Currently i am using gcc version 3.2.3

template<int,intint max(int,int);
template<int,intint min(int,int);
These aren't specialisations.

The specialisations would be declared as

template<const int& max( const int&, const int&);
template<const int& min( const int&, const int&);

and will have to be defined somewhere in your application.

--
Ian Collins.
Sep 15 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Simon | last post by:
Hi, I'm having a problem with templates and specialisation. I'm using it to overload the same function so it can return different things. I can't see what I'm doing wrong, although my compiler...
0
by: Zach | last post by:
Using Dev-C++ 4.9.8.5 I get error: Compiler: Default compiler Executing g++.exe... g++.exe "C:\winroot\src\c++\stupid_tricks\functor_trick.cpp" -o...
3
by: Lord Labakudas | last post by:
Hi, I have the following simple template implementation: // -------------- b.h ----------------- // template <class t> class b { public: b() ;
6
by: c++newbie | last post by:
Hi all, I try to compile the following classes: main.cpp: #include <algorithm> #include <iostream> #include <fstream> #include <iterator>
1
by: Red | last post by:
I am taking a c++ course. I have a simple program that just wont compile and I cant seem to figure out why. If I compile the class file without referencing it in the int main() it will compile but...
3
by: little.freaky | last post by:
Hello group, I have a problem with template classes and inheritance. I've searched on the internet to find a solution but all the examples look the same as my code (as far as I can tell) and I...
5
by: dascandy | last post by:
The following program produces no warnings, no errors, but doesn't do what I expect it to. I expect it to produce a warning or error. What does the standard say about this and/or what should it...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
2
by: subramanian100in | last post by:
consider the following program #include <iostream> using namespace std; class Rec { public: Rec(int arg = 10) : val(arg) { }
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.