473,569 Members | 2,845 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1344
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.supe rnews.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
3003
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 message when the field is blank and Access will not let me save the record. However, I also have a Close command button with the code: DoCmd.Close...
3
1188
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 it, there needs to be proof to me or my boss. Now, does anyone have any advice on just how I should go about this? I have a small JAVA app. as an...
4
2087
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 my own set of classes. Basically, it's a class that is supposed to be allocated automatically on the stack, and possesess one member which is a...
4
1614
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 Configure(IVisiteProtocol oVisiteProtocol) { this.m_oVisitProtocol = oVisitProtocol;
2
2146
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 tells invalid directory. Nothing works even the sample files in that folder also does not run. I am sure the codings are perfect because they work in...
4
2459
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, "Required Field" Me!PrimaryBusiness.SetFocus End If End Sub
27
4296
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 type was the target of a cast. Of course with a reinterpret_cast nothing complains until the UB bites you in the ass. It seems to me that there...
6
9720
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 sure. First, my assumption is that one thread is attempting to get a single key, while other threads are getting, setting, and deleting different...
125
6505
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 problem. http://www.jilp.org/vol9/v9paper10.pdf Specifically, they measured the overhead of a bounds
0
7695
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...
0
7612
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...
0
7922
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8119
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...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6281
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...
0
5218
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...
0
3637
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
936
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...

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.