// Copyright David Abrahams 2008. Distributed under the Boost
// Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PARALLEL_DETAIL_UNTRACKED_DWA20081110_HPP
# define BOOST_PARALLEL_DETAIL_UNTRACKED_DWA20081110_HPP

# include <boost/serialization/wrapper.hpp>
# include <boost/serialization/split_member.hpp>

namespace boost { namespace parallel { namespace detail { 

template <class T>
struct untracked_wrapper
    : boost::serialization::wrapper_traits<
          untracked_wrapper<T>
        , boost::serialization::object_serializable
      >
{
    untracked_wrapper(T& x) : x(x) {}

    template<class Archivex>
    void save(
        Archivex & ar, 
        const unsigned int /* file_version */
    ) const
    {
        // CodeWarrior 8.x can't seem to resolve the << op for a rhs of "const T *"
        ar.operator<<(x);
    }
    
    template<class Archivex>
    void load(
        Archivex & ar, 
        const unsigned int /* file_version */
    )
    {
        // CodeWarrior 8.x can't seem to resolve the >> op for a rhs of "const T *"
        ar.operator>>(x);
    }
    BOOST_SERIALIZATION_SPLIT_MEMBER()
    
    T& x;
};

template <class T>
inline untracked_wrapper<T const>
untracked(T const& x)
{
    return untracked_wrapper<T const>(x);
}

template <class T>
inline untracked_wrapper<T>
untracked(T& x)
{
    return untracked_wrapper<T>(x);
}

template <class Archivex, class T>
Archivex& operator<<(Archivex& ar, untracked_wrapper<T> w)
{
    return ar.operator<<(w);
}
                                      
template <class Archivex, class T>
Archivex& operator>>(Archivex& ar, untracked_wrapper<T> w)
{
    return ar.operator>>(w);
}
                                      

}}} // namespace boost::parallel::detail

#endif // BOOST_PARALLEL_DETAIL_UNTRACKED_DWA20081110_HPP

