News for hackers. Stuff that matters.
Re:C99/C11 dynamic array that mimics C++'s std::vector by throwaway89121 on Saturday January 07, 2017 @10:21AM (#13344512)
I want something like std::vector, but I don't want exceptions. How does C++ help in this case?
Re:C99/C11 dynamic array that mimics C++'s std::vector by ensiferum on Saturday January 07, 2017 @10:23AM (#13344524)
std::vector is a container in a c++ standard library. C++ is a language. You're mixing apples and oranges.

What I'm saying is that you can use C++ without having to use STL and you can use C++ just fine to implement your own exceptionless container if you want (and many such implementations exist already).

And you can also compile with exceptions disabled. Should your code throw it will terminate the process.

Re:C99/C11 dynamic array that mimics C++'s std::vector by gwmarks on Saturday January 07, 2017 @10:35AM (#13344594)
So, garbage like "And you can also compile with exceptions disabled. Should your code throw it will terminate the process." is in the plus, and the parent comment is downvoted.

The C++ community at its finest.

Re:C99/C11 dynamic array that mimics C++'s std::vector by 72deluxe on Saturday January 07, 2017 @02:01PM (#13345883)
You can use any part of C++ without having to use the rest of it. For example, you don't have to write your own std::allocator to use std::vector, nor do you have to use exceptions.

You can use which bits of C++ that you want - that's its great strength, permitting low-level behaviour whilst supporting high level abstractions (and as simple or as complex as you like).

Re:C99/C11 dynamic array that mimics C++'s std::vector by slededit on Saturday January 07, 2017 @10:43PM (#13348111)
While technically you don't need exceptions and can disable it, the reality is the design of the STL is such that exceptions are required. It makes no affordance to signal errors in any other way. You can get farther if you decide OOM is a crash - but otherwise much of the STL is out of bounds.
Re:C99/C11 dynamic array that mimics C++'s std::vector by Joky on Sunday January 08, 2017 @12:17AM (#13348409)
Are there many applications that recover from OOM?
Re:C99/C11 dynamic array that mimics C++'s std::vector by pskocik on Sunday January 08, 2017 @11:08AM (#13350315)
I haven't seen it in practice, but OOM is conceivably recoverable in certain cases (e.g., exponential vector growth with large capacities fails on a 32 bit system, but switching to linear growth as a recovery strategy succeeds in allocating sufficient additional memory). But OOM errors aren't the only type of errors that you can get in ctors. Disabling exceptions makes all those errors either fatal or your class invariants become silently broken, which makes exceptions and RAII kind of a package deal in robust software.
Re:C99/C11 dynamic array that mimics C++'s std::vector by Joky on Tuesday January 10, 2017 @03:34AM (#13363523)
The point was that STL is unusable without exception because of OOM. If you're not using exception anywhere in your codebase and you don't plan to recover from OOM, is this still an issue? (I don't have much experience with exception handling in large codebase, I've mostly worked on codebase that disabled exceptions)
Re:C99/C11 dynamic array that mimics C++'s std::vector by slededit on Sunday January 08, 2017 @04:59PM (#13352301)
Realistically even our operating systems aren't OOM safe. Linux will happily over commit swap but kill you when you try to use it.

Windows actually provides a stronger gurantee here. But if any of your dependencies are not OOM safe then neither are you. And much of windows userland is not OOM safe.

Re:C99/C11 dynamic array that mimics C++'s std::vector by tines on Saturday January 07, 2017 @10:24AM (#13344530)
It will help you either use std::vector with a custom allocator that does not throw exceptions, or else write your own non-throwing vector class with templates, which would, I hope, be more maintainable and easier to use correctly than an equivalent written in C.
Re:C99/C11 dynamic array that mimics C++'s std::vector by hendzen on Saturday January 07, 2017 @01:45PM (#13345789)
Compile with -fno-exceptions