Solve boost.thread compilation error with Metrowerks compiler

I am trying to use boost.thread with metrowerks codewarrior 5.5.3; in the thread.hpp header, I get an error that it overrides thread :: thread_data:

class BOOST_THREAD_DECL thread
{
private:
    ...        
    template<typename F>
    struct thread_data:
        detail::thread_data_base
    {
        F f;

        thread_data(F f_):
            f(f_)
        {}
        thread_data(detail::thread_move_t<F> f_):
            f(f_)
        {}

        void run()
        {
            f();
        }
    };
    ...
 };

template<typename F>
struct thread::thread_data<boost::reference_wrapper<F> >:
    detail::thread_data_base
{
    F& f;

    thread_data(boost::reference_wrapper<F> f_):
        f(f_)
    {}

    void run()
    {
        f();
    }
};

I see that, in fact, thread :: thread_data seems to be declared twice. What C ++ function is used there? How can I overcome this compiler flaw?

+3
source share
1 answer

The second instance is a partial specialization of the template class, it is valid C ++ and should not lead to an override error.

metrowerks , , , . , ... (1)

, , ... ( , / metrowerks )

typedef boost::function< void () > MyThreadFunction; // or whatever you need

template <>
struct thread::thread_data<boost::reference_wrapper< MyThreadFunction > >:
    detail::thread_data_base
{
    ....
};

(1) , , , .

+1

Source: https://habr.com/ru/post/1712282/


All Articles