472,373 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,373 software developers and data experts.

Required safety checks


Hello all,

In general, the STL doesn't have to perform safety checks. But there are
some exceptions, and I'm trying to find as many examples as I can. For
example, vector::at() must perform checking and throw an exception if the
safety checks fail. For people who know of cases where the Standard
*requires* a check, please shout it out!

Thanks,
Dave
Jul 22 '05 #1
3 1309
Dave wrote:
In general, the STL doesn't have to perform safety checks. But there are
some exceptions, and I'm trying to find as many examples as I can. For
example, vector::at() must perform checking and throw an exception if the
safety checks fail. For people who know of cases where the Standard
*requires* a check, please shout it out!


Uh... Why don't you get a copy of the Standard and just read all the
"examples" from there. It specifies precisely which functions throw
(or may throw) what exceptions.

V
Jul 22 '05 #2
Dave wrote:
In general, the STL doesn't have to perform safety checks.
But there are some exceptions
and I'm trying to find as many examples as I can.
For example, vector::at() must perform [range] checking
and throw an exception if the safety checks fail.


My GNU C++ compiler defines:

reference
operator[](size_type __n) { return *(begin() + __n); }

const_reference
operator[](size_type __n) const { return *(begin() + __n); }

You could redefine them:

reference
operator[](size_type __n) {
assert(__n < this->size()); return *(begin() + __n); }

const_reference
operator[](size_type __n) const {
assert(__n < this->size()); return *(begin() + __n); }
Jul 22 '05 #3
"Dave" <be***********@yahoo.com> wrote in message
news:10*************@news.supernews.com...

Hello all,

In general, the STL doesn't have to perform safety checks. But there are
some exceptions, and I'm trying to find as many examples as I can. For
example, vector::at() must perform checking and throw an exception if the
safety checks fail. For people who know of cases where the Standard
*requires* a check, please shout it out!


Gimme twenty dollars and I'll tell ya.

No, wait, if you have twenty dollars, you can purchase
your very own copy of the ISO C++ standard, and learn
about this (and many other interesting things) for yourself.
www.webstore.ansi.org Search for "14882".

-Mike
Jul 22 '05 #4

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

Similar topics

3
by: Mark | last post by:
Access97 --- I set the Required property for a field at the table level and I have a form that contains that field. When I click the Close button at the top left of the screen, I get an error...
3
by: George Jackson | last post by:
OK, I am completely new to ASP, .NET, and JAVA and would like some guiding advice. At my company the employees are required to read a safety sheet on our company intranet. Well, after they read...
4
by: st_ev_fe | last post by:
Hi people, I've been doing C for about 7 years now. But I'm new to C++. I've decided that C++'s operator overloading could be very handy. I'm writing something much like auto_ptr, except for...
4
by: Simo | last post by:
hello, can anyone please tell me if the following structure is thread safe visit.cs class Visit : System.Web.UI.Page { //Variables IVisitProtocol m_oVisitProtocol public void...
2
by: c++ newbie | last post by:
I am new to c++ programming I have Borland Turbo c++ ver 3.0 I copied the installed Tcc files from my friends hdd in a cd and pasted it directly into my hdd at d:\lang\tcc\ when i open tc++ it...
4
by: fong.yang | last post by:
I have the following code for a form with a checkbox: If Me!ServiceWork And IsNull(Me!PrimaryBusiness) Then Cancel = True MsgBox "If Service Work is checked, Must Choose Primary Business.", 48,...
27
by: Noah Roberts | last post by:
What steps do people take to make sure that when dealing with C API callback functions that you do the appropriate reinterpret_cast<>? For instance, today I ran into a situation in which the wrong...
6
by: Adam Olsen | last post by:
It seems to be a commonly held belief that basic dict operations (get, set, del) are atomic. However, since I know searching the hash table is a multistep process, I thought I'd check it out for...
125
by: jacob navia | last post by:
We hear very often in this discussion group that bounds checking, or safety tests are too expensive to be used in C. Several researchers of UCSD have published an interesting paper about this...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

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.