https://gitlab.opengeosys.org/ogs/ogs.git
Revision e64d5d3ccf3a621499d171cc2d35444ead73b0ec authored by Lars Bilke on 07 January 2023, 20:50:59 UTC, committed by Lars Bilke on 07 January 2023, 20:50:59 UTC
Fixes for sanitizer job and MSVC release config

See merge request ogs/ogs!4432
2 parent s b0756c3 + 3e60d14
Raw File
Tip revision: e64d5d3ccf3a621499d171cc2d35444ead73b0ec authored by Lars Bilke on 07 January 2023, 20:50:59 UTC
Merge branch 'fixes' into 'master'
Tip revision: e64d5d3
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