瀏覽代碼

Add a std::span implementation for old platforms

main
Sam Hocevar 10 月之前
父節點
當前提交
a4d0f2013d
共有 3 個檔案被更改,包括 44 行新增0 行删除
  1. +6
    -0
      .gitmodules
  2. +1
    -0
      include/lol/3rdparty/span
  3. +37
    -0
      include/lol/std/span

+ 6
- 0
.gitmodules 查看文件

@@ -38,6 +38,12 @@
branch = master
update = checkout

[submodule "span"]
path = include/lol/3rdparty/span
url = https://github.com/tcbrindle/span
branch = master
update = checkout

[submodule "doctest"]
path = include/lol/3rdparty/doctest
url = https://github.com/doctest/doctest


+ 1
- 0
include/lol/3rdparty/span

@@ -0,0 +1 @@
Subproject commit 836dc6a0efd9849cb194e88e4aa2387436bb079b

+ 37
- 0
include/lol/std/span 查看文件

@@ -0,0 +1,37 @@
//
// Lol Engine
//
// Copyright © 2010–2025 Sam Hocevar <sam@hocevar.net>
//
// Lol Engine is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#pragma once

// Assume std::span is available, then check for exceptions
#define LOL_HAS_STD_SPAN 1

#if !defined __SCE__
# include <version> // Provide __cpp_lib_span if relevant
# if !defined __cpp_lib_span
# undef LOL_HAS_STD_SPAN
# endif
#endif

#if defined __SCE__ // SCE platforms do not have <version>, so check for C++20 support
# if !_HAS_CXX20
# undef LOL_HAS_STD_SPAN
# endif
#endif

// Include <span> if everything went well, otherwise use the 3rd party implementation
#if defined LOL_HAS_STD_SPAN
# include <span>
#else
# define TCB_SPAN_NAMESPACE_NAME std
# include "../3rdparty/span/include/tcb/span.hpp"
#endif

Loading…
取消
儲存