Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
memory.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
10#include <memory>
11
23#ifndef MOMENTUM_DEFINE_POINTERS
24#define MOMENTUM_DEFINE_POINTERS(x) \
25 using x##_p = ::std::shared_ptr<x>; \
26 using x##_u = ::std::unique_ptr<x>; \
27 using x##_w = ::std::weak_ptr<x>; \
28 using x##_const_p = ::std::shared_ptr<const x>; \
29 using x##_const_u = ::std::unique_ptr<const x>; \
30 using x##_const_w = ::std::weak_ptr<const x>;
31#endif // MOMENTUM_DEFINE_POINTERS
32
36#ifndef MOMENTUM_FWD_DECLARE_STRUCT
37#define MOMENTUM_FWD_DECLARE_STRUCT(x) \
38 struct x; \
39 MOMENTUM_DEFINE_POINTERS(x);
40#endif // MOMENTUM_FWD_DECLARE_STRUCT
41
45#ifndef MOMENTUM_FWD_DECLARE_CLASS
46// NOLINTBEGIN(bugprone-macro-parentheses)
47#define MOMENTUM_FWD_DECLARE_CLASS(x) \
48 class x; \
49 MOMENTUM_DEFINE_POINTERS(x)
50// NOLINTEND(bugprone-macro-parentheses)
51#endif // MOMENTUM_FWD_DECLARE_CLASS
52
66#ifndef MOMENTUM_FWD_DECLARE_TEMPLATE_CLASS
67// NOLINTBEGIN(bugprone-macro-parentheses)
68#define MOMENTUM_FWD_DECLARE_TEMPLATE_CLASS(x) \
69 template <typename T> \
70 class x##T; \
71 using x = x##T<float>; \
72 using x##d = x##T<double>; \
73 MOMENTUM_DEFINE_POINTERS(x) \
74 MOMENTUM_DEFINE_POINTERS(x##d)
75// NOLINTEND(bugprone-macro-parentheses)
76#endif // MOMENTUM_FWD_DECLARE_TEMPLATE_CLASS
77
91#ifndef MOMENTUM_FWD_DECLARE_TEMPLATE_STRUCT
92// NOLINTBEGIN(bugprone-macro-parentheses)
93#define MOMENTUM_FWD_DECLARE_TEMPLATE_STRUCT(x) \
94 template <typename T> \
95 struct x##T; \
96 using x = x##T<float>; \
97 using x##d = x##T<double>; \
98 MOMENTUM_DEFINE_POINTERS(x) \
99 MOMENTUM_DEFINE_POINTERS(x##d)
100// NOLINTEND(bugprone-macro-parentheses)
101#endif // MOMENTUM_FWD_DECLARE_TEMPLATE_STRUCT