The Stack Overflow podcast is back! Listen to an interview with our new CEO.
8 The edit to remove the Folly example inadvertently removed the links! These have been restored.
source | link

Update:

Yet another interesting example: Folly from Facebook. See https://github.com/facebook/folly/blob/master/folly/README

However, the rational for this choice isn't explained in the file. Also, not all Folly code seem to follow the rule... so maybe the rule isn't up to date. See:

grep -R throw folly

Gives:

folly/AtomicHashMap.h: *   Insert returns false if there is a key collision and throws if the max size
folly/AtomicHashMap.h:   *   AtomicHashMapFullError is thrown.
folly/ProducerConsumerQueue.h:      throw std::bad_alloc();
folly/json.h: * system, the serializer will throw.
folly/json.h:     * precisely represented by fit a double---instead, throws an
folly/dynamic-inl.h:   * double, or throws if either is not a numeric type.
folly/dynamic-inl.h:      throw TypeError("numeric", a.type(), b.type());
folly/dynamic-inl.h:inline bool dynamic::isString() const { return get_nothrow<fbstring>(); }
folly/dynamic-inl.h:inline bool dynamic::isObject() const { return get_nothrow<ObjectImpl>(); }
folly/dynamic-inl.h:inline bool dynamic::isBool()   const { return get_nothrow<bool>(); }
folly/dynamic-inl.h:inline bool dynamic::isArray()  const { return get_nothrow<Array>(); }
folly/dynamic-inl.h:inline bool dynamic::isDouble() const { return get_nothrow<double>(); }
folly/dynamic-inl.h:inline bool dynamic::isInt()    const { return get_nothrow<int64_t>(); }
folly/dynamic-inl.h:inline bool dynamic::isNull()   const { return get_nothrow<void*>(); }
folly/dynamic-inl.h:    throw TypeError("object", type_);
folly/dynamic-inl.h:      throw TypeError("int64", type(), o.type());           \
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:  if (auto* parray = get_nothrow<Array>()) {
folly/dynamic-inl.h:      throw std::out_of_range("out of range in dynamic array");
folly/dynamic-inl.h:      throw TypeError("int64", idx.type());
folly/dynamic-inl.h:  auto* pobj = get_nothrow<ObjectImpl>();
folly/dynamic-inl.h:    throw std::out_of_range(to<std::string>(
folly/dynamic-inl.h:  if (auto* ar = get_nothrow<Array>()) {
folly/dynamic-inl.h:  if (auto* obj = get_nothrow<ObjectImpl>()) {
folly/dynamic-inl.h:  if (auto* str = get_nothrow<fbstring>()) {
folly/dynamic-inl.h:  throw TypeError("array/object", type());
folly/dynamic-inl.h:    throw TypeError("not null/object/array", type());
folly/dynamic-inl.h:  case INT64:    return to<T>(*get_nothrow<int64_t>());
folly/dynamic-inl.h:  case DOUBLE:   return to<T>(*get_nothrow<double>());
folly/dynamic-inl.h:  case BOOL:     return to<T>(*get_nothrow<bool>());
folly/dynamic-inl.h:  case STRING:   return to<T>(*get_nothrow<fbstring>());
folly/dynamic-inl.h:    throw TypeError("int/double/bool/string", type());
folly/dynamic-inl.h:T* dynamic::get_nothrow() {
folly/dynamic-inl.h:T const* dynamic::get_nothrow() const {
folly/dynamic-inl.h:  return const_cast<dynamic*>(this)->get_nothrow<T>();
folly/dynamic-inl.h:  if (auto* p = get_nothrow<T>()) {
folly/dynamic-inl.h:  throw TypeError(TypeInfo<T>::name, type());
folly/docs/Dynamic.md:`folly::TypeError`. Other exceptions can also be thrown if
folly/docs/Dynamic.md:    dynamic hugeDoub = hugeInt.asDouble();  // throws a folly/Conv.h error,
folly/docs/Conv.md:* Otherwise, `to` inserts bounds checks and throws
folly/docs/FBVector.md:assignment is the same as bitblitting the bits over) or a nothrow
folly/docs/FBVector.md:      (boost::has_trivial_assign<T>::value || boost::has_nothrow_constructor<T>::value));
folly/FormatArg.h:   * Validate the argument for the given type; throws on error.
folly/FormatArg.h:   * is thrown otherwise).
folly/FormatArg.h:   * integer (an exception is thrown otherwise).
folly/FormatArg.h:  throw std::invalid_argument(to<std::string>(
folly/Conv.h:  ((condition) ? (void)0 : throw std::range_error(                      \
folly/Conv.h: * in which case digits_to throws.
folly/Conv.h:    throw std::range_error("Cannot convert string " +
folly/Conv.h:      throw std::range_error("Unable to convert an empty string"
folly/Conv.h:  throw std::range_error("Unable to convert \"" + src->toString()
folly/Conv.h:    throw std::range_error(
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, p.get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, static_cast<const Ptr&>(p).get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<void*>(NULL), p.get_nothrow<void>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<int*>(NULL), p.get_nothrow<int>());
folly/test/ScopeGuardTest.cpp:      throw std::runtime_error("destructors should never throw!");
folly/test/ScopeGuardTest.cpp:  "destructors should never throw");
folly/test/ScopeGuardTest.cpp: * to close a db connection regardless if an exception was thrown during
folly/test/ScopeGuardTest.cpp: *     throw e; // re-throw the exception
folly/test/ScopeGuardTest.cpp:        throw std::runtime_error("throwing an expected error");
folly/test/ScopeGuardTest.cpp:        throw "never throw raw strings";
folly/test/ScopeGuardTest.cpp:    throw std::runtime_error("test");
folly/test/FBStringLibstdcxxStdexceptTest.cpp:          (use std::__throw_* from funcexcept.h instead)
folly/test/ConvTest.cpp:  // However, if the next character would cause an overflow it throws a
folly/test/ConvTest.cpp:    throw std::runtime_error("empty string");
folly/test/ConvTest.cpp:      throw std::runtime_error("overflow");
folly/test/ConvTest.cpp:    throw std::runtime_error("extra chars at the end");
folly/test/AtomicHashMapTest.cpp:    static bool throwException_ = false;
folly/test/AtomicHashMapTest.cpp:    throwException_ = !throwException_;
folly/test/AtomicHashMapTest.cpp:    if (throwException_) {
folly/test/AtomicHashMapTest.cpp:      throw 1;
folly/test/small_vector_test.cpp:int throwCounter = 1;
folly/test/small_vector_test.cpp:  if (!--throwCounter) {
folly/test/small_vector_test.cpp:    throw TestException();
folly/test/small_vector_test.cpp:// Check that throws don't break the basic guarantee for some cases.
folly/test/small_vector_test.cpp:// throwing code paths to occur.
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = counter;
folly/test/small_vector_test.cpp:       * of the above push_back's, and one of the Throwers throws,
folly/test/small_vector_test.cpp:    throwCounter = 4;
folly/StlAllocator.h: * alignment required on your system), throwing std::bad_alloc if the
folly/StlAllocator.h: *     if (!p) throw std::bad_alloc();
folly/dynamic.h: * complete interface than the raw type), and it'll just throw a
folly/dynamic.h:   * those types.  For objects, we throw TypeError.
folly/dynamic.h:   * These throw TypeError when used with types or type combinations
folly/dynamic.h:   * These functions may also throw if you use 64-bit integers with
folly/dynamic.h:   * throws TypeError.
folly/dynamic.h:   * non-arrays will throw a TypeError.
folly/dynamic.h:   * value) in an object.  Calling these on non-objects will throw a TypeError.
folly/dynamic.h:   * the given name.  Otherwise throws TypeError.
folly/dynamic.h:   * will throw a TypeError.  Using an index that is out of range or
folly/dynamic.h:   * object-element that's not present throws std::out_of_range.
folly/dynamic.h:   * In the case of an array, the index must be an integer, and this will throw
folly/dynamic.h:   * value if the key isn't present.  The const overload will throw
folly/dynamic.h:   * Only defined for objects, throws TypeError otherwise.
folly/dynamic.h:   * Inserts the supplied key-value pair to an object, or throws if
folly/dynamic.h:   * Append elements to an array.  If this is not an array, throws
folly/dynamic.h:  template<class T> T*       get_nothrow();
folly/dynamic.h:  template<class T> T const* get_nothrow() const;
folly/String.h: * In strict mode (default), throws std::invalid_argument if it encounters
folly/String.h: * This function may allocate memory (and therefore throw).
folly/String.h:struct has_nothrow_constructor<folly::basic_fbstring<T> > : true_type {
folly/DiscriminatedPtr.h: * throws an exception (and get_nothrow returns nullptr)
folly/DiscriminatedPtr.h:  T* get_nothrow() noexcept {
folly/DiscriminatedPtr.h:  const T* get_nothrow() const noexcept {
folly/DiscriminatedPtr.h:   * Types), and throws std::invalid_argument if this DiscriminatedPtr is empty
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/Format-inl.h:  // and throw if we see any lone "}"
folly/Format-inl.h:        throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument("folly::format: missing ending '}'");
folly/Format-inl.h:      throw std::invalid_argument(
folly/String-inl.h:        throw std::invalid_argument("incomplete escape sequence");
folly/String-inl.h:          throw std::invalid_argument("incomplete hex escape sequence");
folly/String-inl.h:        throw std::invalid_argument("invalid escape sequence");
folly/small_vector.h: * overflow the in situ capacity we throw an exception.
folly/small_vector.h:      // threw: if someone throws from a move constructor the effects
folly/small_vector.h:      throw;
folly/small_vector.h:      throw;
folly/small_vector.h:   * anything throws, undo what we did.
folly/small_vector.h:      throw;
folly/small_vector.h:   * Basic guarantee only.  Provides the nothrow guarantee iff our
folly/small_vector.h:   * value_type has a nothrow move or copy constructor.
folly/small_vector.h:        throw;
folly/small_vector.h:      throw;
folly/small_vector.h:     * constructor throwing by clearing the whole vector).
folly/small_vector.h:     * constructor throws, you either need a nothrow default
folly/small_vector.h:     * constructor or a nothrow copy/move to get something back in the
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:   * objects and insertion outside the function, otherwise exception is thrown.
folly/small_vector.h:      throw std::length_error("max_size exceeded in small_vector");
folly/small_vector.h:      throw std::bad_alloc();
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:// Basic guarantee only, or provides the nothrow guarantee iff T has a
folly/small_vector.h:// nothrow move or copy constructor.
folly/experimental/TestUtil.cpp:    throw std::system_error(errno, std::system_category(),
folly/experimental/TestUtil.cpp:      throw std::system_error(errno, std::system_category(),
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("overflow");
folly/experimental/io/Cursor.h: * (and push() and ensure() will throw) if growth == 0.
folly/experimental/io/Cursor.h:      throw std::out_of_range("can't grow buffer chain");
folly/experimental/io/IOBuf.h:   * second argument.  The free function must never throw exceptions.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.  If freeOnError is true (the
folly/experimental/io/IOBuf.h:   * default) the buffer will be freed before throwing the error.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.
folly/experimental/io/IOBuf.h:   * Currently unshare may also throw std::overflow_error if it tries to
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:          // The user's free function is not allowed to throw.
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:    throw std::overflow_error("IOBuf chain too large to coalesce");
folly/experimental/io/IOBuf.cpp:      // The user's free function should never throw.  Otherwise we might
folly/experimental/io/IOBuf.cpp:      // throw from the IOBuf destructor.  Other code paths like coalesce()
folly/experimental/io/IOBuf.cpp:      // also assume that decrementRefcount() cannot throw.
folly/experimental/io/IOBuf.cpp:            throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:          throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBufQueue.h:   * @throws std::underflow_error if n exceeds the number of bytes
folly/experimental/io/IOBufQueue.h:      throw std::invalid_argument("IOBufQueue: chain length not cached");
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/Traits.h:  struct has_nothrow_constructor<  __VA_ARGS__ > : ::boost::true_type {};
folly/Traits.h: * above, and that it has a nothrow constructor. Most types can be
folly/Traits.h:struct has_nothrow_constructor< std::pair<T, U> >
folly/Traits.h:    : ::boost::mpl::and_< has_nothrow_constructor<T>,
folly/Traits.h:                          has_nothrow_constructor<U> > {};
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/FBVector.h:  boost::has_nothrow_constructor<T>::value
folly/FBVector.h:  !boost::has_nothrow_constructor<T>::value
folly/FBVector.h: * value. If the operation throws, destroys all objects constructed so
folly/FBVector.h:  } else if (boost::has_nothrow_constructor<T>::value) {
folly/FBVector.h:      throw;
folly/FBVector.h: * operation throws, destroys all objects constructed so far and calls
folly/FBVector.h:      throw;
folly/FBVector.h:      // Careful here, fill and uninitialized_fill may throw. The
folly/FBVector.h:      throw std::out_of_range("fbvector: index is greater than size.");
folly/FBVector.h:        throw;
folly/FBVector.h:        throw;
folly/FBString.h:      void (*throw_exc)(const char*),
folly/FBString.h:    if (!condition) throw_exc(msg);
folly/FBString.h:          std::__throw_logic_error(err.c_str());
folly/FBString.h:    enforce(res_arg <= max_size(), std::__throw_length_error, "");
folly/FBString.h:    enforce(n <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(n < size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos1 <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.size(), std::__throw_out_of_range, "");
folly/detail/ThreadLocalDetail.h:      throw std::runtime_error("pthread_key_create failed: " + msg);
folly/detail/ThreadLocalDetail.h:      LOG(WARNING) << "Destructor discarding an exception that was thrown.";
folly/detail/ThreadLocalDetail.h:          throw std::bad_alloc();
folly/AtomicHashMap-inl.h:    throw AtomicHashMapFullError();
folly/AtomicHashArray-inl.h:            throw;
folly/ScopeGuard.h: *   // this will throw an exception upon error, which
folly/ScopeGuard.h: *   // an exception was not thrown, so don't execute
folly/String.cpp:    throw std::runtime_error(
folly/String.cpp:      throw std::runtime_error(
folly/json.cpp:    throw std::runtime_error("folly::decodeUtf8 empty/invalid string");
folly/json.cpp:    throw std::runtime_error(
folly/json.cpp:      throw std::runtime_error(
folly/json.cpp:        throw std::runtime_error(
folly/json.cpp:          throw std::runtime_error(
folly/json.cpp:  throw std::runtime_error("folly::decodeUtf8 encoding length maxed out");
folly/json.cpp:      throw std::runtime_error("folly::toJson: JSON object key was not a "
folly/json.cpp:      throw ParseError(lineNum_, context(),
folly/json.cpp:    throw ParseError(lineNum_, context(), what);
folly/Arena.h: *      alignment required on your system; throw std::bad_alloc if the
folly/Arena.h:    if (!mem) throw std::bad_alloc();

Update:

Yet another interesting example: Folly from Facebook. See https://github.com/facebook/folly/blob/master/folly/README

However, the rational for this choice isn't explained in the file. Also, not all Folly code seem to follow the rule... so maybe the rule isn't up to date. See:

grep -R throw folly

Gives:

folly/AtomicHashMap.h: *   Insert returns false if there is a key collision and throws if the max size
folly/AtomicHashMap.h:   *   AtomicHashMapFullError is thrown.
folly/ProducerConsumerQueue.h:      throw std::bad_alloc();
folly/json.h: * system, the serializer will throw.
folly/json.h:     * precisely represented by fit a double---instead, throws an
folly/dynamic-inl.h:   * double, or throws if either is not a numeric type.
folly/dynamic-inl.h:      throw TypeError("numeric", a.type(), b.type());
folly/dynamic-inl.h:inline bool dynamic::isString() const { return get_nothrow<fbstring>(); }
folly/dynamic-inl.h:inline bool dynamic::isObject() const { return get_nothrow<ObjectImpl>(); }
folly/dynamic-inl.h:inline bool dynamic::isBool()   const { return get_nothrow<bool>(); }
folly/dynamic-inl.h:inline bool dynamic::isArray()  const { return get_nothrow<Array>(); }
folly/dynamic-inl.h:inline bool dynamic::isDouble() const { return get_nothrow<double>(); }
folly/dynamic-inl.h:inline bool dynamic::isInt()    const { return get_nothrow<int64_t>(); }
folly/dynamic-inl.h:inline bool dynamic::isNull()   const { return get_nothrow<void*>(); }
folly/dynamic-inl.h:    throw TypeError("object", type_);
folly/dynamic-inl.h:      throw TypeError("int64", type(), o.type());           \
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:  if (auto* parray = get_nothrow<Array>()) {
folly/dynamic-inl.h:      throw std::out_of_range("out of range in dynamic array");
folly/dynamic-inl.h:      throw TypeError("int64", idx.type());
folly/dynamic-inl.h:  auto* pobj = get_nothrow<ObjectImpl>();
folly/dynamic-inl.h:    throw std::out_of_range(to<std::string>(
folly/dynamic-inl.h:  if (auto* ar = get_nothrow<Array>()) {
folly/dynamic-inl.h:  if (auto* obj = get_nothrow<ObjectImpl>()) {
folly/dynamic-inl.h:  if (auto* str = get_nothrow<fbstring>()) {
folly/dynamic-inl.h:  throw TypeError("array/object", type());
folly/dynamic-inl.h:    throw TypeError("not null/object/array", type());
folly/dynamic-inl.h:  case INT64:    return to<T>(*get_nothrow<int64_t>());
folly/dynamic-inl.h:  case DOUBLE:   return to<T>(*get_nothrow<double>());
folly/dynamic-inl.h:  case BOOL:     return to<T>(*get_nothrow<bool>());
folly/dynamic-inl.h:  case STRING:   return to<T>(*get_nothrow<fbstring>());
folly/dynamic-inl.h:    throw TypeError("int/double/bool/string", type());
folly/dynamic-inl.h:T* dynamic::get_nothrow() {
folly/dynamic-inl.h:T const* dynamic::get_nothrow() const {
folly/dynamic-inl.h:  return const_cast<dynamic*>(this)->get_nothrow<T>();
folly/dynamic-inl.h:  if (auto* p = get_nothrow<T>()) {
folly/dynamic-inl.h:  throw TypeError(TypeInfo<T>::name, type());
folly/docs/Dynamic.md:`folly::TypeError`. Other exceptions can also be thrown if
folly/docs/Dynamic.md:    dynamic hugeDoub = hugeInt.asDouble();  // throws a folly/Conv.h error,
folly/docs/Conv.md:* Otherwise, `to` inserts bounds checks and throws
folly/docs/FBVector.md:assignment is the same as bitblitting the bits over) or a nothrow
folly/docs/FBVector.md:      (boost::has_trivial_assign<T>::value || boost::has_nothrow_constructor<T>::value));
folly/FormatArg.h:   * Validate the argument for the given type; throws on error.
folly/FormatArg.h:   * is thrown otherwise).
folly/FormatArg.h:   * integer (an exception is thrown otherwise).
folly/FormatArg.h:  throw std::invalid_argument(to<std::string>(
folly/Conv.h:  ((condition) ? (void)0 : throw std::range_error(                      \
folly/Conv.h: * in which case digits_to throws.
folly/Conv.h:    throw std::range_error("Cannot convert string " +
folly/Conv.h:      throw std::range_error("Unable to convert an empty string"
folly/Conv.h:  throw std::range_error("Unable to convert \"" + src->toString()
folly/Conv.h:    throw std::range_error(
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, p.get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, static_cast<const Ptr&>(p).get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<void*>(NULL), p.get_nothrow<void>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<int*>(NULL), p.get_nothrow<int>());
folly/test/ScopeGuardTest.cpp:      throw std::runtime_error("destructors should never throw!");
folly/test/ScopeGuardTest.cpp:  "destructors should never throw");
folly/test/ScopeGuardTest.cpp: * to close a db connection regardless if an exception was thrown during
folly/test/ScopeGuardTest.cpp: *     throw e; // re-throw the exception
folly/test/ScopeGuardTest.cpp:        throw std::runtime_error("throwing an expected error");
folly/test/ScopeGuardTest.cpp:        throw "never throw raw strings";
folly/test/ScopeGuardTest.cpp:    throw std::runtime_error("test");
folly/test/FBStringLibstdcxxStdexceptTest.cpp:          (use std::__throw_* from funcexcept.h instead)
folly/test/ConvTest.cpp:  // However, if the next character would cause an overflow it throws a
folly/test/ConvTest.cpp:    throw std::runtime_error("empty string");
folly/test/ConvTest.cpp:      throw std::runtime_error("overflow");
folly/test/ConvTest.cpp:    throw std::runtime_error("extra chars at the end");
folly/test/AtomicHashMapTest.cpp:    static bool throwException_ = false;
folly/test/AtomicHashMapTest.cpp:    throwException_ = !throwException_;
folly/test/AtomicHashMapTest.cpp:    if (throwException_) {
folly/test/AtomicHashMapTest.cpp:      throw 1;
folly/test/small_vector_test.cpp:int throwCounter = 1;
folly/test/small_vector_test.cpp:  if (!--throwCounter) {
folly/test/small_vector_test.cpp:    throw TestException();
folly/test/small_vector_test.cpp:// Check that throws don't break the basic guarantee for some cases.
folly/test/small_vector_test.cpp:// throwing code paths to occur.
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = counter;
folly/test/small_vector_test.cpp:       * of the above push_back's, and one of the Throwers throws,
folly/test/small_vector_test.cpp:    throwCounter = 4;
folly/StlAllocator.h: * alignment required on your system), throwing std::bad_alloc if the
folly/StlAllocator.h: *     if (!p) throw std::bad_alloc();
folly/dynamic.h: * complete interface than the raw type), and it'll just throw a
folly/dynamic.h:   * those types.  For objects, we throw TypeError.
folly/dynamic.h:   * These throw TypeError when used with types or type combinations
folly/dynamic.h:   * These functions may also throw if you use 64-bit integers with
folly/dynamic.h:   * throws TypeError.
folly/dynamic.h:   * non-arrays will throw a TypeError.
folly/dynamic.h:   * value) in an object.  Calling these on non-objects will throw a TypeError.
folly/dynamic.h:   * the given name.  Otherwise throws TypeError.
folly/dynamic.h:   * will throw a TypeError.  Using an index that is out of range or
folly/dynamic.h:   * object-element that's not present throws std::out_of_range.
folly/dynamic.h:   * In the case of an array, the index must be an integer, and this will throw
folly/dynamic.h:   * value if the key isn't present.  The const overload will throw
folly/dynamic.h:   * Only defined for objects, throws TypeError otherwise.
folly/dynamic.h:   * Inserts the supplied key-value pair to an object, or throws if
folly/dynamic.h:   * Append elements to an array.  If this is not an array, throws
folly/dynamic.h:  template<class T> T*       get_nothrow();
folly/dynamic.h:  template<class T> T const* get_nothrow() const;
folly/String.h: * In strict mode (default), throws std::invalid_argument if it encounters
folly/String.h: * This function may allocate memory (and therefore throw).
folly/String.h:struct has_nothrow_constructor<folly::basic_fbstring<T> > : true_type {
folly/DiscriminatedPtr.h: * throws an exception (and get_nothrow returns nullptr)
folly/DiscriminatedPtr.h:  T* get_nothrow() noexcept {
folly/DiscriminatedPtr.h:  const T* get_nothrow() const noexcept {
folly/DiscriminatedPtr.h:   * Types), and throws std::invalid_argument if this DiscriminatedPtr is empty
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/Format-inl.h:  // and throw if we see any lone "}"
folly/Format-inl.h:        throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument("folly::format: missing ending '}'");
folly/Format-inl.h:      throw std::invalid_argument(
folly/String-inl.h:        throw std::invalid_argument("incomplete escape sequence");
folly/String-inl.h:          throw std::invalid_argument("incomplete hex escape sequence");
folly/String-inl.h:        throw std::invalid_argument("invalid escape sequence");
folly/small_vector.h: * overflow the in situ capacity we throw an exception.
folly/small_vector.h:      // threw: if someone throws from a move constructor the effects
folly/small_vector.h:      throw;
folly/small_vector.h:      throw;
folly/small_vector.h:   * anything throws, undo what we did.
folly/small_vector.h:      throw;
folly/small_vector.h:   * Basic guarantee only.  Provides the nothrow guarantee iff our
folly/small_vector.h:   * value_type has a nothrow move or copy constructor.
folly/small_vector.h:        throw;
folly/small_vector.h:      throw;
folly/small_vector.h:     * constructor throwing by clearing the whole vector).
folly/small_vector.h:     * constructor throws, you either need a nothrow default
folly/small_vector.h:     * constructor or a nothrow copy/move to get something back in the
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:   * objects and insertion outside the function, otherwise exception is thrown.
folly/small_vector.h:      throw std::length_error("max_size exceeded in small_vector");
folly/small_vector.h:      throw std::bad_alloc();
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:// Basic guarantee only, or provides the nothrow guarantee iff T has a
folly/small_vector.h:// nothrow move or copy constructor.
folly/experimental/TestUtil.cpp:    throw std::system_error(errno, std::system_category(),
folly/experimental/TestUtil.cpp:      throw std::system_error(errno, std::system_category(),
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("overflow");
folly/experimental/io/Cursor.h: * (and push() and ensure() will throw) if growth == 0.
folly/experimental/io/Cursor.h:      throw std::out_of_range("can't grow buffer chain");
folly/experimental/io/IOBuf.h:   * second argument.  The free function must never throw exceptions.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.  If freeOnError is true (the
folly/experimental/io/IOBuf.h:   * default) the buffer will be freed before throwing the error.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.
folly/experimental/io/IOBuf.h:   * Currently unshare may also throw std::overflow_error if it tries to
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:          // The user's free function is not allowed to throw.
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:    throw std::overflow_error("IOBuf chain too large to coalesce");
folly/experimental/io/IOBuf.cpp:      // The user's free function should never throw.  Otherwise we might
folly/experimental/io/IOBuf.cpp:      // throw from the IOBuf destructor.  Other code paths like coalesce()
folly/experimental/io/IOBuf.cpp:      // also assume that decrementRefcount() cannot throw.
folly/experimental/io/IOBuf.cpp:            throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:          throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBufQueue.h:   * @throws std::underflow_error if n exceeds the number of bytes
folly/experimental/io/IOBufQueue.h:      throw std::invalid_argument("IOBufQueue: chain length not cached");
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/Traits.h:  struct has_nothrow_constructor<  __VA_ARGS__ > : ::boost::true_type {};
folly/Traits.h: * above, and that it has a nothrow constructor. Most types can be
folly/Traits.h:struct has_nothrow_constructor< std::pair<T, U> >
folly/Traits.h:    : ::boost::mpl::and_< has_nothrow_constructor<T>,
folly/Traits.h:                          has_nothrow_constructor<U> > {};
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/FBVector.h:  boost::has_nothrow_constructor<T>::value
folly/FBVector.h:  !boost::has_nothrow_constructor<T>::value
folly/FBVector.h: * value. If the operation throws, destroys all objects constructed so
folly/FBVector.h:  } else if (boost::has_nothrow_constructor<T>::value) {
folly/FBVector.h:      throw;
folly/FBVector.h: * operation throws, destroys all objects constructed so far and calls
folly/FBVector.h:      throw;
folly/FBVector.h:      // Careful here, fill and uninitialized_fill may throw. The
folly/FBVector.h:      throw std::out_of_range("fbvector: index is greater than size.");
folly/FBVector.h:        throw;
folly/FBVector.h:        throw;
folly/FBString.h:      void (*throw_exc)(const char*),
folly/FBString.h:    if (!condition) throw_exc(msg);
folly/FBString.h:          std::__throw_logic_error(err.c_str());
folly/FBString.h:    enforce(res_arg <= max_size(), std::__throw_length_error, "");
folly/FBString.h:    enforce(n <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(n < size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos1 <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.size(), std::__throw_out_of_range, "");
folly/detail/ThreadLocalDetail.h:      throw std::runtime_error("pthread_key_create failed: " + msg);
folly/detail/ThreadLocalDetail.h:      LOG(WARNING) << "Destructor discarding an exception that was thrown.";
folly/detail/ThreadLocalDetail.h:          throw std::bad_alloc();
folly/AtomicHashMap-inl.h:    throw AtomicHashMapFullError();
folly/AtomicHashArray-inl.h:            throw;
folly/ScopeGuard.h: *   // this will throw an exception upon error, which
folly/ScopeGuard.h: *   // an exception was not thrown, so don't execute
folly/String.cpp:    throw std::runtime_error(
folly/String.cpp:      throw std::runtime_error(
folly/json.cpp:    throw std::runtime_error("folly::decodeUtf8 empty/invalid string");
folly/json.cpp:    throw std::runtime_error(
folly/json.cpp:      throw std::runtime_error(
folly/json.cpp:        throw std::runtime_error(
folly/json.cpp:          throw std::runtime_error(
folly/json.cpp:  throw std::runtime_error("folly::decodeUtf8 encoding length maxed out");
folly/json.cpp:      throw std::runtime_error("folly::toJson: JSON object key was not a "
folly/json.cpp:      throw ParseError(lineNum_, context(),
folly/json.cpp:    throw ParseError(lineNum_, context(), what);
folly/Arena.h: *      alignment required on your system; throw std::bad_alloc if the
folly/Arena.h:    if (!mem) throw std::bad_alloc();
7 Rollback to Revision 5
source | link

Also, another example is [Arduino hardware SDK usnig gcc without exception activated in C++, and other things like no STL provided][1]Arduino hardware SDK usnig gcc without exception activated in C++, and other things like no STL provided.

I'm adding another surprising example here: [LLVM/CLang dont use exception nor RTTI for the followin reasons][2]LLVM/CLang dont use exception nor RTTI for the followin reasons:


Update:

Yet another interesting example: Folly from Facebook. See https://github.com/facebook/folly/blob/master/folly/README

However, the rational for this choice isn't explained in the file. Also, not all Folly code seem to follow the rule... so maybe the rule isn't up to date. See:

grep -R throw folly

Gives:

folly/AtomicHashMap.h: *   Insert returns false if there is a key collision and throws if the max size
folly/AtomicHashMap.h:   *   AtomicHashMapFullError is thrown.
folly/ProducerConsumerQueue.h:      throw std::bad_alloc();
folly/json.h: * system, the serializer will throw.
folly/json.h:     * precisely represented by fit a double---instead, throws an
folly/dynamic-inl.h:   * double, or throws if either is not a numeric type.
folly/dynamic-inl.h:      throw TypeError("numeric", a.type(), b.type());
folly/dynamic-inl.h:inline bool dynamic::isString() const { return get_nothrow<fbstring>(); }
folly/dynamic-inl.h:inline bool dynamic::isObject() const { return get_nothrow<ObjectImpl>(); }
folly/dynamic-inl.h:inline bool dynamic::isBool()   const { return get_nothrow<bool>(); }
folly/dynamic-inl.h:inline bool dynamic::isArray()  const { return get_nothrow<Array>(); }
folly/dynamic-inl.h:inline bool dynamic::isDouble() const { return get_nothrow<double>(); }
folly/dynamic-inl.h:inline bool dynamic::isInt()    const { return get_nothrow<int64_t>(); }
folly/dynamic-inl.h:inline bool dynamic::isNull()   const { return get_nothrow<void*>(); }
folly/dynamic-inl.h:    throw TypeError("object", type_);
folly/dynamic-inl.h:      throw TypeError("int64", type(), o.type());           \
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:  if (auto* parray = get_nothrow<Array>()) {
folly/dynamic-inl.h:      throw std::out_of_range("out of range in dynamic array");
folly/dynamic-inl.h:      throw TypeError("int64", idx.type());
folly/dynamic-inl.h:  auto* pobj = get_nothrow<ObjectImpl>();
folly/dynamic-inl.h:    throw std::out_of_range(to<std::string>(
folly/dynamic-inl.h:  if (auto* ar = get_nothrow<Array>()) {
folly/dynamic-inl.h:  if (auto* obj = get_nothrow<ObjectImpl>()) {
folly/dynamic-inl.h:  if (auto* str = get_nothrow<fbstring>()) {
folly/dynamic-inl.h:  throw TypeError("array/object", type());
folly/dynamic-inl.h:    throw TypeError("not null/object/array", type());
folly/dynamic-inl.h:  case INT64:    return to<T>(*get_nothrow<int64_t>());
folly/dynamic-inl.h:  case DOUBLE:   return to<T>(*get_nothrow<double>());
folly/dynamic-inl.h:  case BOOL:     return to<T>(*get_nothrow<bool>());
folly/dynamic-inl.h:  case STRING:   return to<T>(*get_nothrow<fbstring>());
folly/dynamic-inl.h:    throw TypeError("int/double/bool/string", type());
folly/dynamic-inl.h:T* dynamic::get_nothrow() {
folly/dynamic-inl.h:T const* dynamic::get_nothrow() const {
folly/dynamic-inl.h:  return const_cast<dynamic*>(this)->get_nothrow<T>();
folly/dynamic-inl.h:  if (auto* p = get_nothrow<T>()) {
folly/dynamic-inl.h:  throw TypeError(TypeInfo<T>::name, type());
folly/docs/Dynamic.md:`folly::TypeError`. Other exceptions can also be thrown if
folly/docs/Dynamic.md:    dynamic hugeDoub = hugeInt.asDouble();  // throws a folly/Conv.h error,
folly/docs/Conv.md:* Otherwise, `to` inserts bounds checks and throws
folly/docs/FBVector.md:assignment is the same as bitblitting the bits over) or a nothrow
folly/docs/FBVector.md:      (boost::has_trivial_assign<T>::value || boost::has_nothrow_constructor<T>::value));
folly/FormatArg.h:   * Validate the argument for the given type; throws on error.
folly/FormatArg.h:   * is thrown otherwise).
folly/FormatArg.h:   * integer (an exception is thrown otherwise).
folly/FormatArg.h:  throw std::invalid_argument(to<std::string>(
folly/Conv.h:  ((condition) ? (void)0 : throw std::range_error(                      \
folly/Conv.h: * in which case digits_to throws.
folly/Conv.h:    throw std::range_error("Cannot convert string " +
folly/Conv.h:      throw std::range_error("Unable to convert an empty string"
folly/Conv.h:  throw std::range_error("Unable to convert \"" + src->toString()
folly/Conv.h:    throw std::range_error(
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, p.get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, static_cast<const Ptr&>(p).get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<void*>(NULL), p.get_nothrow<void>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<int*>(NULL), p.get_nothrow<int>());
folly/test/ScopeGuardTest.cpp:      throw std::runtime_error("destructors should never throw!");
folly/test/ScopeGuardTest.cpp:  "destructors should never throw");
folly/test/ScopeGuardTest.cpp: * to close a db connection regardless if an exception was thrown during
folly/test/ScopeGuardTest.cpp: *     throw e; // re-throw the exception
folly/test/ScopeGuardTest.cpp:        throw std::runtime_error("throwing an expected error");
folly/test/ScopeGuardTest.cpp:        throw "never throw raw strings";
folly/test/ScopeGuardTest.cpp:    throw std::runtime_error("test");
folly/test/FBStringLibstdcxxStdexceptTest.cpp:          (use std::__throw_* from funcexcept.h instead)
folly/test/ConvTest.cpp:  // However, if the next character would cause an overflow it throws a
folly/test/ConvTest.cpp:    throw std::runtime_error("empty string");
folly/test/ConvTest.cpp:      throw std::runtime_error("overflow");
folly/test/ConvTest.cpp:    throw std::runtime_error("extra chars at the end");
folly/test/AtomicHashMapTest.cpp:    static bool throwException_ = false;
folly/test/AtomicHashMapTest.cpp:    throwException_ = !throwException_;
folly/test/AtomicHashMapTest.cpp:    if (throwException_) {
folly/test/AtomicHashMapTest.cpp:      throw 1;
folly/test/small_vector_test.cpp:int throwCounter = 1;
folly/test/small_vector_test.cpp:  if (!--throwCounter) {
folly/test/small_vector_test.cpp:    throw TestException();
folly/test/small_vector_test.cpp:// Check that throws don't break the basic guarantee for some cases.
folly/test/small_vector_test.cpp:// throwing code paths to occur.
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = counter;
folly/test/small_vector_test.cpp:       * of the above push_back's, and one of the Throwers throws,
folly/test/small_vector_test.cpp:    throwCounter = 4;
folly/StlAllocator.h: * alignment required on your system), throwing std::bad_alloc if the
folly/StlAllocator.h: *     if (!p) throw std::bad_alloc();
folly/dynamic.h: * complete interface than the raw type), and it'll just throw a
folly/dynamic.h:   * those types.  For objects, we throw TypeError.
folly/dynamic.h:   * These throw TypeError when used with types or type combinations
folly/dynamic.h:   * These functions may also throw if you use 64-bit integers with
folly/dynamic.h:   * throws TypeError.
folly/dynamic.h:   * non-arrays will throw a TypeError.
folly/dynamic.h:   * value) in an object.  Calling these on non-objects will throw a TypeError.
folly/dynamic.h:   * the given name.  Otherwise throws TypeError.
folly/dynamic.h:   * will throw a TypeError.  Using an index that is out of range or
folly/dynamic.h:   * object-element that's not present throws std::out_of_range.
folly/dynamic.h:   * In the case of an array, the index must be an integer, and this will throw
folly/dynamic.h:   * value if the key isn't present.  The const overload will throw
folly/dynamic.h:   * Only defined for objects, throws TypeError otherwise.
folly/dynamic.h:   * Inserts the supplied key-value pair to an object, or throws if
folly/dynamic.h:   * Append elements to an array.  If this is not an array, throws
folly/dynamic.h:  template<class T> T*       get_nothrow();
folly/dynamic.h:  template<class T> T const* get_nothrow() const;
folly/String.h: * In strict mode (default), throws std::invalid_argument if it encounters
folly/String.h: * This function may allocate memory (and therefore throw).
folly/String.h:struct has_nothrow_constructor<folly::basic_fbstring<T> > : true_type {
folly/DiscriminatedPtr.h: * throws an exception (and get_nothrow returns nullptr)
folly/DiscriminatedPtr.h:  T* get_nothrow() noexcept {
folly/DiscriminatedPtr.h:  const T* get_nothrow() const noexcept {
folly/DiscriminatedPtr.h:   * Types), and throws std::invalid_argument if this DiscriminatedPtr is empty
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/Format-inl.h:  // and throw if we see any lone "}"
folly/Format-inl.h:        throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument("folly::format: missing ending '}'");
folly/Format-inl.h:      throw std::invalid_argument(
folly/String-inl.h:        throw std::invalid_argument("incomplete escape sequence");
folly/String-inl.h:          throw std::invalid_argument("incomplete hex escape sequence");
folly/String-inl.h:        throw std::invalid_argument("invalid escape sequence");
folly/small_vector.h: * overflow the in situ capacity we throw an exception.
folly/small_vector.h:      // threw: if someone throws from a move constructor the effects
folly/small_vector.h:      throw;
folly/small_vector.h:      throw;
folly/small_vector.h:   * anything throws, undo what we did.
folly/small_vector.h:      throw;
folly/small_vector.h:   * Basic guarantee only.  Provides the nothrow guarantee iff our
folly/small_vector.h:   * value_type has a nothrow move or copy constructor.
folly/small_vector.h:        throw;
folly/small_vector.h:      throw;
folly/small_vector.h:     * constructor throwing by clearing the whole vector).
folly/small_vector.h:     * constructor throws, you either need a nothrow default
folly/small_vector.h:     * constructor or a nothrow copy/move to get something back in the
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:   * objects and insertion outside the function, otherwise exception is thrown.
folly/small_vector.h:      throw std::length_error("max_size exceeded in small_vector");
folly/small_vector.h:      throw std::bad_alloc();
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:// Basic guarantee only, or provides the nothrow guarantee iff T has a
folly/small_vector.h:// nothrow move or copy constructor.
folly/experimental/TestUtil.cpp:    throw std::system_error(errno, std::system_category(),
folly/experimental/TestUtil.cpp:      throw std::system_error(errno, std::system_category(),
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("overflow");
folly/experimental/io/Cursor.h: * (and push() and ensure() will throw) if growth == 0.
folly/experimental/io/Cursor.h:      throw std::out_of_range("can't grow buffer chain");
folly/experimental/io/IOBuf.h:   * second argument.  The free function must never throw exceptions.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.  If freeOnError is true (the
folly/experimental/io/IOBuf.h:   * default) the buffer will be freed before throwing the error.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.
folly/experimental/io/IOBuf.h:   * Currently unshare may also throw std::overflow_error if it tries to
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:          // The user's free function is not allowed to throw.
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:    throw std::overflow_error("IOBuf chain too large to coalesce");
folly/experimental/io/IOBuf.cpp:      // The user's free function should never throw.  Otherwise we might
folly/experimental/io/IOBuf.cpp:      // throw from the IOBuf destructor.  Other code paths like coalesce()
folly/experimental/io/IOBuf.cpp:      // also assume that decrementRefcount() cannot throw.
folly/experimental/io/IOBuf.cpp:            throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:          throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBufQueue.h:   * @throws std::underflow_error if n exceeds the number of bytes
folly/experimental/io/IOBufQueue.h:      throw std::invalid_argument("IOBufQueue: chain length not cached");
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/Traits.h:  struct has_nothrow_constructor<  __VA_ARGS__ > : ::boost::true_type {};
folly/Traits.h: * above, and that it has a nothrow constructor. Most types can be
folly/Traits.h:struct has_nothrow_constructor< std::pair<T, U> >
folly/Traits.h:    : ::boost::mpl::and_< has_nothrow_constructor<T>,
folly/Traits.h:                          has_nothrow_constructor<U> > {};
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/FBVector.h:  boost::has_nothrow_constructor<T>::value
folly/FBVector.h:  !boost::has_nothrow_constructor<T>::value
folly/FBVector.h: * value. If the operation throws, destroys all objects constructed so
folly/FBVector.h:  } else if (boost::has_nothrow_constructor<T>::value) {
folly/FBVector.h:      throw;
folly/FBVector.h: * operation throws, destroys all objects constructed so far and calls
folly/FBVector.h:      throw;
folly/FBVector.h:      // Careful here, fill and uninitialized_fill may throw. The
folly/FBVector.h:      throw std::out_of_range("fbvector: index is greater than size.");
folly/FBVector.h:        throw;
folly/FBVector.h:        throw;
folly/FBString.h:      void (*throw_exc)(const char*),
folly/FBString.h:    if (!condition) throw_exc(msg);
folly/FBString.h:          std::__throw_logic_error(err.c_str());
folly/FBString.h:    enforce(res_arg <= max_size(), std::__throw_length_error, "");
folly/FBString.h:    enforce(n <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(n < size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos1 <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.size(), std::__throw_out_of_range, "");
folly/detail/ThreadLocalDetail.h:      throw std::runtime_error("pthread_key_create failed: " + msg);
folly/detail/ThreadLocalDetail.h:      LOG(WARNING) << "Destructor discarding an exception that was thrown.";
folly/detail/ThreadLocalDetail.h:          throw std::bad_alloc();
folly/AtomicHashMap-inl.h:    throw AtomicHashMapFullError();
folly/AtomicHashArray-inl.h:            throw;
folly/ScopeGuard.h: *   // this will throw an exception upon error, which
folly/ScopeGuard.h: *   // an exception was not thrown, so don't execute
folly/String.cpp:    throw std::runtime_error(
folly/String.cpp:      throw std::runtime_error(
folly/json.cpp:    throw std::runtime_error("folly::decodeUtf8 empty/invalid string");
folly/json.cpp:    throw std::runtime_error(
folly/json.cpp:      throw std::runtime_error(
folly/json.cpp:        throw std::runtime_error(
folly/json.cpp:          throw std::runtime_error(
folly/json.cpp:  throw std::runtime_error("folly::decodeUtf8 encoding length maxed out");
folly/json.cpp:      throw std::runtime_error("folly::toJson: JSON object key was not a "
folly/json.cpp:      throw ParseError(lineNum_, context(),
folly/json.cpp:    throw ParseError(lineNum_, context(), what);
folly/Arena.h: *      alignment required on your system; throw std::bad_alloc if the
folly/Arena.h:    if (!mem) throw std::bad_alloc();

Also, another example is [Arduino hardware SDK usnig gcc without exception activated in C++, and other things like no STL provided][1].

I'm adding another surprising example here: [LLVM/CLang dont use exception nor RTTI for the followin reasons][2]:

Also, another example is Arduino hardware SDK usnig gcc without exception activated in C++, and other things like no STL provided.

I'm adding another surprising example here: LLVM/CLang dont use exception nor RTTI for the followin reasons:


Update:

Yet another interesting example: Folly from Facebook. See https://github.com/facebook/folly/blob/master/folly/README

However, the rational for this choice isn't explained in the file. Also, not all Folly code seem to follow the rule... so maybe the rule isn't up to date. See:

grep -R throw folly

Gives:

folly/AtomicHashMap.h: *   Insert returns false if there is a key collision and throws if the max size
folly/AtomicHashMap.h:   *   AtomicHashMapFullError is thrown.
folly/ProducerConsumerQueue.h:      throw std::bad_alloc();
folly/json.h: * system, the serializer will throw.
folly/json.h:     * precisely represented by fit a double---instead, throws an
folly/dynamic-inl.h:   * double, or throws if either is not a numeric type.
folly/dynamic-inl.h:      throw TypeError("numeric", a.type(), b.type());
folly/dynamic-inl.h:inline bool dynamic::isString() const { return get_nothrow<fbstring>(); }
folly/dynamic-inl.h:inline bool dynamic::isObject() const { return get_nothrow<ObjectImpl>(); }
folly/dynamic-inl.h:inline bool dynamic::isBool()   const { return get_nothrow<bool>(); }
folly/dynamic-inl.h:inline bool dynamic::isArray()  const { return get_nothrow<Array>(); }
folly/dynamic-inl.h:inline bool dynamic::isDouble() const { return get_nothrow<double>(); }
folly/dynamic-inl.h:inline bool dynamic::isInt()    const { return get_nothrow<int64_t>(); }
folly/dynamic-inl.h:inline bool dynamic::isNull()   const { return get_nothrow<void*>(); }
folly/dynamic-inl.h:    throw TypeError("object", type_);
folly/dynamic-inl.h:      throw TypeError("int64", type(), o.type());           \
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:  if (auto* parray = get_nothrow<Array>()) {
folly/dynamic-inl.h:      throw std::out_of_range("out of range in dynamic array");
folly/dynamic-inl.h:      throw TypeError("int64", idx.type());
folly/dynamic-inl.h:  auto* pobj = get_nothrow<ObjectImpl>();
folly/dynamic-inl.h:    throw std::out_of_range(to<std::string>(
folly/dynamic-inl.h:  if (auto* ar = get_nothrow<Array>()) {
folly/dynamic-inl.h:  if (auto* obj = get_nothrow<ObjectImpl>()) {
folly/dynamic-inl.h:  if (auto* str = get_nothrow<fbstring>()) {
folly/dynamic-inl.h:  throw TypeError("array/object", type());
folly/dynamic-inl.h:    throw TypeError("not null/object/array", type());
folly/dynamic-inl.h:  case INT64:    return to<T>(*get_nothrow<int64_t>());
folly/dynamic-inl.h:  case DOUBLE:   return to<T>(*get_nothrow<double>());
folly/dynamic-inl.h:  case BOOL:     return to<T>(*get_nothrow<bool>());
folly/dynamic-inl.h:  case STRING:   return to<T>(*get_nothrow<fbstring>());
folly/dynamic-inl.h:    throw TypeError("int/double/bool/string", type());
folly/dynamic-inl.h:T* dynamic::get_nothrow() {
folly/dynamic-inl.h:T const* dynamic::get_nothrow() const {
folly/dynamic-inl.h:  return const_cast<dynamic*>(this)->get_nothrow<T>();
folly/dynamic-inl.h:  if (auto* p = get_nothrow<T>()) {
folly/dynamic-inl.h:  throw TypeError(TypeInfo<T>::name, type());
folly/docs/Dynamic.md:`folly::TypeError`. Other exceptions can also be thrown if
folly/docs/Dynamic.md:    dynamic hugeDoub = hugeInt.asDouble();  // throws a folly/Conv.h error,
folly/docs/Conv.md:* Otherwise, `to` inserts bounds checks and throws
folly/docs/FBVector.md:assignment is the same as bitblitting the bits over) or a nothrow
folly/docs/FBVector.md:      (boost::has_trivial_assign<T>::value || boost::has_nothrow_constructor<T>::value));
folly/FormatArg.h:   * Validate the argument for the given type; throws on error.
folly/FormatArg.h:   * is thrown otherwise).
folly/FormatArg.h:   * integer (an exception is thrown otherwise).
folly/FormatArg.h:  throw std::invalid_argument(to<std::string>(
folly/Conv.h:  ((condition) ? (void)0 : throw std::range_error(                      \
folly/Conv.h: * in which case digits_to throws.
folly/Conv.h:    throw std::range_error("Cannot convert string " +
folly/Conv.h:      throw std::range_error("Unable to convert an empty string"
folly/Conv.h:  throw std::range_error("Unable to convert \"" + src->toString()
folly/Conv.h:    throw std::range_error(
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, p.get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, static_cast<const Ptr&>(p).get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<void*>(NULL), p.get_nothrow<void>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<int*>(NULL), p.get_nothrow<int>());
folly/test/ScopeGuardTest.cpp:      throw std::runtime_error("destructors should never throw!");
folly/test/ScopeGuardTest.cpp:  "destructors should never throw");
folly/test/ScopeGuardTest.cpp: * to close a db connection regardless if an exception was thrown during
folly/test/ScopeGuardTest.cpp: *     throw e; // re-throw the exception
folly/test/ScopeGuardTest.cpp:        throw std::runtime_error("throwing an expected error");
folly/test/ScopeGuardTest.cpp:        throw "never throw raw strings";
folly/test/ScopeGuardTest.cpp:    throw std::runtime_error("test");
folly/test/FBStringLibstdcxxStdexceptTest.cpp:          (use std::__throw_* from funcexcept.h instead)
folly/test/ConvTest.cpp:  // However, if the next character would cause an overflow it throws a
folly/test/ConvTest.cpp:    throw std::runtime_error("empty string");
folly/test/ConvTest.cpp:      throw std::runtime_error("overflow");
folly/test/ConvTest.cpp:    throw std::runtime_error("extra chars at the end");
folly/test/AtomicHashMapTest.cpp:    static bool throwException_ = false;
folly/test/AtomicHashMapTest.cpp:    throwException_ = !throwException_;
folly/test/AtomicHashMapTest.cpp:    if (throwException_) {
folly/test/AtomicHashMapTest.cpp:      throw 1;
folly/test/small_vector_test.cpp:int throwCounter = 1;
folly/test/small_vector_test.cpp:  if (!--throwCounter) {
folly/test/small_vector_test.cpp:    throw TestException();
folly/test/small_vector_test.cpp:// Check that throws don't break the basic guarantee for some cases.
folly/test/small_vector_test.cpp:// throwing code paths to occur.
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = counter;
folly/test/small_vector_test.cpp:       * of the above push_back's, and one of the Throwers throws,
folly/test/small_vector_test.cpp:    throwCounter = 4;
folly/StlAllocator.h: * alignment required on your system), throwing std::bad_alloc if the
folly/StlAllocator.h: *     if (!p) throw std::bad_alloc();
folly/dynamic.h: * complete interface than the raw type), and it'll just throw a
folly/dynamic.h:   * those types.  For objects, we throw TypeError.
folly/dynamic.h:   * These throw TypeError when used with types or type combinations
folly/dynamic.h:   * These functions may also throw if you use 64-bit integers with
folly/dynamic.h:   * throws TypeError.
folly/dynamic.h:   * non-arrays will throw a TypeError.
folly/dynamic.h:   * value) in an object.  Calling these on non-objects will throw a TypeError.
folly/dynamic.h:   * the given name.  Otherwise throws TypeError.
folly/dynamic.h:   * will throw a TypeError.  Using an index that is out of range or
folly/dynamic.h:   * object-element that's not present throws std::out_of_range.
folly/dynamic.h:   * In the case of an array, the index must be an integer, and this will throw
folly/dynamic.h:   * value if the key isn't present.  The const overload will throw
folly/dynamic.h:   * Only defined for objects, throws TypeError otherwise.
folly/dynamic.h:   * Inserts the supplied key-value pair to an object, or throws if
folly/dynamic.h:   * Append elements to an array.  If this is not an array, throws
folly/dynamic.h:  template<class T> T*       get_nothrow();
folly/dynamic.h:  template<class T> T const* get_nothrow() const;
folly/String.h: * In strict mode (default), throws std::invalid_argument if it encounters
folly/String.h: * This function may allocate memory (and therefore throw).
folly/String.h:struct has_nothrow_constructor<folly::basic_fbstring<T> > : true_type {
folly/DiscriminatedPtr.h: * throws an exception (and get_nothrow returns nullptr)
folly/DiscriminatedPtr.h:  T* get_nothrow() noexcept {
folly/DiscriminatedPtr.h:  const T* get_nothrow() const noexcept {
folly/DiscriminatedPtr.h:   * Types), and throws std::invalid_argument if this DiscriminatedPtr is empty
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/Format-inl.h:  // and throw if we see any lone "}"
folly/Format-inl.h:        throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument("folly::format: missing ending '}'");
folly/Format-inl.h:      throw std::invalid_argument(
folly/String-inl.h:        throw std::invalid_argument("incomplete escape sequence");
folly/String-inl.h:          throw std::invalid_argument("incomplete hex escape sequence");
folly/String-inl.h:        throw std::invalid_argument("invalid escape sequence");
folly/small_vector.h: * overflow the in situ capacity we throw an exception.
folly/small_vector.h:      // threw: if someone throws from a move constructor the effects
folly/small_vector.h:      throw;
folly/small_vector.h:      throw;
folly/small_vector.h:   * anything throws, undo what we did.
folly/small_vector.h:      throw;
folly/small_vector.h:   * Basic guarantee only.  Provides the nothrow guarantee iff our
folly/small_vector.h:   * value_type has a nothrow move or copy constructor.
folly/small_vector.h:        throw;
folly/small_vector.h:      throw;
folly/small_vector.h:     * constructor throwing by clearing the whole vector).
folly/small_vector.h:     * constructor throws, you either need a nothrow default
folly/small_vector.h:     * constructor or a nothrow copy/move to get something back in the
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:   * objects and insertion outside the function, otherwise exception is thrown.
folly/small_vector.h:      throw std::length_error("max_size exceeded in small_vector");
folly/small_vector.h:      throw std::bad_alloc();
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:// Basic guarantee only, or provides the nothrow guarantee iff T has a
folly/small_vector.h:// nothrow move or copy constructor.
folly/experimental/TestUtil.cpp:    throw std::system_error(errno, std::system_category(),
folly/experimental/TestUtil.cpp:      throw std::system_error(errno, std::system_category(),
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("overflow");
folly/experimental/io/Cursor.h: * (and push() and ensure() will throw) if growth == 0.
folly/experimental/io/Cursor.h:      throw std::out_of_range("can't grow buffer chain");
folly/experimental/io/IOBuf.h:   * second argument.  The free function must never throw exceptions.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.  If freeOnError is true (the
folly/experimental/io/IOBuf.h:   * default) the buffer will be freed before throwing the error.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.
folly/experimental/io/IOBuf.h:   * Currently unshare may also throw std::overflow_error if it tries to
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:          // The user's free function is not allowed to throw.
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:    throw std::overflow_error("IOBuf chain too large to coalesce");
folly/experimental/io/IOBuf.cpp:      // The user's free function should never throw.  Otherwise we might
folly/experimental/io/IOBuf.cpp:      // throw from the IOBuf destructor.  Other code paths like coalesce()
folly/experimental/io/IOBuf.cpp:      // also assume that decrementRefcount() cannot throw.
folly/experimental/io/IOBuf.cpp:            throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:          throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBufQueue.h:   * @throws std::underflow_error if n exceeds the number of bytes
folly/experimental/io/IOBufQueue.h:      throw std::invalid_argument("IOBufQueue: chain length not cached");
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/Traits.h:  struct has_nothrow_constructor<  __VA_ARGS__ > : ::boost::true_type {};
folly/Traits.h: * above, and that it has a nothrow constructor. Most types can be
folly/Traits.h:struct has_nothrow_constructor< std::pair<T, U> >
folly/Traits.h:    : ::boost::mpl::and_< has_nothrow_constructor<T>,
folly/Traits.h:                          has_nothrow_constructor<U> > {};
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/FBVector.h:  boost::has_nothrow_constructor<T>::value
folly/FBVector.h:  !boost::has_nothrow_constructor<T>::value
folly/FBVector.h: * value. If the operation throws, destroys all objects constructed so
folly/FBVector.h:  } else if (boost::has_nothrow_constructor<T>::value) {
folly/FBVector.h:      throw;
folly/FBVector.h: * operation throws, destroys all objects constructed so far and calls
folly/FBVector.h:      throw;
folly/FBVector.h:      // Careful here, fill and uninitialized_fill may throw. The
folly/FBVector.h:      throw std::out_of_range("fbvector: index is greater than size.");
folly/FBVector.h:        throw;
folly/FBVector.h:        throw;
folly/FBString.h:      void (*throw_exc)(const char*),
folly/FBString.h:    if (!condition) throw_exc(msg);
folly/FBString.h:          std::__throw_logic_error(err.c_str());
folly/FBString.h:    enforce(res_arg <= max_size(), std::__throw_length_error, "");
folly/FBString.h:    enforce(n <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(n < size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos1 <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.size(), std::__throw_out_of_range, "");
folly/detail/ThreadLocalDetail.h:      throw std::runtime_error("pthread_key_create failed: " + msg);
folly/detail/ThreadLocalDetail.h:      LOG(WARNING) << "Destructor discarding an exception that was thrown.";
folly/detail/ThreadLocalDetail.h:          throw std::bad_alloc();
folly/AtomicHashMap-inl.h:    throw AtomicHashMapFullError();
folly/AtomicHashArray-inl.h:            throw;
folly/ScopeGuard.h: *   // this will throw an exception upon error, which
folly/ScopeGuard.h: *   // an exception was not thrown, so don't execute
folly/String.cpp:    throw std::runtime_error(
folly/String.cpp:      throw std::runtime_error(
folly/json.cpp:    throw std::runtime_error("folly::decodeUtf8 empty/invalid string");
folly/json.cpp:    throw std::runtime_error(
folly/json.cpp:      throw std::runtime_error(
folly/json.cpp:        throw std::runtime_error(
folly/json.cpp:          throw std::runtime_error(
folly/json.cpp:  throw std::runtime_error("folly::decodeUtf8 encoding length maxed out");
folly/json.cpp:      throw std::runtime_error("folly::toJson: JSON object key was not a "
folly/json.cpp:      throw ParseError(lineNum_, context(),
folly/json.cpp:    throw ParseError(lineNum_, context(), what);
folly/Arena.h: *      alignment required on your system; throw std::bad_alloc if the
folly/Arena.h:    if (!mem) throw std::bad_alloc();
6 removed folly example, see comments
source | link

Also, another example is Arduino hardware SDK usnig gcc without exception activated in C++, and other things like no STL provided[Arduino hardware SDK usnig gcc without exception activated in C++, and other things like no STL provided][1].

I'm adding another surprising example here: [LLVM/CLang LLVM/CLang dont use exception nor RTTI for the followin reasonsdont use exception nor RTTI for the followin reasons][2]:


Update:

Yet another interesting example: Folly from Facebook. See https://github.com/facebook/folly/blob/master/folly/README

However, the rational for this choice isn't explained in the file. Also, not all Folly code seem to follow the rule... so maybe the rule isn't up to date. See:

grep -R throw folly

Gives:

folly/AtomicHashMap.h: *   Insert returns false if there is a key collision and throws if the max size
folly/AtomicHashMap.h:   *   AtomicHashMapFullError is thrown.
folly/ProducerConsumerQueue.h:      throw std::bad_alloc();
folly/json.h: * system, the serializer will throw.
folly/json.h:     * precisely represented by fit a double---instead, throws an
folly/dynamic-inl.h:   * double, or throws if either is not a numeric type.
folly/dynamic-inl.h:      throw TypeError("numeric", a.type(), b.type());
folly/dynamic-inl.h:inline bool dynamic::isString() const { return get_nothrow<fbstring>(); }
folly/dynamic-inl.h:inline bool dynamic::isObject() const { return get_nothrow<ObjectImpl>(); }
folly/dynamic-inl.h:inline bool dynamic::isBool()   const { return get_nothrow<bool>(); }
folly/dynamic-inl.h:inline bool dynamic::isArray()  const { return get_nothrow<Array>(); }
folly/dynamic-inl.h:inline bool dynamic::isDouble() const { return get_nothrow<double>(); }
folly/dynamic-inl.h:inline bool dynamic::isInt()    const { return get_nothrow<int64_t>(); }
folly/dynamic-inl.h:inline bool dynamic::isNull()   const { return get_nothrow<void*>(); }
folly/dynamic-inl.h:    throw TypeError("object", type_);
folly/dynamic-inl.h:      throw TypeError("int64", type(), o.type());           \
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:  if (auto* parray = get_nothrow<Array>()) {
folly/dynamic-inl.h:      throw std::out_of_range("out of range in dynamic array");
folly/dynamic-inl.h:      throw TypeError("int64", idx.type());
folly/dynamic-inl.h:  auto* pobj = get_nothrow<ObjectImpl>();
folly/dynamic-inl.h:    throw std::out_of_range(to<std::string>(
folly/dynamic-inl.h:  if (auto* ar = get_nothrow<Array>()) {
folly/dynamic-inl.h:  if (auto* obj = get_nothrow<ObjectImpl>()) {
folly/dynamic-inl.h:  if (auto* str = get_nothrow<fbstring>()) {
folly/dynamic-inl.h:  throw TypeError("array/object", type());
folly/dynamic-inl.h:    throw TypeError("not null/object/array", type());
folly/dynamic-inl.h:  case INT64:    return to<T>(*get_nothrow<int64_t>());
folly/dynamic-inl.h:  case DOUBLE:   return to<T>(*get_nothrow<double>());
folly/dynamic-inl.h:  case BOOL:     return to<T>(*get_nothrow<bool>());
folly/dynamic-inl.h:  case STRING:   return to<T>(*get_nothrow<fbstring>());
folly/dynamic-inl.h:    throw TypeError("int/double/bool/string", type());
folly/dynamic-inl.h:T* dynamic::get_nothrow() {
folly/dynamic-inl.h:T const* dynamic::get_nothrow() const {
folly/dynamic-inl.h:  return const_cast<dynamic*>(this)->get_nothrow<T>();
folly/dynamic-inl.h:  if (auto* p = get_nothrow<T>()) {
folly/dynamic-inl.h:  throw TypeError(TypeInfo<T>::name, type());
folly/docs/Dynamic.md:`folly::TypeError`. Other exceptions can also be thrown if
folly/docs/Dynamic.md:    dynamic hugeDoub = hugeInt.asDouble();  // throws a folly/Conv.h error,
folly/docs/Conv.md:* Otherwise, `to` inserts bounds checks and throws
folly/docs/FBVector.md:assignment is the same as bitblitting the bits over) or a nothrow
folly/docs/FBVector.md:      (boost::has_trivial_assign<T>::value || boost::has_nothrow_constructor<T>::value));
folly/FormatArg.h:   * Validate the argument for the given type; throws on error.
folly/FormatArg.h:   * is thrown otherwise).
folly/FormatArg.h:   * integer (an exception is thrown otherwise).
folly/FormatArg.h:  throw std::invalid_argument(to<std::string>(
folly/Conv.h:  ((condition) ? (void)0 : throw std::range_error(                      \
folly/Conv.h: * in which case digits_to throws.
folly/Conv.h:    throw std::range_error("Cannot convert string " +
folly/Conv.h:      throw std::range_error("Unable to convert an empty string"
folly/Conv.h:  throw std::range_error("Unable to convert \"" + src->toString()
folly/Conv.h:    throw std::range_error(
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, p.get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, static_cast<const Ptr&>(p).get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<void*>(NULL), p.get_nothrow<void>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<int*>(NULL), p.get_nothrow<int>());
folly/test/ScopeGuardTest.cpp:      throw std::runtime_error("destructors should never throw!");
folly/test/ScopeGuardTest.cpp:  "destructors should never throw");
folly/test/ScopeGuardTest.cpp: * to close a db connection regardless if an exception was thrown during
folly/test/ScopeGuardTest.cpp: *     throw e; // re-throw the exception
folly/test/ScopeGuardTest.cpp:        throw std::runtime_error("throwing an expected error");
folly/test/ScopeGuardTest.cpp:        throw "never throw raw strings";
folly/test/ScopeGuardTest.cpp:    throw std::runtime_error("test");
folly/test/FBStringLibstdcxxStdexceptTest.cpp:          (use std::__throw_* from funcexcept.h instead)
folly/test/ConvTest.cpp:  // However, if the next character would cause an overflow it throws a
folly/test/ConvTest.cpp:    throw std::runtime_error("empty string");
folly/test/ConvTest.cpp:      throw std::runtime_error("overflow");
folly/test/ConvTest.cpp:    throw std::runtime_error("extra chars at the end");
folly/test/AtomicHashMapTest.cpp:    static bool throwException_ = false;
folly/test/AtomicHashMapTest.cpp:    throwException_ = !throwException_;
folly/test/AtomicHashMapTest.cpp:    if (throwException_) {
folly/test/AtomicHashMapTest.cpp:      throw 1;
folly/test/small_vector_test.cpp:int throwCounter = 1;
folly/test/small_vector_test.cpp:  if (!--throwCounter) {
folly/test/small_vector_test.cpp:    throw TestException();
folly/test/small_vector_test.cpp:// Check that throws don't break the basic guarantee for some cases.
folly/test/small_vector_test.cpp:// throwing code paths to occur.
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = counter;
folly/test/small_vector_test.cpp:       * of the above push_back's, and one of the Throwers throws,
folly/test/small_vector_test.cpp:    throwCounter = 4;
folly/StlAllocator.h: * alignment required on your system), throwing std::bad_alloc if the
folly/StlAllocator.h: *     if (!p) throw std::bad_alloc();
folly/dynamic.h: * complete interface than the raw type), and it'll just throw a
folly/dynamic.h:   * those types.  For objects, we throw TypeError.
folly/dynamic.h:   * These throw TypeError when used with types or type combinations
folly/dynamic.h:   * These functions may also throw if you use 64-bit integers with
folly/dynamic.h:   * throws TypeError.
folly/dynamic.h:   * non-arrays will throw a TypeError.
folly/dynamic.h:   * value) in an object.  Calling these on non-objects will throw a TypeError.
folly/dynamic.h:   * the given name.  Otherwise throws TypeError.
folly/dynamic.h:   * will throw a TypeError.  Using an index that is out of range or
folly/dynamic.h:   * object-element that's not present throws std::out_of_range.
folly/dynamic.h:   * In the case of an array, the index must be an integer, and this will throw
folly/dynamic.h:   * value if the key isn't present.  The const overload will throw
folly/dynamic.h:   * Only defined for objects, throws TypeError otherwise.
folly/dynamic.h:   * Inserts the supplied key-value pair to an object, or throws if
folly/dynamic.h:   * Append elements to an array.  If this is not an array, throws
folly/dynamic.h:  template<class T> T*       get_nothrow();
folly/dynamic.h:  template<class T> T const* get_nothrow() const;
folly/String.h: * In strict mode (default), throws std::invalid_argument if it encounters
folly/String.h: * This function may allocate memory (and therefore throw).
folly/String.h:struct has_nothrow_constructor<folly::basic_fbstring<T> > : true_type {
folly/DiscriminatedPtr.h: * throws an exception (and get_nothrow returns nullptr)
folly/DiscriminatedPtr.h:  T* get_nothrow() noexcept {
folly/DiscriminatedPtr.h:  const T* get_nothrow() const noexcept {
folly/DiscriminatedPtr.h:   * Types), and throws std::invalid_argument if this DiscriminatedPtr is empty
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/Format-inl.h:  // and throw if we see any lone "}"
folly/Format-inl.h:        throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument("folly::format: missing ending '}'");
folly/Format-inl.h:      throw std::invalid_argument(
folly/String-inl.h:        throw std::invalid_argument("incomplete escape sequence");
folly/String-inl.h:          throw std::invalid_argument("incomplete hex escape sequence");
folly/String-inl.h:        throw std::invalid_argument("invalid escape sequence");
folly/small_vector.h: * overflow the in situ capacity we throw an exception.
folly/small_vector.h:      // threw: if someone throws from a move constructor the effects
folly/small_vector.h:      throw;
folly/small_vector.h:      throw;
folly/small_vector.h:   * anything throws, undo what we did.
folly/small_vector.h:      throw;
folly/small_vector.h:   * Basic guarantee only.  Provides the nothrow guarantee iff our
folly/small_vector.h:   * value_type has a nothrow move or copy constructor.
folly/small_vector.h:        throw;
folly/small_vector.h:      throw;
folly/small_vector.h:     * constructor throwing by clearing the whole vector).
folly/small_vector.h:     * constructor throws, you either need a nothrow default
folly/small_vector.h:     * constructor or a nothrow copy/move to get something back in the
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:   * objects and insertion outside the function, otherwise exception is thrown.
folly/small_vector.h:      throw std::length_error("max_size exceeded in small_vector");
folly/small_vector.h:      throw std::bad_alloc();
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:// Basic guarantee only, or provides the nothrow guarantee iff T has a
folly/small_vector.h:// nothrow move or copy constructor.
folly/experimental/TestUtil.cpp:    throw std::system_error(errno, std::system_category(),
folly/experimental/TestUtil.cpp:      throw std::system_error(errno, std::system_category(),
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("overflow");
folly/experimental/io/Cursor.h: * (and push() and ensure() will throw) if growth == 0.
folly/experimental/io/Cursor.h:      throw std::out_of_range("can't grow buffer chain");
folly/experimental/io/IOBuf.h:   * second argument.  The free function must never throw exceptions.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.  If freeOnError is true (the
folly/experimental/io/IOBuf.h:   * default) the buffer will be freed before throwing the error.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.
folly/experimental/io/IOBuf.h:   * Currently unshare may also throw std::overflow_error if it tries to
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:          // The user's free function is not allowed to throw.
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:    throw std::overflow_error("IOBuf chain too large to coalesce");
folly/experimental/io/IOBuf.cpp:      // The user's free function should never throw.  Otherwise we might
folly/experimental/io/IOBuf.cpp:      // throw from the IOBuf destructor.  Other code paths like coalesce()
folly/experimental/io/IOBuf.cpp:      // also assume that decrementRefcount() cannot throw.
folly/experimental/io/IOBuf.cpp:            throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:          throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBufQueue.h:   * @throws std::underflow_error if n exceeds the number of bytes
folly/experimental/io/IOBufQueue.h:      throw std::invalid_argument("IOBufQueue: chain length not cached");
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/Traits.h:  struct has_nothrow_constructor<  __VA_ARGS__ > : ::boost::true_type {};
folly/Traits.h: * above, and that it has a nothrow constructor. Most types can be
folly/Traits.h:struct has_nothrow_constructor< std::pair<T, U> >
folly/Traits.h:    : ::boost::mpl::and_< has_nothrow_constructor<T>,
folly/Traits.h:                          has_nothrow_constructor<U> > {};
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/FBVector.h:  boost::has_nothrow_constructor<T>::value
folly/FBVector.h:  !boost::has_nothrow_constructor<T>::value
folly/FBVector.h: * value. If the operation throws, destroys all objects constructed so
folly/FBVector.h:  } else if (boost::has_nothrow_constructor<T>::value) {
folly/FBVector.h:      throw;
folly/FBVector.h: * operation throws, destroys all objects constructed so far and calls
folly/FBVector.h:      throw;
folly/FBVector.h:      // Careful here, fill and uninitialized_fill may throw. The
folly/FBVector.h:      throw std::out_of_range("fbvector: index is greater than size.");
folly/FBVector.h:        throw;
folly/FBVector.h:        throw;
folly/FBString.h:      void (*throw_exc)(const char*),
folly/FBString.h:    if (!condition) throw_exc(msg);
folly/FBString.h:          std::__throw_logic_error(err.c_str());
folly/FBString.h:    enforce(res_arg <= max_size(), std::__throw_length_error, "");
folly/FBString.h:    enforce(n <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(n < size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos1 <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.size(), std::__throw_out_of_range, "");
folly/detail/ThreadLocalDetail.h:      throw std::runtime_error("pthread_key_create failed: " + msg);
folly/detail/ThreadLocalDetail.h:      LOG(WARNING) << "Destructor discarding an exception that was thrown.";
folly/detail/ThreadLocalDetail.h:          throw std::bad_alloc();
folly/AtomicHashMap-inl.h:    throw AtomicHashMapFullError();
folly/AtomicHashArray-inl.h:            throw;
folly/ScopeGuard.h: *   // this will throw an exception upon error, which
folly/ScopeGuard.h: *   // an exception was not thrown, so don't execute
folly/String.cpp:    throw std::runtime_error(
folly/String.cpp:      throw std::runtime_error(
folly/json.cpp:    throw std::runtime_error("folly::decodeUtf8 empty/invalid string");
folly/json.cpp:    throw std::runtime_error(
folly/json.cpp:      throw std::runtime_error(
folly/json.cpp:        throw std::runtime_error(
folly/json.cpp:          throw std::runtime_error(
folly/json.cpp:  throw std::runtime_error("folly::decodeUtf8 encoding length maxed out");
folly/json.cpp:      throw std::runtime_error("folly::toJson: JSON object key was not a "
folly/json.cpp:      throw ParseError(lineNum_, context(),
folly/json.cpp:    throw ParseError(lineNum_, context(), what);
folly/Arena.h: *      alignment required on your system; throw std::bad_alloc if the
folly/Arena.h:    if (!mem) throw std::bad_alloc();

Also, another example is Arduino hardware SDK usnig gcc without exception activated in C++, and other things like no STL provided.

I'm adding another surprising example here: LLVM/CLang dont use exception nor RTTI for the followin reasons:


Update:

Yet another interesting example: Folly from Facebook. See https://github.com/facebook/folly/blob/master/folly/README

However, the rational for this choice isn't explained in the file. Also, not all Folly code seem to follow the rule... so maybe the rule isn't up to date. See:

grep -R throw folly

Gives:

folly/AtomicHashMap.h: *   Insert returns false if there is a key collision and throws if the max size
folly/AtomicHashMap.h:   *   AtomicHashMapFullError is thrown.
folly/ProducerConsumerQueue.h:      throw std::bad_alloc();
folly/json.h: * system, the serializer will throw.
folly/json.h:     * precisely represented by fit a double---instead, throws an
folly/dynamic-inl.h:   * double, or throws if either is not a numeric type.
folly/dynamic-inl.h:      throw TypeError("numeric", a.type(), b.type());
folly/dynamic-inl.h:inline bool dynamic::isString() const { return get_nothrow<fbstring>(); }
folly/dynamic-inl.h:inline bool dynamic::isObject() const { return get_nothrow<ObjectImpl>(); }
folly/dynamic-inl.h:inline bool dynamic::isBool()   const { return get_nothrow<bool>(); }
folly/dynamic-inl.h:inline bool dynamic::isArray()  const { return get_nothrow<Array>(); }
folly/dynamic-inl.h:inline bool dynamic::isDouble() const { return get_nothrow<double>(); }
folly/dynamic-inl.h:inline bool dynamic::isInt()    const { return get_nothrow<int64_t>(); }
folly/dynamic-inl.h:inline bool dynamic::isNull()   const { return get_nothrow<void*>(); }
folly/dynamic-inl.h:    throw TypeError("object", type_);
folly/dynamic-inl.h:      throw TypeError("int64", type(), o.type());           \
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:    throw TypeError("object/array", type());
folly/dynamic-inl.h:  if (auto* parray = get_nothrow<Array>()) {
folly/dynamic-inl.h:      throw std::out_of_range("out of range in dynamic array");
folly/dynamic-inl.h:      throw TypeError("int64", idx.type());
folly/dynamic-inl.h:  auto* pobj = get_nothrow<ObjectImpl>();
folly/dynamic-inl.h:    throw std::out_of_range(to<std::string>(
folly/dynamic-inl.h:  if (auto* ar = get_nothrow<Array>()) {
folly/dynamic-inl.h:  if (auto* obj = get_nothrow<ObjectImpl>()) {
folly/dynamic-inl.h:  if (auto* str = get_nothrow<fbstring>()) {
folly/dynamic-inl.h:  throw TypeError("array/object", type());
folly/dynamic-inl.h:    throw TypeError("not null/object/array", type());
folly/dynamic-inl.h:  case INT64:    return to<T>(*get_nothrow<int64_t>());
folly/dynamic-inl.h:  case DOUBLE:   return to<T>(*get_nothrow<double>());
folly/dynamic-inl.h:  case BOOL:     return to<T>(*get_nothrow<bool>());
folly/dynamic-inl.h:  case STRING:   return to<T>(*get_nothrow<fbstring>());
folly/dynamic-inl.h:    throw TypeError("int/double/bool/string", type());
folly/dynamic-inl.h:T* dynamic::get_nothrow() {
folly/dynamic-inl.h:T const* dynamic::get_nothrow() const {
folly/dynamic-inl.h:  return const_cast<dynamic*>(this)->get_nothrow<T>();
folly/dynamic-inl.h:  if (auto* p = get_nothrow<T>()) {
folly/dynamic-inl.h:  throw TypeError(TypeInfo<T>::name, type());
folly/docs/Dynamic.md:`folly::TypeError`. Other exceptions can also be thrown if
folly/docs/Dynamic.md:    dynamic hugeDoub = hugeInt.asDouble();  // throws a folly/Conv.h error,
folly/docs/Conv.md:* Otherwise, `to` inserts bounds checks and throws
folly/docs/FBVector.md:assignment is the same as bitblitting the bits over) or a nothrow
folly/docs/FBVector.md:      (boost::has_trivial_assign<T>::value || boost::has_nothrow_constructor<T>::value));
folly/FormatArg.h:   * Validate the argument for the given type; throws on error.
folly/FormatArg.h:   * is thrown otherwise).
folly/FormatArg.h:   * integer (an exception is thrown otherwise).
folly/FormatArg.h:  throw std::invalid_argument(to<std::string>(
folly/Conv.h:  ((condition) ? (void)0 : throw std::range_error(                      \
folly/Conv.h: * in which case digits_to throws.
folly/Conv.h:    throw std::range_error("Cannot convert string " +
folly/Conv.h:      throw std::range_error("Unable to convert an empty string"
folly/Conv.h:  throw std::range_error("Unable to convert \"" + src->toString()
folly/Conv.h:    throw std::range_error(
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/sorted_vector_types.h:  // Nothrow as long as swap() on the Compare type is nothrow.
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, p.get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(&a, static_cast<const Ptr&>(p).get_nothrow<int>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<void*>(NULL), p.get_nothrow<void>());
folly/test/DiscriminatedPtrTest.cpp:  EXPECT_EQ(static_cast<int*>(NULL), p.get_nothrow<int>());
folly/test/ScopeGuardTest.cpp:      throw std::runtime_error("destructors should never throw!");
folly/test/ScopeGuardTest.cpp:  "destructors should never throw");
folly/test/ScopeGuardTest.cpp: * to close a db connection regardless if an exception was thrown during
folly/test/ScopeGuardTest.cpp: *     throw e; // re-throw the exception
folly/test/ScopeGuardTest.cpp:        throw std::runtime_error("throwing an expected error");
folly/test/ScopeGuardTest.cpp:        throw "never throw raw strings";
folly/test/ScopeGuardTest.cpp:    throw std::runtime_error("test");
folly/test/FBStringLibstdcxxStdexceptTest.cpp:          (use std::__throw_* from funcexcept.h instead)
folly/test/ConvTest.cpp:  // However, if the next character would cause an overflow it throws a
folly/test/ConvTest.cpp:    throw std::runtime_error("empty string");
folly/test/ConvTest.cpp:      throw std::runtime_error("overflow");
folly/test/ConvTest.cpp:    throw std::runtime_error("extra chars at the end");
folly/test/AtomicHashMapTest.cpp:    static bool throwException_ = false;
folly/test/AtomicHashMapTest.cpp:    throwException_ = !throwException_;
folly/test/AtomicHashMapTest.cpp:    if (throwException_) {
folly/test/AtomicHashMapTest.cpp:      throw 1;
folly/test/small_vector_test.cpp:int throwCounter = 1;
folly/test/small_vector_test.cpp:  if (!--throwCounter) {
folly/test/small_vector_test.cpp:    throw TestException();
folly/test/small_vector_test.cpp:// Check that throws don't break the basic guarantee for some cases.
folly/test/small_vector_test.cpp:// throwing code paths to occur.
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:    throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = 1000;
folly/test/small_vector_test.cpp:      throwCounter = counter;
folly/test/small_vector_test.cpp:       * of the above push_back's, and one of the Throwers throws,
folly/test/small_vector_test.cpp:    throwCounter = 4;
folly/StlAllocator.h: * alignment required on your system), throwing std::bad_alloc if the
folly/StlAllocator.h: *     if (!p) throw std::bad_alloc();
folly/dynamic.h: * complete interface than the raw type), and it'll just throw a
folly/dynamic.h:   * those types.  For objects, we throw TypeError.
folly/dynamic.h:   * These throw TypeError when used with types or type combinations
folly/dynamic.h:   * These functions may also throw if you use 64-bit integers with
folly/dynamic.h:   * throws TypeError.
folly/dynamic.h:   * non-arrays will throw a TypeError.
folly/dynamic.h:   * value) in an object.  Calling these on non-objects will throw a TypeError.
folly/dynamic.h:   * the given name.  Otherwise throws TypeError.
folly/dynamic.h:   * will throw a TypeError.  Using an index that is out of range or
folly/dynamic.h:   * object-element that's not present throws std::out_of_range.
folly/dynamic.h:   * In the case of an array, the index must be an integer, and this will throw
folly/dynamic.h:   * value if the key isn't present.  The const overload will throw
folly/dynamic.h:   * Only defined for objects, throws TypeError otherwise.
folly/dynamic.h:   * Inserts the supplied key-value pair to an object, or throws if
folly/dynamic.h:   * Append elements to an array.  If this is not an array, throws
folly/dynamic.h:  template<class T> T*       get_nothrow();
folly/dynamic.h:  template<class T> T const* get_nothrow() const;
folly/String.h: * In strict mode (default), throws std::invalid_argument if it encounters
folly/String.h: * This function may allocate memory (and therefore throw).
folly/String.h:struct has_nothrow_constructor<folly::basic_fbstring<T> > : true_type {
folly/DiscriminatedPtr.h: * throws an exception (and get_nothrow returns nullptr)
folly/DiscriminatedPtr.h:  T* get_nothrow() noexcept {
folly/DiscriminatedPtr.h:  const T* get_nothrow() const noexcept {
folly/DiscriminatedPtr.h:   * Types), and throws std::invalid_argument if this DiscriminatedPtr is empty
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:      throw std::invalid_argument("Invalid type");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/DiscriminatedPtr.h:    if (n == 0) throw std::invalid_argument("Empty DiscriminatedPtr");
folly/Format-inl.h:  // and throw if we see any lone "}"
folly/Format-inl.h:        throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument(
folly/Format-inl.h:      throw std::invalid_argument("folly::format: missing ending '}'");
folly/Format-inl.h:      throw std::invalid_argument(
folly/String-inl.h:        throw std::invalid_argument("incomplete escape sequence");
folly/String-inl.h:          throw std::invalid_argument("incomplete hex escape sequence");
folly/String-inl.h:        throw std::invalid_argument("invalid escape sequence");
folly/small_vector.h: * overflow the in situ capacity we throw an exception.
folly/small_vector.h:      // threw: if someone throws from a move constructor the effects
folly/small_vector.h:      throw;
folly/small_vector.h:      throw;
folly/small_vector.h:   * anything throws, undo what we did.
folly/small_vector.h:      throw;
folly/small_vector.h:   * Basic guarantee only.  Provides the nothrow guarantee iff our
folly/small_vector.h:   * value_type has a nothrow move or copy constructor.
folly/small_vector.h:        throw;
folly/small_vector.h:      throw;
folly/small_vector.h:     * constructor throwing by clearing the whole vector).
folly/small_vector.h:     * constructor throws, you either need a nothrow default
folly/small_vector.h:     * constructor or a nothrow copy/move to get something back in the
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:      throw std::out_of_range();
folly/small_vector.h:   * objects and insertion outside the function, otherwise exception is thrown.
folly/small_vector.h:      throw std::length_error("max_size exceeded in small_vector");
folly/small_vector.h:      throw std::bad_alloc();
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:        throw;
folly/small_vector.h:// Basic guarantee only, or provides the nothrow guarantee iff T has a
folly/small_vector.h:// nothrow move or copy constructor.
folly/experimental/TestUtil.cpp:    throw std::system_error(errno, std::system_category(),
folly/experimental/TestUtil.cpp:      throw std::system_error(errno, std::system_category(),
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("underflow");
folly/experimental/io/Cursor.h:      throw std::out_of_range("overflow");
folly/experimental/io/Cursor.h: * (and push() and ensure() will throw) if growth == 0.
folly/experimental/io/Cursor.h:      throw std::out_of_range("can't grow buffer chain");
folly/experimental/io/IOBuf.h:   * second argument.  The free function must never throw exceptions.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.  If freeOnError is true (the
folly/experimental/io/IOBuf.h:   * default) the buffer will be freed before throwing the error.
folly/experimental/io/IOBuf.h:   * On error, std::bad_alloc will be thrown.
folly/experimental/io/IOBuf.h:   * Currently unshare may also throw std::overflow_error if it tries to
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:          // The user's free function is not allowed to throw.
folly/experimental/io/IOBuf.cpp:    throw;
folly/experimental/io/IOBuf.cpp:    throw std::overflow_error("IOBuf chain too large to coalesce");
folly/experimental/io/IOBuf.cpp:      // The user's free function should never throw.  Otherwise we might
folly/experimental/io/IOBuf.cpp:      // throw from the IOBuf destructor.  Other code paths like coalesce()
folly/experimental/io/IOBuf.cpp:      // also assume that decrementRefcount() cannot throw.
folly/experimental/io/IOBuf.cpp:            throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:          throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:      throw std::bad_alloc();
folly/experimental/io/IOBuf.cpp:    throw std::bad_alloc();
folly/experimental/io/IOBufQueue.h:   * @throws std::underflow_error if n exceeds the number of bytes
folly/experimental/io/IOBufQueue.h:      throw std::invalid_argument("IOBufQueue: chain length not cached");
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/experimental/io/IOBufQueue.cpp:      throw std::underflow_error(
folly/Traits.h:  struct has_nothrow_constructor<  __VA_ARGS__ > : ::boost::true_type {};
folly/Traits.h: * above, and that it has a nothrow constructor. Most types can be
folly/Traits.h:struct has_nothrow_constructor< std::pair<T, U> >
folly/Traits.h:    : ::boost::mpl::and_< has_nothrow_constructor<T>,
folly/Traits.h:                          has_nothrow_constructor<U> > {};
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/Range.h:    if (i >= size()) throw std::out_of_range("index out of range");
folly/FBVector.h:  boost::has_nothrow_constructor<T>::value
folly/FBVector.h:  !boost::has_nothrow_constructor<T>::value
folly/FBVector.h: * value. If the operation throws, destroys all objects constructed so
folly/FBVector.h:  } else if (boost::has_nothrow_constructor<T>::value) {
folly/FBVector.h:      throw;
folly/FBVector.h: * operation throws, destroys all objects constructed so far and calls
folly/FBVector.h:      throw;
folly/FBVector.h:      // Careful here, fill and uninitialized_fill may throw. The
folly/FBVector.h:      throw std::out_of_range("fbvector: index is greater than size.");
folly/FBVector.h:        throw;
folly/FBVector.h:        throw;
folly/FBString.h:      void (*throw_exc)(const char*),
folly/FBString.h:    if (!condition) throw_exc(msg);
folly/FBString.h:          std::__throw_logic_error(err.c_str());
folly/FBString.h:    enforce(res_arg <= max_size(), std::__throw_length_error, "");
folly/FBString.h:    enforce(n <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(n < size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= sz, std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.length(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos1 <= size(), std::__throw_out_of_range, "");
folly/FBString.h:    enforce(pos2 <= str.size(), std::__throw_out_of_range, "");
folly/detail/ThreadLocalDetail.h:      throw std::runtime_error("pthread_key_create failed: " + msg);
folly/detail/ThreadLocalDetail.h:      LOG(WARNING) << "Destructor discarding an exception that was thrown.";
folly/detail/ThreadLocalDetail.h:          throw std::bad_alloc();
folly/AtomicHashMap-inl.h:    throw AtomicHashMapFullError();
folly/AtomicHashArray-inl.h:            throw;
folly/ScopeGuard.h: *   // this will throw an exception upon error, which
folly/ScopeGuard.h: *   // an exception was not thrown, so don't execute
folly/String.cpp:    throw std::runtime_error(
folly/String.cpp:      throw std::runtime_error(
folly/json.cpp:    throw std::runtime_error("folly::decodeUtf8 empty/invalid string");
folly/json.cpp:    throw std::runtime_error(
folly/json.cpp:      throw std::runtime_error(
folly/json.cpp:        throw std::runtime_error(
folly/json.cpp:          throw std::runtime_error(
folly/json.cpp:  throw std::runtime_error("folly::decodeUtf8 encoding length maxed out");
folly/json.cpp:      throw std::runtime_error("folly::toJson: JSON object key was not a "
folly/json.cpp:      throw ParseError(lineNum_, context(),
folly/json.cpp:    throw ParseError(lineNum_, context(), what);
folly/Arena.h: *      alignment required on your system; throw std::bad_alloc if the
folly/Arena.h:    if (!mem) throw std::bad_alloc();

Also, another example is [Arduino hardware SDK usnig gcc without exception activated in C++, and other things like no STL provided][1].

I'm adding another surprising example here: [LLVM/CLang dont use exception nor RTTI for the followin reasons][2]:

5 updated folly example and added some segmentations to the answer
source | link
4 added folly as another example
source | link
3 another good example
source | link
2 added 1577 characters in body
source | link
1
source | link