00001
00002 #ifndef _INSTIGATE_STL_INTERNAL_HEADER_IN_ALGORITHM
00003 #error This is an internal header file used to implement Instigate STL.\
00004 It should never be included directly by a program.
00005 #endif
00006
00007 #ifndef INSTIGATE_STL_FILL_N_HPP
00008 #define INSTIGATE_STL_FILL_N_HPP
00009
00058
00059 #include "concept.hpp"
00060 #include "_basis.hpp"
00061
00062
00063
00064
00065
00066
00067 namespace instigate {
00068 namespace stl {
00069 template <typename O, typename S, typename T>
00070 O fill_n(O b, S n, const T& v);
00071 template <typename S>
00072 inline char* fill_n(char* b, S n, const char& c);
00073 }
00074 }
00075
00108 template <typename O, typename S, typename T>
00109 O instigate::stl::fill_n(O b, S n, const T& v)
00110 {
00111 typedef typename instigate::stl::writable_iterator::interface<O>::
00112 value_type value_type;
00113 CHECK(instigate::stl::incrementable_iterator::requirements<O>);
00114 CHECK(instigate::stl::writable_iterator::requirements<O>);
00115 CHECK(instigate::generic::assignable::requirements<T>);
00116 CHECK_CONVERTIBILITY(value_type, T);
00117 for (; 0 < n; --n, increment(b)) {
00118 dereference_assign(b, v);
00119 }
00120 return b;
00121 }
00122
00144 template <typename S>
00145 inline char* instigate::stl::fill_n(char* b, S n, const char& c)
00146 {
00147 assert(0 != b);
00148 instigate::stl::fill(b, b + n, c);
00149 return b + n;
00150 }
00151
00152
00153
00154 #endif // INSTIGATE_STL_FILL_N_HPP
00155