alpaqa 1.0.0a10
Nonconvex constrained optimization
Loading...
Searching...
No Matches
alloc-check.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <Eigen/Core>
4
5namespace alpaqa {
6
7#ifdef EIGEN_RUNTIME_NO_MALLOC
8template <bool Allow>
9struct ScopedMallocChecker {
10 ScopedMallocChecker() : prev(Eigen::internal::is_malloc_allowed()) {
11 Eigen::internal::set_is_malloc_allowed(Allow);
12 }
13 ~ScopedMallocChecker() { Eigen::internal::set_is_malloc_allowed(prev); }
14 bool prev;
15};
16#else
17template <bool>
18struct [[maybe_unused]] ScopedMallocChecker {};
19#endif
20struct [[maybe_unused]] ScopedMallocBlocker : ScopedMallocChecker<false> {};
21struct [[maybe_unused]] ScopedMallocAllower : ScopedMallocChecker<true> {};
22
23} // namespace alpaqa