#pragma once #include namespace alpaqa { #ifdef EIGEN_RUNTIME_NO_MALLOC template struct ScopedMallocChecker { ScopedMallocChecker() : prev(Eigen::internal::is_malloc_allowed()) { Eigen::internal::set_is_malloc_allowed(Allow); } ~ScopedMallocChecker() { Eigen::internal::set_is_malloc_allowed(prev); } bool prev; }; #else template struct [[maybe_unused]] ScopedMallocChecker {}; #endif struct [[maybe_unused]] ScopedMallocBlocker : ScopedMallocChecker {}; struct [[maybe_unused]] ScopedMallocAllower : ScopedMallocChecker {}; } // namespace alpaqa