Commit fd2292f1 authored by Victor Zverovich's avatar Victor Zverovich

Cleanup checked iterators

parent 4912cff6
...@@ -307,17 +307,13 @@ class format_error : public std::runtime_error { ...@@ -307,17 +307,13 @@ class format_error : public std::runtime_error {
namespace internal { namespace internal {
#if FMT_SECURE_SCL #if FMT_SECURE_SCL
template <typename T> struct checked { // Make a checked iterator to avoid MSVC warnings.
typedef stdext::checked_array_iterator<T*> type; template <typename T> using checked_ptr = stdext::checked_array_iterator<T*>;
}; template <typename T> checked_ptr<T> make_checked(T* p, std::size_t size) {
// Make a checked iterator to avoid warnings on MSVC.
template <typename T>
inline stdext::checked_array_iterator<T*> make_checked(T* p, std::size_t size) {
return {p, size}; return {p, size};
} }
#else #else
template <typename T> struct checked { typedef T* type; }; template <typename T> using checked_ptr = T*;
template <typename T> inline T* make_checked(T* p, std::size_t) { return p; } template <typename T> inline T* make_checked(T* p, std::size_t) { return p; }
#endif #endif
...@@ -487,7 +483,7 @@ inline typename Container::value_type* get_data(Container& c) { ...@@ -487,7 +483,7 @@ inline typename Container::value_type* get_data(Container& c) {
} }
template <typename Container, FMT_ENABLE_IF(is_contiguous<Container>::value)> template <typename Container, FMT_ENABLE_IF(is_contiguous<Container>::value)>
inline typename checked<typename Container::value_type>::type reserve( inline checked_ptr<typename Container::value_type> reserve(
std::back_insert_iterator<Container>& it, std::size_t n) { std::back_insert_iterator<Container>& it, std::size_t n) {
Container& c = internal::get_container(it); Container& c = internal::get_container(it);
std::size_t size = c.size(); std::size_t size = c.size();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment