Policy Based design

hi…

I have an algorithm which has two strategies that share many of the same data structures but also have their own. It seems a fit for policy based design. Something like (from wikipedia):

template <typename OutputPolicy, typename LanguagePolicy>
class HelloWorld : private OutputPolicy, private LanguagePolicy
{
    using OutputPolicy::print;
    using LanguagePolicy::message;
 
public:
    // Behaviour method
    void run() const
    {
        // Two policy methods
        print(message());
    }
};
 
class OutputPolicyWriteToCout
{
protected:
    template<typename MessageType>
    void print(MessageType const &message) const
    {
        std::cout << message << std::endl;
    }
};
 
class LanguagePolicyEnglish
{
protected:
    std::string message() const
    {
        return "Hello, World!";
    }
};
 
class LanguagePolicyGerman
{
protected:
    std::string message() const
    {
        return "Hallo Welt!";
    }
};

I can create this manually, but as I’m just getting into Visual Paradigm i was just wondering if there was some sort of library for common design patterns which might smooth out some of the :evil: details for c++ code generation.

Thanks!

Digging in a bit it looks like the “Working with Template Design Pattern” tutorial is useful. Will give it a shot and see how it goes.