Optimization code for a debug function (c++11 with templates) [closed]

std::forward_list::max_size returns the maximum number of elements that the forward_list container can hold.

Your forward list implementation should be:

//Forward list
template<>
struct F22<true>{
    template<typename T>
    static void F23(const string& name, const T& a){
        std::size_t i = 0;
        for (const auto& e : a) {
            std::cout << name << "[" << i << "]: " << e << std::endl;
            ++i;
        }
    }
};

BTW, I propose this implementation for the debug function.

You may also be interested by pretty-print-c-stl-containers

Leave a Comment