473,809 Members | 2,804 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

STL-container used with references

hi!

normally i would simply do the following:

std::vector<Ele ment> vec;
void somefunc() {
Element e;
vec.push_back(e );
}

now Element e is in the vector. thats fine as long as no polymorphic
behaviour is needed.

std::vector<Ele ment &> vec;
void somefunc() {
Derived_from_El ement e;
vec.push_back(e ); //bad idea,.. e is gone after functionscope is left
}

what i want to avoid (if possible) are 2 things:
dynamic allocation of the objects, and having an extracontiner for every
type derived from the basetype to store the elements.

i hope, i made clear what i'm trying to do... so is there a solution (except
for the 2 mentioned above?)

thx, regards,
sev
Jul 22 '05
32 1794
"Dietmar Kuehl" <di***********@ yahoo.com> wrote in message
news:5b******** *************** ***@posting.goo gle.com...
tom_usenet <to********@hot mail.com> wrote:
How long till Dinkumware starts to track TR1 extensions? Will you wait
until its almost finalised or even finished (the conservative,
possibly sensible approach)?
I cannot speak for Dinkumware, of course, but I know that library writers
are already implementing what is currently in the TR. Actually, quite a
few of the defects we processed two weeks ago seem to come from people
implementing the TR.

Of course, this is no indication when there will be a release of the TR
components, even if they closely track what is going on: since there are
probably still some changes which will be applied, I think it would be
unwise to release an implementation of the TR libraries just now. I would
expect that you will be able to purchase or download a version relatively
soon after the TR is finalized. I'm always confusing the data but I think
the plan is to try and essentially finalize the TR at the next meeting ie.
in October in Redmont.


Correct, and as Pete Becker indicated, Dinkumware has been implementing all
of
the pieces of TR1 for over a year now. We hope to have a *full* version soon
after the document freezes, which we still hope will be this October. Note
that it's a *very big* addition, including all of the functions added to C
with C99.
BTW, does anybody have a good open source implementation of the special
functions in the lib TR? Well, not necessarily in C or C++ but at least
the same functionality - or an idea how this stuff can be implemented?
Some people apparently know how to do such stuff but I considered numerics
a waste of time while at the university and in any case they didn't talk
about computing these functions anyway (as far as I can remember...).


The C committee has asked for an appendix to their special functions TR
to indicate at least some way to implement each of these functions. Our
work to date has unearthed a few free functions that are excellent, quite
a few that are barely adequate to float precision, and numerous approaches
that are mediocre but make a reasonable starting point. If there's a
complete, high quality set out there we haven't found it yet. They're
pretty tough, in general.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 22 '05 #31
> maybe even better, use a container that takes ownership of the pointers.

checkout the ptr_container lib in the boost sandbox.

br

Thorsten


Now THIS is finally what I've been waiting for for the last 5 years -
a crucial missing piece - I do certainly hope that the ptr_container
will make it into the official boost branch and from there as quickly
as possible into the standard (or the tr).
In the last years I've continuously pointed out that omission and
tried to provide workarounds that deal with STL containers of pointers
- most of the time people seemed just happy with containers of
shared_ptr's but the main point is and was, that it is dangerous and
yet at the same time possible to use normal pointers in STL
containers: dangerous because algorithms can be innocently applied (as
long as the functors are written appropriately) and yet have
devastating effects (leaks and crashes - see my Short Tip in C++ Users
Journal: "A remove_if for vector", C/C++ Users Journal, July 2001. ).
If finally a dedicated version of the STL containers exist (like
ptr_container delivers) users will be guided the correct way - thats
why I appreciate this library so much.
Jul 22 '05 #32
> maybe even better, use a container that takes ownership of the pointers.

checkout the ptr_container lib in the boost sandbox.

br

Thorsten


Now THIS is finally what I've been waiting for for the last 5 years -
a crucial missing piece - I do certainly hope that the ptr_container
will make it into the official boost branch and from there as quickly
as possible into the standard (or the tr).
In the last years I've continuously pointed out that omission and
tried to provide workarounds that deal with STL containers of pointers
- most of the time people seemed just happy with containers of
shared_ptr's but the main point is and was, that it is dangerous and
yet at the same time possible to use normal pointers in STL
containers: dangerous because algorithms can be innocently applied (as
long as the functors are written appropriately) and yet have
devastating effects (leaks and crashes - see my Short Tip in C++ Users
Journal: "A remove_if for vector", C/C++ Users Journal, July 2001. ).
If finally a dedicated version of the STL containers exist (like
ptr_container delivers) users will be guided the correct way - thats
why I appreciate this library so much.
Jul 22 '05 #33

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

Similar topics

2
4797
by: Jean-Baptiste | last post by:
Hi, I am currently porting a C++ project (linux version) under windows. This project uses the STL stuff. When I try to compile and built my project, I get a lot of errors. The main part of them seems to be due to the stl library. Indeed, it seems that the standard libary redefines some structure already defined in xutility. I tryed some tricks without any success.
5
2106
by: Scott Brady Drummonds | last post by:
Hi, everyone, A coworker and I have been pondering a memory allocation problem that we're having with a very large process. Our joint research has led us to the conclusion that we may have to replace the STL allocator. But, before I even attempt something like this, I wanted to ask some questions to this group: 1) We read online that STL caches allocated memory so that containers and their contents that are freed at one point in...
5
4239
by: Khalid | last post by:
II am allocating alot of memory for my problem model which uses stl containers for these pointers, will stl free the memory? by other words what is the semantics of memory ownership in stl? thanks a lot kh
11
2575
by: RR | last post by:
I have Plauger's book on STL and I've found that it's different from the STL I have on a Linux box (libstdc++-2.96-112). In particular, the map::erase(iterator) method I have returns nothing (void), not "iterator". So, does the latest C++ Standards document (INCITS/ISO/IEC 14882-2003) contain the definitive current standard for STL and all its templates? Is that the recommended document to find the correct STL semantics, or is
0
1474
by: Tony Johansson | last post by:
Hello! I have two classes called Handle which is a template class and a class Integer which is not a template class. The Integer class is just a wrapper class for a primitive int with some methods. I don't show the Integer class because it will not add any information to my problem. Main is using some STL function. In main you put in nodes in the STL list and you can display the STL list and other things such as erase some value from...
0
1869
by: rajd99 | last post by:
Hi, I am getting the following error while compiling with sun C++ 5.5 and using SGI STL. Has anyone run into this. The SGI headers are one at http://www.sgi.com/tech/stl/download.html Thanks, #include <stl/string> class ASPString : public stl::string { public:
32
2008
by: Conrad Weyns | last post by:
I have recently gone back to doing some work in c, after years of c++, but I find the lack of templates and in particular the container in the stl to be a huge show stopper. There are math libs, plotting libs, graphic libs etc but I what about some usefull container lib. Any ideas anyone? regards, Conrad Weyns
7
1993
by: rodrigostrauss | last post by:
I'm using Visual Studio 2005 Professional, and I didn't find the STL.NET. This code: #include "stdafx.h" #include <vector> using namespace System; using namespace std; int main(array<System::String ^> ^args)
15
2036
by: Herby | last post by:
This is a follow on from my previous thread about clr/safe and STL.NET http://groups.google.com/group/microsoft.public.dotnet.languages.vc/browse_thread/thread/0eb9b25a83bc02df/b170a89dbc67c332#b170a89dbc67c332 A more specific problem now is migrating the current MFC serialization onto STL serialization? How best to serilize using STL? STL does not seem to directly support the concept of serialization in
20
1840
by: Andrew Roberts | last post by:
Any more info on this? Anyone know when it will be released?
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10378
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
10391
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
9200
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
7664
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
6881
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
5550
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
5690
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3015
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.