Added full check constexpr constructor
This commit is contained in:
parent
b1c8927679
commit
3e1c4cfb84
1 changed files with 20 additions and 9 deletions
|
@ -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);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue