473,655 Members | 3,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exporting templates


I'm writing code at the moment which I intend to be 100% portable and
well-defined in line with the current C++ Standard.

I like the "export" feature, whereby I can put template functions in
source files (where I feel they belong -- unless I intend them to be
inline, of course).

I realise, however, that the majority of compilers are defective in that
they do not implement the "export" feature.

I see that the FAQ offers an alternative:

//header.hpp
template<class T>
T Get();

#ifdef UNSUPPORTED_EXP ORT_KEYWORD
#include "header.cpp "
#endif
//header.cpp
#ifdef UNSUPPORTED_EXP ORT_KEYWORD
#define export
#endif

export template<class T>
T Get()
{
return 0;
}
Do many of you here use this? I'm thinking of starting to use it in my
code. I'm going to put a "readme" file with it saying:

If your compiler doesn't implement the "export" feature, then define blah
blah...

While I'm at it, are there any othere things in the C++ Standard that
aren't done properly by a lot of compilers?

-Tomás
Feb 18 '06 #1
4 1556
Tomás wrote:
[...]
I'm going to put a "readme" file with it saying:

If your compiler doesn't implement the "export" feature, then define blah
blah...


Try 'if your compiler implements the "export" feature,
then _undefine_ blah blah'. Compilers that support 'export'
are in the minority :)

- J.
Feb 18 '06 #2

Tomás wrote:
I'm writing code at the moment which I intend to be 100% portable and
well-defined in line with the current C++ Standard.
<snip discussion of the technique in FAQ 35.14>
Do many of you here use this? I'm thinking of starting to use it in my
code. I'm going to put a "readme" file with it saying:

If your compiler doesn't implement the "export" feature, then define blah
blah...
Having never used the technique I can't usefully comment on it, however
....
While I'm at it, are there any othere things in the C++ Standard that
aren't done properly by a lot of compilers?


.... if you are trying to write portable and conformant code, one issue
you may run into is the <cxxx> vs <xxx.h> C library headers. Quite a
lot of compilers (MSVC++ 8, Comeau online last time I checked, GCC
3.4.2 in Dev C++) implement the <cxxx> headers incorrectly in that C
library names are placed in the global namespace as well as namespace
std. So if you forget to prepend printf with std:: your code will be
incorrect but the compiler won't complain.

Gavin Deane

Feb 18 '06 #3
Tomás wrote:

I'm writing code at the moment which I intend to be 100% portable and
well-defined in line with the current C++ Standard.

I like the "export" feature, whereby I can put template functions in
source files (where I feel they belong -- unless I intend them to be
inline, of course).

I realise, however, that the majority of compilers are defective in that
they do not implement the "export" feature.
One could argue that it might be the standard that is defective. If the
majority of compilers don't implement that feature even 7 years after the
standard was released, this indicates that this feature is problematic.
I see that the FAQ offers an alternative:

//header.hpp
template<class T>
T Get();

#ifdef UNSUPPORTED_EXP ORT_KEYWORD
#include "header.cpp "
#endif
//header.cpp
#ifdef UNSUPPORTED_EXP ORT_KEYWORD
#define export
#endif

export template<class T>
T Get()
{
return 0;
}
Do many of you here use this?
I don't see any real advantage in this. Usually, you do such things if
several compilers must be treated differently, but the non-export version
works on all compilers, so IMHO, this just adds unnecessary clutter.
While I'm at it, are there any othere things in the C++ Standard that
aren't done properly by a lot of compilers?


Maybe two-phase lookup.
Feb 18 '06 #4
In article <kG************ ******@news.ind igo.ie>,
"Tomás" <NU**@NULL.NULL > wrote:
I'm writing code at the moment which I intend to be 100% portable and
well-defined in line with the current C++ Standard.
Do it like they do it at "boost.org" . They have several defines to get
around compiler problems already in their library. Use them and maybe
one day, you can submit your stuff for inclusion in their library.
I see that the FAQ offers an alternative:

//header.hpp
template<class T>
T Get();

#ifdef UNSUPPORTED_EXP ORT_KEYWORD
#include "header.cpp "
#endif
//header.cpp
#ifdef UNSUPPORTED_EXP ORT_KEYWORD
#define export
#endif

export template<class T>
T Get()
{
return 0;
}

boost.org doesn't do the above...

--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Feb 18 '06 #5

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

Similar topics

3
9237
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works only exporting to single worksheet. but i need to export data to multiple worksheets. it is very urgent to us. so please help me in code.
1
10507
by: Alex | last post by:
Hi all, I've seen this noted in many posts, but nothing I've checked out gives me any clue on how to do this. Basically as my topic says, I have a DTS and I simply need to export some data from a table in MS SQL 2000 to an Excel spreadsheet. I also need to automate this process so it can run nightly and each new day a new spreadsheet will be on a network share for us to pick-up.
1
1944
by: Jacky11 | last post by:
I have a column name the Data type is MEMO The input is more than thousands of characters. When exporting, not all the information is exported. Who can I correct this problem? Thanks
2
7995
by: Kenneth | last post by:
How do I remove the limitation in Access that deny me from exporting 24000 rows and 17 columns (in a query) into Excel? Kenneth
3
3833
by: gowens | last post by:
I have an ASP.Net multi-part tabbed page. One of the tab pages contains several controls (including a DataList). The DataList contains, virtually-rendered, Database images and some text fields. We'd like to take the content and format of the DataList to create a Word document (album) for the end-users. Is it possible to export the DataList (HTML table, data, etc) to a MS Word document? I haven't found anything that is very clear or...
1
3158
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream As System.IO.MemoryStream = 3 myReport.ExportToStream( ExportFormatType.PortableDocFormat) 4 Response.Clear() 5 Response.Buffer() = True
2
2402
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform exporting ALL data from the datagrid control. Exporting data works fine when I show all data on the datagrid control. I'd like to shows only 30 records on the datagrid control instead of ALL data using page navigation, and perform exporting...
2
3170
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to set this up so as to do it reliably and minimize overhead? There are currently no constraints on the destination table. Assume the user or some configuration specifies the database name, server name, and filename+fullpath. The server is SQL...
2
3158
by: Larry L | last post by:
Hi guys, been a while since I've been on the group, glad to see some regulars are still around! I've got an app that outputs a scale model plan to a printer, printing to a lettersize or a4 sheet of paper. The output is exactly to scale, and if cut and assembled will produce a miniature version of the drawn object. The program is very stable and I rarely get support calls from my users, however I DO get a lot of folks who've downloaded...
0
1708
by: =?Utf-8?B?ZGVuIDIwMDU=?= | last post by:
hi, I trying to export data display on a gridview that supports any language (like chinese, japanese, thai, french) shown here is chinese only. There is no problem exporting english language data, problem starts exporting non-english data using approach shown below, the data is retrieve in database in an xml format. Is there a simple way to be able to make this work? Response.ContentEncoding = System.Text.Encoding.UTF8;
0
8380
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1598
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.