1
0
Fork 0
arangodb/lib/Basics/tryEmplaceHelper.h

18 lines
475 B
C++

#ifndef ARANGODB_BASICS_TRYEMPLACEHELPER_H
#define ARANGODB_BASICS_TRYEMPLACEHELPER_H 1
#include <type_traits>
#include <memory>
namespace arangodb {
template <class Lambda>
struct lazyConstruct {
using type = std::invoke_result_t<const Lambda&>;
constexpr lazyConstruct(Lambda&& factory) : factory_(std::move(factory)) {}
constexpr operator type() const noexcept(std::is_nothrow_invocable_v<const Lambda&>) {
return factory_();
}
Lambda factory_;
};
}
#endif