473,485 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

STL sort throw exception?

200 New Member
Hello everyone,


In Bjarne's book, it is mentioned that sort of STL may throw exception, like sorting elements in a vector.

In what situation will sort throw exception? I can not find a case.


thanks in advance,
George
Jan 4 '08 #1
5 1942
weaknessforcats
9,208 Recognized Expert Moderator Expert
Where does he mention it??

The sort should not throw although exceptions can be thrown by predicates. You should always presume exceptions whenever you use STL algorithms.
Jan 4 '08 #2
oler1s
671 Recognized Expert Contributor
George, while we have been helping you, your behavior feels very similar to that of a help vampire. Furthermore, you seem to be posting to multiple boards at once. Also see http://cboard.cprogramming.com/showthread.php?t=97544. And http://www.eggheadcafe.com/software/...exception.aspx.

Starting multiple threads on the same question wastes people's time, as they are completely oblivious to other trains of thought. Perhaps you should review how to ask smart questions, an excellent article on the mentality and etiquette on technical forums.

EDIT: This is not the only thread George has been spamming multiple boards. Check his other questions. They have been multi-spammed everywhere, including Usenet.
Jan 4 '08 #3
George2
200 New Member
Hi weaknessforcats,


You can refer to his book, appendix E, Standard-Library Exception Safety, in the 1st sample in E.1 (Introduction).

Where does he mention it??

The sort should not throw although exceptions can be thrown by predicates. You should always presume exceptions whenever you use STL algorithms.

regards,
George
Jan 5 '08 #4
weaknessforcats
9,208 Recognized Expert Moderator Expert
[
You can refer to his book, appendix E, Standard-Library Exception Safety, in the 1st sample in E.1 (Introduction).
He doesn't say that the sort throws an exception.

What is does say is that the code that compares two objects can throw an exception.

There's a difference.

It all comes down to using try/catch blocks liberally when writing C++. To not do that just invites a crash.
Jan 5 '08 #5
George2
200 New Member
Thanks weaknessforcats,


My question is answered.

[

He doesn't say that the sort throws an exception.

What is does say is that the code that compares two objects can throw an exception.

There's a difference.

It all comes down to using try/catch blocks liberally when writing C++. To not do that just invites a crash.

regards,
George
Jan 7 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
458
by: Kerri | last post by:
Hi, I am new to .NET In my Error Logic on my Aspx pages when an error happens it hits my catch statement where I throw an Exception. My question is : what is the difference between Thwo...
3
3479
by: Pierre Rouleau | last post by:
The std::exception class defined in the Standard C++ <exception> header specifies that the constructors could throw any exception becuase they do not have a throw() specification. Why is that? ...
17
1925
by: hplloyd | last post by:
Hi, I have a function that adds data to a database and I want to return true if the database was updated and false if there was a problem, so I am using a try... catch block... My problem is...
6
5704
by: Arjen | last post by:
Hi, I'm reading the enterprise library documentation and there I see the throw statement. try { // run code } catch(Exception ex) {
1
2677
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
6
7840
by: Paul van Brenk | last post by:
When you run the Shuffle method often enough it will throw exception. And I can't figure out why. Anybody? Paul van Brenk the code: static void Shuffle(){ int ints = { 1, 2, 3, 4, 5, 6,...
6
11624
by: Henryk | last post by:
I did a lot of delphi GUI programming recently. In my experience most of the time you just want to throw a standard exception with a descriptive message. Then all calling functions can handle...
28
2815
by: Jess | last post by:
Hello, It is said that if I implement a "swap" member function, then it should never throw any exception. However, if I implement "swap" non- member function, then the restriction doesn't...
4
2214
by: George2 | last post by:
Hello everyone, In Bjarne's book, it is mentioned that sort of STL may throw exception, like sorting elements in a vector. In what situation will sort throw exception? I can not find a case....
6
1940
by: jason.cipriani | last post by:
Consider this program, which defines a template class who's template parameter is the type of an exception that can be thrown by members of the class: === BEGIN EXAMPLE === #include...
0
7090
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,...
0
7161
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...
0
7275
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...
0
5418
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,...
1
4857
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...
0
4551
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...
0
3063
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
595
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
247
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...

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.