|
-
December 15th, 2003, 07:42 AM
#1
Compiling tempate class implementation into a lib file
If any one wants to distribute it's code containing implementation of template classes and he doen't want anyone to see the code, then obviously he would have to make a library file for that.
I've been reading solutions for compiling template classes, but all those require text files, such as h and/or .cpp.
Now, could you tell me how to hide the implementation code of template classes or in other words, a way to produce a library file that can be distributed to others, so they can't see the code.
There must be a solution, otherwise how c++ compiler vendors made those standard template libraries?
-
December 15th, 2003, 10:33 AM
#2
You really can't... As you have already been told in another thread!
And all of the STL code is right there in the header files.
-
December 15th, 2003, 12:20 PM
#3
Hamid,
All of the answers in the other post as well as the response in this post are correct. Normal template programming must be included and visible to the user for instantiation.
The usual implementations of the STL (Standard Template Library) do, in fact, rely on template programming which can not be hidden from the user.
There is a mechanism in the C++ standard called export. The export keyword should allow one to embed the templated code within a C++ source file. However, I do not have any experience with the export keyword and support for this language feature is rare.
Good luck.
Sincerely, Chris.
You're gonna go blind staring into that box all day.
-
December 15th, 2003, 01:53 PM
#4
Exported templates only exist as compiler-specific extensions.
All the buzzt
CornedBee
-
February 25th, 2004, 12:25 PM
#5
Originally posted by Assmaster
You really can't... As you have already been told in another thread!
And all of the STL code is right there in the header files.
Note that ten days after this was posted, I was told that that is not true. See STL and Linux wherein I said:
There is not a library for the STL. The STL is (usually) only source code and exists entirely in the headers.
and the response was:I wonder what the truth is.
-
February 25th, 2004, 01:42 PM
#6
Originally posted by Sam Hobbs
I wonder what the truth is.
The standard certainly does not dictate this one way or the other. In fact there does not have to be a file corresponding to <map>. It could be a special symbol handled entirely by the compiler.
A compiler could require linking with a library to use certain features of STL. I don't think this violates any rule of the standard.
Jeff
-
February 25th, 2004, 05:32 PM
#7
I think that for a while the Dinkumware version of the STL provided the implementation of basic_*stream in .cpp file, using the exported templates feature of MSC++. This meant that only the char and wchar_t versions could be used though.
All the buzzt
CornedBee
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|