From 7cae35024f0d3a74e424eae12596f6398f60a948 Mon Sep 17 00:00:00 2001 From: Merry Date: Sat, 19 Nov 2022 22:44:16 +0000 Subject: [PATCH] common: Add StringLiteral --- src/common/CMakeLists.txt | 1 + src/common/string_literal.h | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/common/string_literal.h diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 48914c960..e4f8b25e8 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -104,6 +104,7 @@ add_library(common STATIC serialization/boost_flat_set.h serialization/boost_small_vector.hpp serialization/boost_vector.hpp + string_literal.h string_util.cpp string_util.h swap.h diff --git a/src/common/string_literal.h b/src/common/string_literal.h new file mode 100644 index 000000000..cc148edda --- /dev/null +++ b/src/common/string_literal.h @@ -0,0 +1,24 @@ +// Copyright 2022 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Common { + +template +struct StringLiteral { + constexpr StringLiteral(const char (&str)[N]) { + std::copy_n(str, N, value); + } + + static constexpr std::size_t strlen = N - 1; + static constexpr std::size_t size = N; + + char value[N]; +}; + +} // namespace Common