https://gitlab.opengeosys.org/ogs/ogs.git
Revision 96f6b540f209a25ee84a24bf7b6d2309b0efc445 authored by Dmitri Naumov on 31 January 2023, 10:36:02 UTC, committed by Dmitri Naumov on 01 February 2023, 14:23:26 UTC
1 parent 3fb75b9
Raw File
Tip revision: 96f6b540f209a25ee84a24bf7b6d2309b0efc445 authored by Dmitri Naumov on 31 January 2023, 10:36:02 UTC
[PL/CT] Change assertion to OGS_FATAL
Tip revision: 96f6b54
DynamicSpan.h
/**
 * \file
 * \copyright
 * Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 */

#pragma once

#include <cstddef>

namespace BaseLib
{
template <typename T>
struct DynamicSpan
{
    template <typename Iterator>
    DynamicSpan(Iterator data_, std::size_t size)
        : data{&*data_ /* manually convert iterator to pointer */}, size_{size}
    {
    }

    T* begin() const { return data; }
    T* end() const { return data + size_; }
    std::size_t size() const { return size_; }
    T& operator[](std::size_t i) const { return data[i]; }

    T* data;

private:
    std::size_t size_;
};

template <typename T>
DynamicSpan(T*, std::size_t) -> DynamicSpan<T>;
}  // namespace BaseLib
back to top