473,883 Members | 2,961 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1519
Alexander Stippler wrote in news:41******@n ews.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_templat e
{
// Whatever (as above).
};

typedef for_non_templat e<> non_template;

HTH.

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


Rob Williscroft wrote:
Alexander Stippler wrote in news:41******@n ews.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_templat e
{
// Whatever (as above).
};

typedef for_non_templat e<> 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******** *******@bluegra ss.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******@n ews.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_templat e
{
// Whatever (as above).
};

typedef for_non_templat e<> 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******@n ews.uni-ulm.de in
comp.lang.c++:
Rob Williscroft wrote:
Alexander Stippler wrote in news:41******@n ews.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_templat e
{
// Whatever (as above).
};

typedef for_non_templat e<> 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******@n ews.uni-ulm.de in
comp.lang.c++:
Rob Williscroft wrote:
Alexander Stippler wrote in news:41******@n ews.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_templat e
{
// Whatever (as above).
};

typedef for_non_templat e<> 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**@mathemati k.uni-ulm.de> wrote in message news:<41******@ news.uni-ulm.de>...
Rob Williscroft wrote:
Alexander Stippler wrote in news:41******@n ews.uni-ulm.de in
comp.lang.c++:
Rob Williscroft wrote:

Alexander Stippler wrote in news:41******@n ews.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**@mathemati k.uni-ulm.de> wrote in message
news:<41******@ news.uni-ulm.de>...
Rob Williscroft wrote:
> Alexander Stippler wrote in news:41******@n ews.uni-ulm.de in
> comp.lang.c++:
>
>> Rob Williscroft wrote:
>>
>>> Alexander Stippler wrote in news:41******@n ews.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

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

Similar topics

15
2297
by: Ville Vainio | last post by:
Pythonic Nirvana - towards a true Object Oriented Environment ============================================================= IPython (by Francois Pinard) recently (next release - changes are still in CVS) got the basic abilities of a system shell (like bash). Actually, using it as a shell is rather comfortable. This all made me think... Why do we write simple scripts to do simple things? Why do we serialize data to flat text files in...
1
1597
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 available to senior management via the intranet. After some initial design problems (OK, after severely scratching our heads at the HOW? question) we were quite pleased with our solution: a background process in the DOS system gathers the data and...
11
3149
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 useful utils that more pages on that server can use. As an example, I have created a Page Counter class that opens an Access .mdb file, counts the current entries for that page, and adds a new entry with some information regarding the current...
11
1404
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 duplicates. And to make it harder (or not???!!) my criteria for defining the duplicate is the left 15 (or so) characters of the file path.
12
1433
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 duplicates. And to make it harder (or not???!!) my criteria for defining the duplicate is the left 15 (or so) characters of the file path. Help, as always, is greatly appreciated!
6
1083
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 Wizard as WizardClass). Each rule then has a property Private Wiz as WizardClass, which is set in Sub New with Wiz = Wizard. Currently there is only one Wizard in the project but there might be more in the future to handle different rulesets. My...
0
1670
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 to explain the problem in more detail. The following is rather special and probably not so easy to understand, but I'll do my best. Please ask if you need more information.
11
1454
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 much-discussed topic of decrementing a pointer to the non-existent location before the start of an array. I've been re-reading K.N. King's ``C Programming: A Modern Approach'' and came across ``reverse2.c'' on page 228, which raised a red flag. I...
1
1492
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, that multiple dataset objects can read from and write to the same dataset xml file without causing any conflicts? Thanks for your input.
0
9944
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...
0
10762
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10863
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
9586
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...
0
5807
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6005
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4622
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
4228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3241
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.