[EMAIL PROTECTED] writes:

> Is a swap function part of "standard c++"? 

Yes (as part of STL): section 25.2.2 Swap:

   template<class T> void swap(T& a, T& b); 

   Requires: Type T is Assignable (23.1). 
   Effects: Exchanges values stored in two locations.

> If not, where can I read

Info on STL swap:
http://www.sgi.com/tech/stl/swap.html

> about the implementation of this particular swap in this particular
> compiler?

I don't know where you can read about this implementation, but you
can read the implementation itself (there isn't much to it :)

// gcc-3.4.3/include/c++/3.4.3/bits/stl_algobase.h

  /**
   *  @brief Swaps two values.
   *  @param  a  A thing of arbitrary type.
   *  @param  b  Another thing of arbitrary type.
   *  @return   Nothing.
   *
   *  This is the simple classic generic implementation.  It will work on
   *  any type which has a copy constructor and an assignment operator.
  */
  template<typename _Tp>
    inline void
    swap(_Tp& __a, _Tp& __b)
    {
      // concept requirements
      __glibcxx_function_requires(_SGIAssignableConcept<_Tp>)

      const _Tp __tmp = __a;
      __a = __b;
      __b = __tmp;
    }


Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
_______________________________________________
Help-gplusplus mailing list
Help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to