home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / Rw / valimp.cc < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  3.3 KB  |  98 lines

  1. #ifndef __VALIMP_CC
  2. #define __VALIMP_CC
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * valimp.cc - Declarations for the Standard Library valarray
  8.  *
  9.  ***************************************************************************
  10.  *
  11.  * Copyright (c) 1994-1999 Rogue Wave Software, Inc.  All Rights Reserved.
  12.  *
  13.  * This computer software is owned by Rogue Wave Software, Inc. and is
  14.  * protected by U.S. copyright laws and other laws and by international
  15.  * treaties.  This computer software is furnished by Rogue Wave Software,
  16.  * Inc. pursuant to a written license agreement and may be used, copied,
  17.  * transmitted, and stored only in accordance with the terms of such
  18.  * license and with the inclusion of the above copyright notice.  This
  19.  * computer software or any other copies thereof may not be provided or
  20.  * otherwise made available to any other person.
  21.  *
  22.  * U.S. Government Restricted Rights.  This computer software is provided
  23.  * with Restricted Rights.  Use, duplication, or disclosure by the
  24.  * Government is subject to restrictions as set forth in subparagraph (c)
  25.  * (1) (ii) of The Rights in Technical Data and Computer Software clause
  26.  * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
  27.  * Commercial Computer Software รป Restricted Rights at 48 CFR 52.227-19,
  28.  * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
  29.  * Flatiron Parkway, Boulder, Colorado 80301 USA.
  30.  *
  31.  **************************************************************************/
  32.  
  33. #ifdef __BORLANDC__
  34. #pragma option -w-ccc
  35. #pragma option -w-rch
  36. #endif
  37.  
  38. #ifndef _RWSTD_NO_NAMESPACE
  39. namespace __rwstd {
  40. #endif
  41. /*****************************************************************
  42.  *                                                                *
  43.  *                _RW_array<T> MEMBER FUNCTIONS                    *
  44.  *                                                                *
  45.  ******************************************************************/
  46.  
  47.   template <class T>
  48.   void 
  49.   _RW_array<T>::_initialize_with_value(const T& value, size_t size)
  50.   {
  51.     if ( _RW_length < size )
  52.       _RW_resize_without_copy(size);
  53.  
  54.     for(size_t cpt=0; cpt<size; cpt++)
  55.       _RW_storage[cpt] = value;
  56.   }
  57.  
  58.   template <class T>
  59.   void 
  60.   _RW_array<T>::_initialize_with_array(const T* pointer, size_t size)
  61.   {
  62.     if ( _RW_length < size )
  63.       _RW_resize_without_copy(size);
  64.  
  65.     if ( valarray_traits_optimize<T>::optimize_copy() )
  66. #if !defined(_RWSTD_NO_NEW_HEADER) && !defined(_RWSTD_NO_NAMESPACE)
  67.       std::memcpy((void *)_RW_storage,(void*)pointer,size*sizeof(T));
  68. #else
  69.       memcpy((void *)_RW_storage,(void*)pointer,size*sizeof(T));
  70. #endif
  71.     else
  72.     {
  73.       for(size_t cpt=0; cpt<size; cpt++)
  74.         _RW_storage[cpt] = pointer[cpt];
  75.     }
  76.   }
  77.  
  78.   template <class T>
  79.   void 
  80.   _RW_array<T>::_copy_memory_array(const _RW_array<T>& array)
  81.   {
  82.     if ( array._get_length() != _RW_length )
  83.       _RW_resize_without_copy(array._get_length());
  84.  
  85.     if ( valarray_traits_optimize<T>::optimize_copy() )
  86.       array._RW_copy(_RW_storage);
  87.     else
  88.     {
  89.       for(size_t tmp=0; tmp<_RW_length; tmp++)
  90.         _RW_storage[tmp]= array[tmp];
  91.     }
  92.   }
  93. #ifndef _RWSTD_NO_NAMESPACE
  94. }
  95. #endif
  96. #pragma option pop
  97. #endif /* __VALIMP_CC */
  98.