Print additional info when various out-of-range conditions are detected.
[gcc.git] / libstdc++-v3 / include / std / array
index 86e8aee14baf21cd2463a04832f3fb9c0791ed2b..673d0e4b18d78c2447e0099b00bb1308cec98dd9 100644 (file)
@@ -180,7 +180,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       at(size_type __n)
       {
        if (__n >= _Nm)
-         std::__throw_out_of_range(__N("array::at"));
+         std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
+                                           ">= _Nm (which is %zu)"),
+                                       __n, _Nm);
        return _AT_Type::_S_ref(_M_elems, __n);
       }
 
@@ -190,7 +192,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        // Result of conditional expression must be an lvalue so use
        // boolean ? lvalue : (throw-expr, lvalue)
        return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
-         : (std::__throw_out_of_range(__N("array::at")),
+         : (std::__throw_out_of_range_fmt(__N("array::at: __n (which is %zu) "
+                                              ">= _Nm (which is %zu)"),
+                                          __n, _Nm),
             _AT_Type::_S_ref(_M_elems, 0));
       }