I want to send std::array as a parameter to my virtual function
class Handler:
    {
    public:
        template <std::size_t N>
        virtual void handle(const std::array<char, N>& msg, std::vector<boost::asio::const_buffer>& buffers) = 0;
    };
but gcc said templates may not be 'virtual'. So how i pass a std::array to my function?
A member function template may not be virtual. See this question.
However, you can make a virtual member function takes a std::array of specific size by moving the N out to the Handler:
template <size_t N>
class Handler:
{
public:
    virtual void handle(const std::array<char, N>& msg,
        std::vector<boost::asio::const_buffer>& buffers) = 0;
};
Or simply passing a vector<char>, which given the context, could make more sense:
class Handler:
{
public:
    virtual void handle(const std::vector<char>& msg,
        std::vector<boost::asio::const_buffer>& buffers) = 0;
};
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With