2024-07-02 16:50:12 +00:00
|
|
|
#include <cserver/components/loggable_component_base.hpp>
|
|
|
|
|
|
|
|
struct SomeComponent {
|
|
|
|
static constexpr utempl::ConstexprString kName = "component";
|
|
|
|
|
2024-07-07 00:48:00 +00:00
|
|
|
explicit constexpr SomeComponent(auto&) {};
|
2024-07-02 16:50:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SomeComponent2 {
|
|
|
|
static constexpr utempl::ConstexprString kName = "component2";
|
|
|
|
|
2024-07-07 00:48:00 +00:00
|
|
|
explicit constexpr SomeComponent2(auto&) {};
|
2024-07-02 16:50:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OtherComponent {
|
|
|
|
static constexpr utempl::ConstexprString kName = "other";
|
|
|
|
|
|
|
|
auto Foo(auto& context) -> void {
|
2024-07-07 00:48:00 +00:00
|
|
|
context.template FindComponent<"component2">(); // UB on runtime with old check
|
|
|
|
// Compile time error with new check(check via loopholes)
|
2024-07-02 16:50:12 +00:00
|
|
|
};
|
|
|
|
|
2024-07-07 00:48:00 +00:00
|
|
|
explicit constexpr OtherComponent(auto& context) {
|
2024-07-02 16:50:12 +00:00
|
|
|
context.template FindComponent<"component">();
|
|
|
|
Foo(context);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-07-07 00:48:00 +00:00
|
|
|
// clang-format off
|
|
|
|
// NOLINTBEGIN
|
2024-07-02 16:50:12 +00:00
|
|
|
auto main() -> int {
|
|
|
|
cserver::ServiceContextBuilder{}
|
|
|
|
.AppendConfigParam<"threads", 8>()
|
|
|
|
.Append<SomeComponent>()
|
|
|
|
.Append<SomeComponent2>()
|
|
|
|
.Append<OtherComponent>()
|
|
|
|
.Sort()
|
|
|
|
.Run();
|
|
|
|
};
|
2024-07-07 00:48:00 +00:00
|
|
|
// NOLINTEND
|