Ticket #2056: array_support_for_sandbox_swap.patch

File array_support_for_sandbox_swap.patch, 1.1 KB (added by niels_dekker, 14 years ago)
  • swap.hpp

     
    1 // Copyright (C) 2007 Steven Watanabe, Joseph Gauterin
     1// Copyright (C) 2007, 2008 Steven Watanabe, Joseph Gauterin
    22//
    33// Distributed under the Boost Software License, Version 1.0. (See
    44// accompanying file LICENSE_1_0.txt or copy at
    55// http://www.boost.org/LICENSE_1_0.txt)
    66// For more information, see http://www.boost.org
     7//
     8// Update:
     9// 29 June 2008 (Added support for built-in arrays.) Niels Dekker 
    710
    811
    912#ifndef BOOST_UTILITY_SWAP_HPP
    1013#define BOOST_UTILITY_SWAP_HPP
    1114
    1215#include <algorithm> //for std::swap
     16#include <cstddef> //for std::size_t
    1317
    1418namespace boost_swap_impl
    1519{
     
    1923    using std::swap;//use std::swap if argument dependent lookup fails
    2024    swap(left,right);
    2125  }
     26
     27  template<class T, std::size_t N>
     28  void swap_impl(T (& left)[N], T (& right)[N])
     29  {
     30    for (std::size_t i = 0; i < N; ++i)
     31    {
     32      ::boost_swap_impl::swap_impl(left[i], right[i]);
     33    }
     34  }
    2235}
    2336
    2437namespace boost