Newer
Older
Import / research / framework / source / VectorSlice.hpp
@John Ryland John Ryland on 22 Dec 2020 829 bytes import NUC files
/************************************************
*
*  Vector Slice
*  Copyright (C) 2020
*  John Ryland
*  All rights reserved
*
************************************************/
#pragma once
#ifndef VECTOR_SLICE_HPP
#define VECTOR_SLICE_HPP

#include <vector>

template <typename T>
class VectorSlice
{
public:
    // Types
    using Vector = typename std::vector<T>;
    using Iterator = typename Vector::iterator;

    // Constructors
    VectorSlice(const Iterator aBegin, const Iterator aEnd)
        : mBegin(aBegin)
        , mEnd(aEnd)
    {
    }

    // Accessors
    Vector DeepCopy() const { return Vector(begin(), end()); }
    const Iterator& begin() const   { return mBegin; }
    const Iterator& end() const     { return mEnd;   }

private:
    Iterator mBegin;
    Iterator mEnd;
};

#endif // VECTOR_SLICE_HPP