4#define BOOST_TEST_DYN_LINK
5#define BOOST_TEST_MODULE VirtualFunctionTemplateTest
6#include <boost/test/unit_test.hpp>
7using namespace boost::unit_test_framework;
25 std::string getValue_impl(T& ) {
26 return std::string(
"Base: ") +
typeid(T).name();
37 std::string getValue_impl(T& base) {
38 if constexpr(std::is_same_v<std::string, T>) {
41 return std::string(
"Derived1: ") +
typeid(T).name();
52 std::string getValue_impl(T& base) {
53 if constexpr(std::is_same_v<float, T>) {
56 else if constexpr(std::is_same_v<double, T>) {
59 return std::string(
"Derived2: ") +
typeid(T).name();
70 typedef typename std::remove_reference<
decltype(pair)>::type::first_type T;
72 BOOST_TEST(base.
getValue<T>(argument) == std::string(
"Base: ") +
typeid(T).name());
81 typedef typename std::remove_reference<
decltype(pair)>::type::first_type T;
83 if constexpr(std::is_same_v<T, std::string>) {
84 BOOST_TEST(base.
getValue<T>(argument) == std::string(
"Base: ") +
typeid(T).name());
87 BOOST_TEST(base.
getValue<T>(argument) == std::string(
"Derived1: ") +
typeid(T).name());
97 typedef typename std::remove_reference<
decltype(pair)>::type::first_type T;
99 if constexpr(std::is_same_v<T, double>) {
100 BOOST_TEST(base.
getValue<T>(argument) == std::string(
"Base: ") +
typeid(T).name());
102 else if constexpr(std::is_same_v<T, float>) {
103 BOOST_TEST(base.
getValue<T>(argument) == std::string(
"Derived1: ") +
typeid(T).name());
106 BOOST_TEST(base.
getValue<T>(argument) == std::string(
"Derived2: ") +
typeid(T).name());
#define OVERRIDE_VIRTUAL_FUNCTION_TEMPLATE(BaseClass, functionName)
Save the old vtable to be accessible by CALL_BASE_FUNCTION_TEMPLATE and overwrite it with the new imp...
#define CALL_BASE_FUNCTION_TEMPLATE(BaseClass, functionName, templateArgument,...)
Execute the virtual function template call to the base implementation of the function.
#define CALL_VIRTUAL_FUNCTION_TEMPLATE(functionName, templateArgument,...)
Execute the virtual function template call using the vtable defined with the DEFINE_VIRTUAL_FUNCTION_...
#define FILL_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(functionName)
Fill the vtable of a virtual function template defined with DEFINE_VIRTUAL_FUNCTION_TEMPLATE.
std::string getValue(T &base)
DEFINE_VIRTUAL_FUNCTION_TEMPLATE_VTABLE(getValue_impl, std::string(T &))
DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE(Base, getValue_impl, std::string(T &))
DEFINE_VIRTUAL_FUNCTION_OVERRIDE_VTABLE(Derived1, getValue_impl, std::string(T &))
boost::fusion::map< boost::fusion::pair< int8_t, int8_t >, boost::fusion::pair< uint8_t, uint8_t >, boost::fusion::pair< int16_t, int16_t >, boost::fusion::pair< uint16_t, uint16_t >, boost::fusion::pair< int32_t, int32_t >, boost::fusion::pair< uint32_t, uint32_t >, boost::fusion::pair< int64_t, int64_t >, boost::fusion::pair< uint64_t, uint64_t >, boost::fusion::pair< float, float >, boost::fusion::pair< double, double >, boost::fusion::pair< std::string, std::string >, boost::fusion::pair< Boolean, Boolean >, boost::fusion::pair< Void, Void > > userTypeMap
Map of UserType to value of the UserType.
void for_each(MAPTYPE &map, const LAMBDATYPE &lambda)
Variant of boost::fusion::for_each() to iterate a boost::fusion::map, which accepts a lambda instead ...
BOOST_AUTO_TEST_CASE(testBaseClass)