Added full check constexpr constructor

This commit is contained in:
sha512sum 2024-06-30 12:53:21 +00:00
parent b1c8927679
commit 3e1c4cfb84

View file

@ -261,21 +261,32 @@ struct ServiceContext {
constexpr auto GetContextFor() /* Internal Use Only */ { constexpr auto GetContextFor() /* Internal Use Only */ {
return impl::ServiceContextForComponent<Component, std::decay_t<decltype(*this)>>{*this}; return impl::ServiceContextForComponent<Component, std::decay_t<decltype(*this)>>{*this};
}; };
private:
static constexpr struct {
constexpr auto operator=(auto&&) const noexcept {};
} ComponentType{};
static constexpr struct {
constexpr auto operator=(auto&&) const noexcept {};
} ComponentName{};
static constexpr struct {
constexpr auto operator=(auto&&) const noexcept {};
} ComponentOptions{};
static constexpr struct {
constexpr auto operator=(auto&&) const noexcept {};
} RequiredComponent;
public:
template <typename Current, std::size_t I> template <typename Current, std::size_t I>
constexpr auto FindComponent() -> decltype(*Get<I>(this->storage))& { constexpr auto FindComponent() -> decltype(*Get<I>(this->storage))& {
constexpr auto Index = kUtils.GetIndexByName(Current::kName); constexpr auto Index = kUtils.GetIndexByName(Current::kName);
constexpr auto J = utempl::loopholes::Counter<Current, utempl::Wrapper<I>>();
constexpr utempl::ConstexprString name = Current::kName;
constexpr Options options = Current::kOptions;
constexpr auto dependencies = Get<Index>(DependencyGraph); constexpr auto dependencies = Get<Index>(DependencyGraph);
static_assert(( static_assert((
/* Component Type */ std::ignore = utempl::kType<typename Current::Type>, ComponentType = utempl::kType<typename Current::Type>,
/* Component Name */ std::ignore = name, ComponentName = utempl::kWrapper<Current::kName>,
/* Component Options */ std::ignore = options, ComponentOptions = utempl::kWrapper<Current::kOptions>,
dependencies.size() != 0), "Constructor is not declared as constexpr"); RequiredComponent = utempl::kType<decltype(Get<I>(kUtils.kComponentConfigs))>,
dependencies.size() > J), "Constructor is not declared as constexpr");
return *Get<I>(this->storage); return *Get<I>(this->storage);
}; };