Skip to content

Repository files navigation

PolyH

PolyH - Polymorphic Helpers

VirtualBase

Curiously recurring template pattern solution with supporting multilevel inheritance and without suffering from diamond problem.

 #include"detail/polyh/crtp_macro.hpp"
#include"detail/polyh/virtual_base.hpp"
#include<iostream>constexprint forty_and_two{42};
template<typename Derived>
classQuestion : publicmarklar::detail::polyh::VirtualBase<Derived, Question> {
public:voidprint_answer() constnoexcept
{
std::cout << CRTP_UNDERLYING.answer() << " - The Answer to the Ultimate Question of Life, The Universe, and Everything.\n";
}
};
classAnswer : publicQuestion<Answer> {
CRTP_FRIEND(Question<Answer>)
protected:constexprintanswer() constnoexcept
{
return forty_and_two;
}
};
intmain()
{
Answer answare;
answare.print_answer();
return0;
}

VirtualAssign

Work in progress

VirtualCompare

Work in progress

About

PolyH - Polymorphic Helpers

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages