Skip to content

Commit

Permalink
use using in slice
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Apr 5, 2023
1 parent 971bbfa commit 3fd513f
Showing 1 changed file with 3 additions and 35 deletions.
38 changes: 3 additions & 35 deletions include/exiv2/slice.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,19 +160,11 @@ struct ConstSliceBase : SliceBase {
*/
template <template <typename> class storage_type, typename data_type>
struct MutableSliceBase : public ConstSliceBase<storage_type, data_type> {
using ConstSliceBase<storage_type, data_type>::ConstSliceBase;
using iterator = typename ConstSliceBase<storage_type, data_type>::iterator;
using const_iterator = typename ConstSliceBase<storage_type, data_type>::const_iterator;
using value_type = typename ConstSliceBase<storage_type, data_type>::value_type;

/*!
* Forwards everything to the constructor of const_slice_base
*
* @todo use using once we have C++11
*/
MutableSliceBase(data_type& data, size_t begin, size_t end) :
ConstSliceBase<storage_type, data_type>(data, begin, end) {
}

/*!
* Obtain a reference to the element with the specified index in the
* slice.
Expand Down Expand Up @@ -427,8 +419,8 @@ struct PtrSliceStorage {
*/
template <typename container>
struct Slice : public Internal::MutableSliceBase<Internal::ContainerStorage, container> {
using Internal::MutableSliceBase<Internal::ContainerStorage, container>::MutableSliceBase;
using iterator = typename container::iterator;

using const_iterator = typename container::const_iterator;

#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L
Expand All @@ -437,26 +429,6 @@ struct Slice : public Internal::MutableSliceBase<Internal::ContainerStorage, con
using value_type = typename std::remove_cv<typename container::value_type>::type;
#endif

/*!
* @brief Construct a slice of the container `cont` starting at `begin`
* (including) and ending before `end`.
*
* @param[in] cont Reference to the container
* @param[in] begin First element of the slice.
* @param[in] end First element beyond the slice.
*
* @throws std::out_of_range For invalid slice bounds: when end is not
* larger than begin or when the slice's bounds are larger than the
* container's size.
*
* Please note that due to the requirement that `end` must be larger
* than `begin` (they cannot be equal) it is impossible to construct a
* slice with zero length.
*/
Slice(container& cont, size_t begin, size_t end) :
Internal::MutableSliceBase<Internal::ContainerStorage, container>(cont, begin, end) {
}

/*!
* Construct a sub-slice of this slice with the given bounds. The bounds
* are evaluated with respect to the current slice.
Expand Down Expand Up @@ -484,8 +456,8 @@ struct Slice : public Internal::MutableSliceBase<Internal::ContainerStorage, con
*/
template <typename container>
struct Slice<const container> : public Internal::ConstSliceBase<Internal::ContainerStorage, const container> {
using Internal::ConstSliceBase<Internal::ContainerStorage, const container>::ConstSliceBase;
using iterator = typename container::iterator;

using const_iterator = typename container::const_iterator;

#if __cplusplus >= 201402L || _MSVC_LANG >= 201402L
Expand All @@ -494,10 +466,6 @@ struct Slice<const container> : public Internal::ConstSliceBase<Internal::Contai
using value_type = typename std::remove_cv<typename container::value_type>::type;
#endif

Slice(const container& cont, size_t begin, size_t end) :
Internal::ConstSliceBase<Internal::ContainerStorage, const container>(cont, begin, end) {
}

Slice subSlice(size_t begin, size_t end) const {
return Internal::ConstSliceBase<Internal::ContainerStorage,
const container>::template subSlice<Slice<const container>>(begin, end);
Expand Down

0 comments on commit 3fd513f

Please sign in to comment.