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
5 1950
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.
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
[
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 Exception and Throw
|
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? Is this because there could be an exception thrown when
the code creates a std::exception? I would assume that is not the case.
However, if I want...
|
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 that I can return true ok is the routine succeeds but where do
I put the return false; statement id the process fails - I get a compile
error say...
|
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)
{
|
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, paginantion or accepting the add and
remove item events.
What i am observing is that none of the vents are happening... (Sort, page,
or item). I am sure I...
| |
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, 7, 8, 9, 0 };
|
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 this exception as they like and finally show a message to the
user or not. Only in a few occasions I need some special exception
types to behave...
|
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 apply. Can somebody tell
me why?
Thanks,
Jess
|
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.
thanks in advance,
|
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 <iostream>
#include <string>
using namespace std;
|
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...
| |
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...
|
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. ...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
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...
| |