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

avoiding object files

Hello,

I have written a little library which consists of template functions and
classes (99%) and two non-template classes. I'd appreciate very much if I
could use the library by only including some header files without having to
deal with building and linking a library or object files. Are there any
tricks how this can be achieved?
I guess not, but perhaps you know better.

Best regards,
alex
Jul 22 '05 #1
10 1492
Alexander Stippler wrote in news:41******@news.uni-ulm.de in
comp.lang.c++:
Hello,

I have written a little library which consists of template functions
and classes (99%) and two non-template classes. I'd appreciate very
much if I could use the library by only including some header files
without having to deal with building and linking a library or object
files. Are there any tricks how this can be achieved?
I guess not, but perhaps you know better.


Instead of

class non_template
{
// whatever
};

Do:

template < typename = void >
class for_non_template
{
// Whatever (as above).
};

typedef for_non_template<> non_template;

HTH.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #2


Rob Williscroft wrote:
Alexander Stippler wrote in news:41******@news.uni-ulm.de in
comp.lang.c++:
Hello,

I have written a little library which consists of template functions
and classes (99%) and two non-template classes. I'd appreciate very
much if I could use the library by only including some header files
without having to deal with building and linking a library or object
files. Are there any tricks how this can be achieved?
I guess not, but perhaps you know better.


Instead of

class non_template
{
// whatever
};

Do:

template < typename = void >
class for_non_template
{
// Whatever (as above).
};

typedef for_non_template<> non_template;


what does it mean if you use the typename keyword in a template parameter
declaration?

Thanks,

David
Jul 22 '05 #3
David Lindauer wrote in news:41***************@bluegrass.net in
comp.lang.c++:

what does it mean if you use the typename keyword in a template parameter
declaration?


Its exactly the same as when you use class.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #4
Rob Williscroft wrote:
Alexander Stippler wrote in news:41******@news.uni-ulm.de in
comp.lang.c++:
Hello,

I have written a little library which consists of template functions
and classes (99%) and two non-template classes. I'd appreciate very
much if I could use the library by only including some header files
without having to deal with building and linking a library or object
files. Are there any tricks how this can be achieved?
I guess not, but perhaps you know better.


Instead of

class non_template
{
// whatever
};

Do:

template < typename = void >
class for_non_template
{
// Whatever (as above).
};

typedef for_non_template<> non_template;

HTH.

Rob.


That works fine for whole classes, but what about simple objects. I have
only one global variable, which I do not want to give any dummy template
parameter. Just an instantiation of a non-template class. It's only this one
object which forces the creation of a library. Any workaround?

regards,
alex
Jul 22 '05 #5
Alexander Stippler wrote:
/snip/

... I have only one global variable, which I do not want
to give any dummy template parameter. Just an instantiation
of a non-template class. It's only this one object which
forces the creation of a library. Any workaround?


Well, you could declare your global variable "extern" in the header and
demand that the *user* of the library define it somewhere.
Regards,

--
Lionel B

Jul 22 '05 #6
Alexander Stippler wrote in news:41******@news.uni-ulm.de in
comp.lang.c++:
Rob Williscroft wrote:
Alexander Stippler wrote in news:41******@news.uni-ulm.de in
comp.lang.c++:
Hello,

I have written a little library which consists of template functions
and classes (99%) and two non-template classes. I'd appreciate very
much if I could use the library by only including some header files
without having to deal with building and linking a library or object
files. Are there any tricks how this can be achieved?
I guess not, but perhaps you know better.


Instead of

class non_template
{
// whatever
};

Do:

template < typename = void >
class for_non_template
{
// Whatever (as above).
};

typedef for_non_template<> non_template;

HTH.

Rob.


That works fine for whole classes, but what about simple objects. I
have only one global variable, which I do not want to give any dummy
template parameter. Just an instantiation of a non-template class.
It's only this one object which forces the creation of a library. Any
workaround?

inline non_template &object()
{
static non_template obj = non_template();
return obj;
}
Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #7
Rob Williscroft wrote:
Alexander Stippler wrote in news:41******@news.uni-ulm.de in
comp.lang.c++:
Rob Williscroft wrote:
Alexander Stippler wrote in news:41******@news.uni-ulm.de in
comp.lang.c++:

Hello,

I have written a little library which consists of template functions
and classes (99%) and two non-template classes. I'd appreciate very
much if I could use the library by only including some header files
without having to deal with building and linking a library or object
files. Are there any tricks how this can be achieved?
I guess not, but perhaps you know better.
Instead of

class non_template
{
// whatever
};

Do:

template < typename = void >
class for_non_template
{
// Whatever (as above).
};

typedef for_non_template<> non_template;

HTH.

Rob.


That works fine for whole classes, but what about simple objects. I
have only one global variable, which I do not want to give any dummy
template parameter. Just an instantiation of a non-template class.
It's only this one object which forces the creation of a library. Any
workaround?

inline non_template &object()
{
static non_template obj = non_template();
return obj;
}
Rob.


Works in general. But this way I have a function call, not direct access. In
my special situation direct access to the variable is necessary. It is
called '_' and I want to use it for function arguments in special
situations, like A( _ , 1 ) and not A( _(), 1). Thus your solution does not
work for me. I'm afraid, IMO there is no solution.

regards,
alex

Jul 22 '05 #8
Alexander Stippler <st**@mathematik.uni-ulm.de> wrote in message news:<41******@news.uni-ulm.de>...
Rob Williscroft wrote:
Alexander Stippler wrote in news:41******@news.uni-ulm.de in
comp.lang.c++:
Rob Williscroft wrote:

Alexander Stippler wrote in news:41******@news.uni-ulm.de in
comp.lang.c++:

> Hello,
>
> I have written a little library which consists of template functions
> and classes (99%) and two non-template classes. I'd appreciate very
> much if I could use the library by only including some header files
> without having to deal with building and linking a library or object
> files. Are there any tricks how this can be achieved?
> I guess not, but perhaps you know better.
/snip/
I have only one global variable, which I do not want to give any dummy
template parameter. Just an instantiation of a non-template class.
It's only this one object which forces the creation of a library. Any
workaround?

inline non_template &object()
{
static non_template obj = non_template();
return obj;
}
Rob.


That's neat :)
Works in general. But this way I have a function call, not direct access. In
my special situation direct access to the variable is necessary. It is
called '_' and I want to use it for function arguments in special
situations, like A( _ , 1 ) and not A( _(), 1). Thus your solution does not
work for me. I'm afraid, IMO there is no solution.


What exactly is the problem with declaring your object "extern"?

Regards,

--
Lionel B
Jul 22 '05 #9
Lionel B wrote:
Alexander Stippler <st**@mathematik.uni-ulm.de> wrote in message
news:<41******@news.uni-ulm.de>...
Rob Williscroft wrote:
> Alexander Stippler wrote in news:41******@news.uni-ulm.de in
> comp.lang.c++:
>
>> Rob Williscroft wrote:
>>
>>> Alexander Stippler wrote in news:41******@news.uni-ulm.de in
>>> comp.lang.c++:
>>>
>>>> Hello,
>>>>
>>>> I have written a little library which consists of template functions
>>>> and classes (99%) and two non-template classes. I'd appreciate very
>>>> much if I could use the library by only including some header files
>>>> without having to deal with building and linking a library or object
>>>> files. Are there any tricks how this can be achieved?
>>>> I guess not, but perhaps you know better.
/snip/
>> I have only one global variable, which I do not want to give any dummy
>> template parameter. Just an instantiation of a non-template class.
>> It's only this one object which forces the creation of a library. Any
>> workaround?
>>
>
> inline non_template &object()
> {
> static non_template obj = non_template();
> return obj;
> }
>
>
> Rob.


That's neat :)
Works in general. But this way I have a function call, not direct access.
In my special situation direct access to the variable is necessary. It is
called '_' and I want to use it for function arguments in special
situations, like A( _ , 1 ) and not A( _(), 1). Thus your solution does
not work for me. I'm afraid, IMO there is no solution.


What exactly is the problem with declaring your object "extern"?

Regards,


We want to achieve the most simple way of usage for our library since users
are students with very poor knowledge of C++ and software development at
all. They shall do numerical exercises with it (and have already done
successfully one semester).
Declaring '_' as extern would require the user to define it somewhere. On
the other hand this tiny little '_' object is a really nice piece of
syntactic sugar, we do not want to miss anymore. But it's also the one
single piece of code which prevents us from having the whole library to be
used by including headers only.

regards,
alex
Jul 22 '05 #10
Alexander Stippler <st**@mathematik.uni-ulm.de> wrote in message news:<41******@news.uni-ulm.de>...
Lionel B wrote:
Alexander Stippler <st**@mathematik.uni-ulm.de> wrote in message
news:<41******@news.uni-ulm.de>...
/snip/
>> I have only one global variable, which I do not want to give any dummy
>> template parameter. Just an instantiation of a non-template class.
>> It's only this one object which forces the creation of a library. Any
>> workaround?
/snip/
In my special situation direct access to the variable is necessary. It is
called '_' and I want to use it for function arguments in special
situations, like A( _ , 1 ) and not A( _(), 1). Thus your solution does
not work for me. I'm afraid, IMO there is no solution.
What exactly is the problem with declaring your object "extern"?

We want to achieve the most simple way of usage for our library since users
are students with very poor knowledge of C++ and software development at
all. They shall do numerical exercises with it (and have already done
successfully one semester).


Fair enough.
Declaring '_' as extern would require the user to define it somewhere. On
the other hand this tiny little '_' object is a really nice piece of
syntactic sugar, we do not want to miss anymore. But it's also the one
single piece of code which prevents us from having the whole library to be
used by including headers only.


I have to confess that having a variable called '_' sounds to me like
a recipe for generating fabulously opaque compiler errors (especially
for "students with very poor knowledge of C++" ...?).

That said, surely even the most computer-illiterate student could be
persuaded to copy-and-paste the line:

underscore_object_type _;

into a source file? Perhaps they might be enticed with:

#define MY_TEACHER_TOLD_ME_TO_PUT_THIS_HERE underscore_object_type _;

;)

--
Lionel B
Jul 22 '05 #11

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

Similar topics

15
by: Ville Vainio | last post by:
Pythonic Nirvana - towards a true Object Oriented Environment ============================================================= IPython (by Francois Pinard) recently (next release - changes are...
1
by: Des Perado | last post by:
We have an elderly DOS-based system running on a Novell Netware server here, and an extensive intranet. Quite recently the board decided that some crucial info from the DOS system was to be made...
11
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some...
11
by: google_groups3 | last post by:
Hi all. I currently have 2 text files which contain lists of file names. These text files are updated by my code. What I want to do is be able to merge these text files discarding the...
12
by: google_groups3 | last post by:
Hi all. I currently have 2 text files which contain lists of file names. These text files are updated by my code. What I want to do is be able to merge these text files discarding the...
6
by: Gregory Gadow | last post by:
In a VB.Net 2.0 project, I have a WizardClass that contains a List (of RuleClass). Each rule needs access to variables within it's parent wizard, so the constructor for RuleClass is New (ByVal...
0
by: Stefan Schwarzer | last post by:
Hi all! For my FTP library module ftputil , some users have asked for a way to avoid server timeouts (FTP status code 421). But I haven't found out yet how I can do this in all cases. I try...
11
by: Bob Nelson | last post by:
It's been a long time since I've posed a query here on c.l.c. My work environment evolved to primarily C++ and Perl with very little C, so I've forgotten quite a lot over time. This revisits the...
1
by: tomb | last post by:
I wasn't sure which group was the correct one for this question. I am in the design phase of an application, and I'm not sure about a specific point about datasets and xml files. Is it true,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.