473,225 Members | 1,223 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,225 software developers and data experts.

template export question

Hello.

Excerpt from ISO/IEC 14882 :
14/6
A namespace-scope declaration or definition of ........skipped...... a non-
inline member function of a class template or a static data member of a class
template may be preceded by the export keyword.

and from http://www.comeaucomputing.com/4.3.0...5+/43stuff.txt :
A template must be declared export at both the point of definition and
the point of reference.

I have some files:

//templ.h
template<class T>
class A
{
public:
void fun();
static int i_;
};
//I want to export A<T>::fun and A<T>::i_, but I do not want to declare class
//A as exported

//def.cpp
//1!
//exported definitions are here, ordering problems?
//fun first declared as non-exported and later as exported?

export template<class T>
void A<T>::fun()
{
}

export template<class T>
int A<T>::i_ = 0;

//user.cpp
//2! here's class usage

#include "templ.h"

int main()
{
A<int>a;
a.fun();
}

How can I declare A<T>::fun in user.cpp as exported at the point of reference?
Jul 22 '05 #1
10 1906

"New_user" <tp*****@mail.ru> wrote in message
news:d2*************************@posting.google.co m...
Hello.

Excerpt from ISO/IEC 14882 :
14/6
A namespace-scope declaration or definition of ........skipped...... a non- inline member function of a class template or a static data member of a class template may be preceded by the export keyword.

and from http://www.comeaucomputing.com/4.3.0...5+/43stuff.txt :
A template must be declared export at both the point of definition and
the point of reference.

I have some files:

//templ.h
template<class T>
class A
{
public:
void fun();
static int i_;
};
//I want to export A<T>::fun and A<T>::i_, but I do not want to declare class //A as exported
The effect would be exactly the same if you do this:

//templ.h
export template <class T>
class A {
public:
void fun();
static int i_;
};
"export" in def.cpp is then redundant.

//def.cpp

#include "templ.h"

template<class T>
void A<T>::fun()
{}

template<class T>
int A<T>::i_ = 0;

Regards,
Sumit.

//def.cpp
//1!
//exported definitions are here, ordering problems?
//fun first declared as non-exported and later as exported?

export template<class T>
void A<T>::fun()
{
}

export template<class T>
int A<T>::i_ = 0;

//user.cpp
//2! here's class usage

#include "templ.h"

int main()
{
A<int>a;
a.fun();
}

How can I declare A<T>::fun in user.cpp as exported at the point of

reference?
Jul 22 '05 #2

"New_user" <tp*****@mail.ru> wrote in message
news:d2*************************@posting.google.co m...
Hello.

Excerpt from ISO/IEC 14882 :
14/6
A namespace-scope declaration or definition of ........skipped...... a non- inline member function of a class template or a static data member of a class template may be preceded by the export keyword.

and from http://www.comeaucomputing.com/4.3.0...5+/43stuff.txt :
A template must be declared export at both the point of definition and
the point of reference.

I have some files:

//templ.h
template<class T>
class A
{
public:
void fun();
static int i_;
};
//I want to export A<T>::fun and A<T>::i_, but I do not want to declare class //A as exported
The effect would be exactly the same if you do this:

//templ.h
export template <class T>
class A {
public:
void fun();
static int i_;
};
"export" in def.cpp is then redundant.

//def.cpp

#include "templ.h"

template<class T>
void A<T>::fun()
{}

template<class T>
int A<T>::i_ = 0;

Regards,
Sumit.

//def.cpp
//1!
//exported definitions are here, ordering problems?
//fun first declared as non-exported and later as exported?

export template<class T>
void A<T>::fun()
{
}

export template<class T>
int A<T>::i_ = 0;

//user.cpp
//2! here's class usage

#include "templ.h"

int main()
{
A<int>a;
a.fun();
}

How can I declare A<T>::fun in user.cpp as exported at the point of

reference?
Jul 22 '05 #3

"Sumit Rajan" <su********@myrealbox.com> wrote in message
news:c5*************@ID-206022.news.uni-berlin.de...

"New_user" <tp*****@mail.ru> wrote in message
news:d2*************************@posting.google.co m...

How can I declare A<T>::fun in user.cpp as exported at the point of

reference?

Sorry. Please disregard that post. I missed that question when I read
through your message. :-)
Jul 22 '05 #4

"Sumit Rajan" <su********@myrealbox.com> wrote in message
news:c5*************@ID-206022.news.uni-berlin.de...

"New_user" <tp*****@mail.ru> wrote in message
news:d2*************************@posting.google.co m...

How can I declare A<T>::fun in user.cpp as exported at the point of

reference?

Sorry. Please disregard that post. I missed that question when I read
through your message. :-)
Jul 22 '05 #5

"Sumit Rajan" <su********@myrealbox.com> wrote in message
news:c5*************@ID-206022.news.uni-berlin.de...

"New_user" <tp*****@mail.ru> wrote in message
news:d2*************************@posting.google.co m...

How can I declare A<T>::fun in user.cpp as exported at the point of

reference?

Sorry. Please disregard that post. I missed that question when I read
through your message. :-)

Jul 22 '05 #6

"Sumit Rajan" <su********@myrealbox.com> wrote in message
news:c5*************@ID-206022.news.uni-berlin.de...

"New_user" <tp*****@mail.ru> wrote in message
news:d2*************************@posting.google.co m...

How can I declare A<T>::fun in user.cpp as exported at the point of

reference?

Sorry. Please disregard that post. I missed that question when I read
through your message. :-)

Jul 22 '05 #7
New_user wrote:

Hello.

Excerpt from ISO/IEC 14882 :
14/6
A namespace-scope declaration or definition of ........skipped...... a non-
inline member function of a class template or a static data member of a class
template may be preceded by the export keyword.

and from http://www.comeaucomputing.com/4.3.0...5+/43stuff.txt :
A template must be declared export at both the point of definition and
the point of reference.
[snip]
How can I declare A<T>::fun in user.cpp as exported at the point of reference?


If I understand you correctly you don't want to declare your templates with the
export keyword at the point you are using them and still want them to be resolved
as exported? If so, I would guess that would not do. I take 14/6 and 14/8 to mean
that the first declaration of exported templates in /each/ of the translation units
must use the export keyword; subsequent redeclarations or definitions do not need to
use "export"; one and only one of the translation units must provide a definition.

I am not quite sure and would like to confirm if the above is correct, for myself.

It may sound ugly, but if you don't want to go the inclusion way I'd consider
explicit instantiation.

Denis
Jul 22 '05 #8
New_user wrote:

Hello.

Excerpt from ISO/IEC 14882 :
14/6
A namespace-scope declaration or definition of ........skipped...... a non-
inline member function of a class template or a static data member of a class
template may be preceded by the export keyword.

and from http://www.comeaucomputing.com/4.3.0...5+/43stuff.txt :
A template must be declared export at both the point of definition and
the point of reference.
[snip]
How can I declare A<T>::fun in user.cpp as exported at the point of reference?


If I understand you correctly you don't want to declare your templates with the
export keyword at the point you are using them and still want them to be resolved
as exported? If so, I would guess that would not do. I take 14/6 and 14/8 to mean
that the first declaration of exported templates in /each/ of the translation units
must use the export keyword; subsequent redeclarations or definitions do not need to
use "export"; one and only one of the translation units must provide a definition.

I am not quite sure and would like to confirm if the above is correct, for myself.

It may sound ugly, but if you don't want to go the inclusion way I'd consider
explicit instantiation.

Denis
Jul 22 '05 #9
Hello, Denis.
If I understand you correctly you don't want to declare your templates with the
export keyword at the point you are using them and still want them to be resolved
as exported?


No. I just want to understand, how can I declare a non-inline
member-function of a class template (not a member template) or how can
I declare a static data-member of a class template as exported? It
seems to me, the only way is to declare class as exported. But
Standard says, that declaration of a non-inline member-function (or
static data-member) can be preceeded by the 'export' keyword.
Jul 22 '05 #10
Hello, Denis.
If I understand you correctly you don't want to declare your templates with the
export keyword at the point you are using them and still want them to be resolved
as exported?


No. I just want to understand, how can I declare a non-inline
member-function of a class template (not a member template) or how can
I declare a static data-member of a class template as exported? It
seems to me, the only way is to declare class as exported. But
Standard says, that declaration of a non-inline member-function (or
static data-member) can be preceeded by the 'export' keyword.
Jul 22 '05 #11

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

Similar topics

8
by: LaBird | last post by:
Hi, I have a simple question about templates. When I have a class definition like this in "class.h": template <typename T> class C { T p; public:
2
by: Ben | last post by:
Hi. I am currently trying to move compilers (VC6 -> VC7 in fact) and I'm having a few problems (so far exclusively to do with better standard conformance). Anyhow, whilst rebuilding a...
10
by: New_user | last post by:
Hello. Excerpt from ISO/IEC 14882 : 14/6 A namespace-scope declaration or definition of ........skipped...... a non- inline member function of a class template or a static data member of a...
5
by: Nomak | last post by:
Hello all, i have two template classes which needs each other. I tried to write some fwd decl / decl / impl in a good way but i can't get it to compile. Explanations: - .hh files are for...
15
by: iuweriur | last post by:
A few questions on the curiously recurring template pattern: This page: http://c2.com/cgi/wiki?CuriouslyRecurringTemplate this part: template<typename T> struct ArithmeticType { T operator...
8
by: William Payne | last post by:
As the title says, is something like this legal: template<typename T> class foo { public: static T* t; }; T* foo::t;
14
by: Jess | last post by:
Hello, I was told that if I have a template class or template function, then the definitions must be put into the header file where I put the declarations. On the other hand, it is generally...
3
by: djsuson | last post by:
I'm trying to set up an inheritance tree that also uses templates. This is an attempt to simplify some previous code that was filled with redundancies. I'm working with g++ 3.4.6. The code is split...
8
by: Tim Frink | last post by:
Hi, I want to use a callback function together with templates. Let's say I've this code: File a.h: class A { private:
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.