forked from qt-creator/qt-creator
Change-Id: I24dffa459ad8a948fd58d83249cb07c827a6343f Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
26 lines
727 B
C++
26 lines
727 B
C++
// Copyright (C) 2023 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
#pragma once
|
|
|
|
#include <array>
|
|
|
|
namespace Utils {
|
|
|
|
namespace Internal {
|
|
template<typename Type, std::size_t size, std::size_t... index>
|
|
constexpr std::array<std::remove_cv_t<Type>, size> to_array_implementation(
|
|
Type (&&array)[size], std::index_sequence<index...>)
|
|
{
|
|
return {{std::move(array[index])...}};
|
|
}
|
|
} // namespace Internal
|
|
|
|
template<typename Type, std::size_t size>
|
|
constexpr std::array<std::remove_cv_t<Type>, size> to_array(Type (&&array)[size])
|
|
{
|
|
return Internal::to_array_implementation(std::move(array), std::make_index_sequence<size>{});
|
|
}
|
|
|
|
} // namespace Utils
|