Add value_type to span (#425)

* Add value_type to span

Currently I'm working on project which involves a lot of `span`s and mocking via Google Mock. Unfortunately a lot of standard matchers requires `value_type` type definition inside container which `gsl::span` lacks.

This pull request add `value_type` type definition inside `gsl::span`

* Strip cv from value_type of span and span_iterator
This commit is contained in:
Maciej T. Nowak 2017-04-13 22:55:20 +02:00 committed by Neil MacIntosh
parent 66cf6896e5
commit c2f953f2eb

View File

@ -133,7 +133,7 @@ namespace details
using element_type_ = typename Span::element_type;
public:
using iterator_category = std::random_access_iterator_tag;
using value_type = std::remove_const_t<element_type_>;
using value_type = std::remove_cv_t<element_type_>;
using difference_type = typename Span::index_type;
using reference =
@ -337,6 +337,7 @@ class span
public:
// constants and types
using element_type = ElementType;
using value_type = std::remove_cv_t<ElementType>;
using index_type = std::ptrdiff_t;
using pointer = element_type*;
using reference = element_type&;
@ -346,6 +347,8 @@ public:
using reverse_iterator = std::reverse_iterator<iterator>;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using size_type = index_type;
constexpr static const index_type extent = Extent;
// [span.cons], span constructors, copy, assignment, and destructor