1 /*! 2 * \file include/TFEL/FSAlgorithm/fill.hxx 3 * \brief This file implements the fill class. 4 * \author Thomas Helfer 5 * \date 30 Jun 2006 6 * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights 7 * reserved. 8 * This project is publicly released under either the GNU GPL Licence 9 * or the CECILL-A licence. A copy of thoses licences are delivered 10 * with the sources of TFEL. CEA or EDF may also distribute this 11 * project under specific licensing conditions. 12 */ 13 14 #ifndef LIB_TFEL_FILL_HXX 15 #define LIB_TFEL_FILL_HXX 16 17 #include"TFEL/Config/TFELConfig.hxx" 18 19 namespace tfel{ 20 21 namespace fsalgo{ 22 23 /*! 24 * \class fill 25 * \brief Fill assigns the value value to every element in the range [first, last). That is, for every iterator i in [first, first+N), it performs the assignment *i = value. 26 * \param N number of element to be filled. 27 * 28 * This documentation is mostly inspired from: 29 * http://www.sgi.com/tech/stl/fill.html 30 * 31 * \author Thomas Helfer 32 * \date 30 Jun 2006 33 */ 34 template<unsigned int N> 35 struct fill 36 { 37 /* 38 * \param OutputIterator iterator to the elements being filled. 39 * \param T type of the value. 40 * \return void 41 * 42 * \pre 43 * - ForwardIterator is a model of Forward Iterator. 44 * - ForwardIterator is mutable. 45 * - T is a model of Assignable. 46 * - T is convertible to Forward Iterator's value type. 47 */ 48 template<typename OutputIterator,typename T> 49 static TFEL_FSALGORITHM_INLINE exetfel::fsalgo::fill50 void exe(OutputIterator p, T q) 51 { 52 *p = q; 53 fill<N-1>::exe(++p,q); 54 } 55 }; 56 57 /*! 58 * \brief partial specialisation of struct fill to end recursion. 59 * 60 * \author Thomas Helfer 61 * \date 30 Jun 2006 62 */ 63 template<> 64 struct fill<0u> 65 { 66 /*! 67 * \return void 68 * \sa fill<N>::exe() for details 69 * 70 * \author Thomas Helfer 71 * \date 30 Jun 2006 72 */ 73 template<typename OutputIterator,typename T> 74 static TFEL_FSALGORITHM_INLINE exetfel::fsalgo::fill75 void exe(OutputIterator, T) 76 {} 77 }; 78 79 } // end of namespace fsalgo 80 81 } // end of namespace tfel 82 83 #endif /* LIB_TFEL_FILL_HXX */ 84 85