Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
span_compat.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
23// TODO: Remove this shim and switch call sites to `std::span<T>` once the
24// project no longer needs to support C++17 toolchains.
25
30#if __cplusplus >= 202002L || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
31#define MOMENTUM_HAS_CPP20_SPAN 1
32#else
33#define MOMENTUM_HAS_CPP20_SPAN 0
34#endif
35
36#if MOMENTUM_HAS_CPP20_SPAN
37#include <span>
38#else
39#include <gsl/span>
40#endif
41
42namespace momentum {
43
44#if MOMENTUM_HAS_CPP20_SPAN
45
47template <typename T>
48using span = std::span<T>;
49
50#else
51
53template <typename T>
54using span = gsl::span<T>;
55
56#endif
57
58} // namespace momentum
gsl::span< T > span
Span type alias using gsl::span (C++17 fallback).
Definition span_compat.h:54