StringLiteral.h 464 B

123456789101112131415161718192021
  1. // Copyright 2023 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <algorithm>
  5. namespace Common
  6. {
  7. // A useful template for passing string literals as arguments to templates
  8. // from: https://ctrpeach.io/posts/cpp20-string-literal-template-parameters/
  9. template <size_t N>
  10. struct StringLiteral
  11. {
  12. consteval StringLiteral(const char (&str)[N]) { std::copy_n(str, N, value); }
  13. char value[N];
  14. };
  15. } // namespace Common