Thread: STL sort throw exception?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Good!

    A search in Mingw implementation of algorithms didn't turn up any instances of "throw".
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It is possible that this wording is for precautions only - allowing sort to throw an exception allows implementations to CHOOSE whether they throw an exception under some circumstances or not, whilst stating that it can't limits the implementation to only such ways that can not throw an exception. Just like there are plenty of compilers that allow things that are undefined by the C or C++ standard - because that particular compiler or C runtime has a suitable solution for this undefined behaviour.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Hi Mats,


    I do not agree it is for precautions, but I think he means assignment operator (e.g. when doing swap) may throw exception.

    Quote Originally Posted by matsp View Post
    It is possible that this wording is for precautions only - allowing sort to throw an exception allows implementations to CHOOSE whether they throw an exception under some circumstances or not, whilst stating that it can't limits the implementation to only such ways that can not throw an exception. Just like there are plenty of compilers that allow things that are undefined by the C or C++ standard - because that particular compiler or C runtime has a suitable solution for this undefined behaviour.

    --
    Mats

    regards,
    George

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Hi anon,


    In his book, Appendix E (Standard-Library Exception Safety), (E.1 Introduction), he mentioned it (in the 1st sample).

    Quote Originally Posted by anon View Post
    Good!

    A search in Mingw implementation of algorithms didn't turn up any instances of "throw".

    regards,
    George

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lifetime of temporary during exception throw
    By brewbuck in forum C++ Programming
    Replies: 3
    Last Post: 05-22-2009, 04:08 PM
  2. Straight Insertion Sort function problem
    By StaticKyle in forum C++ Programming
    Replies: 6
    Last Post: 05-12-2008, 04:03 AM
  3. threaded merge sort
    By AusTex in forum Linux Programming
    Replies: 4
    Last Post: 05-04-2005, 04:03 AM
  4. im extreamly new help
    By rigo305 in forum C++ Programming
    Replies: 27
    Last Post: 04-23-2004, 11:22 PM
  5. Developing Custom Exception Handler :: C++
    By kuphryn in forum C++ Programming
    Replies: 4
    Last Post: 02-20-2002, 04:21 PM