1 typedef long int ptrdiff_t;
2 typedef long unsigned int size_t;
10 template<class _CharT> struct char_traits;
14 typedef ptrdiff_t streamsize;
15 template<typename _StateT> class fpos {
17 template<typename _Iterator, typename _Container> class __normal_iterator {
19 template<typename _Tp> inline const _Tp& min(const _Tp& __a, const _Tp& __b) {
29 template<typename _Tp> class new_allocator {
30 public: typedef size_t size_type;
31 typedef _Tp& reference;
32 template<typename _Tp1> struct rebind {
33 typedef new_allocator<_Tp1> other;
38 template<typename _Tp> class allocator: public __gnu_cxx::new_allocator<_Tp> {
40 template<typename _Tp, typename _Alloc> struct _Vector_base {
41 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
43 template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class vector : protected _Vector_base<_Tp, _Alloc> {
44 typedef _Vector_base<_Tp, _Alloc> _Base;
45 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
46 public: typedef _Tp value_type;
47 typedef typename _Tp_alloc_type::reference reference;
48 typedef size_t size_type;
49 size_type size() const {
51 reference operator[](size_type __n) {
56 template<typename _CharT, typename _Traits, typename _Alloc> class basic_string {
63 _S_boolalpha = 1L << 0, _S_dec = 1L << 1, _S_fixed = 1L << 2, _S_hex = 1L << 3, _S_internal = 1L << 4, _S_left = 1L << 5, _S_oct = 1L << 6, _S_right = 1L << 7, _S_scientific = 1L << 8, _S_showbase = 1L << 9, _S_showpoint = 1L << 10, _S_showpos = 1L << 11, _S_skipws = 1L << 12, _S_unitbuf = 1L << 13, _S_uppercase = 1L << 14, _S_adjustfield = _S_left | _S_right | _S_internal, _S_basefield = _S_dec | _S_oct | _S_hex, _S_floatfield = _S_scientific | _S_fixed, _S_ios_fmtflags_end = 1L << 16 };
65 _S_beg = 0, _S_cur = 1, _S_end = 2, _S_ios_seekdir_end = 1L << 16 };
67 public: class failure : public exception {
69 typedef _Ios_Fmtflags fmtflags;
70 static const fmtflags internal = _S_internal;
71 inline fmtflags flags() const {
73 inline streamsize width() const {
76 template<typename _CharT, typename _Traits> class basic_streambuf {
80 namespace __cxxabiv1 {
82 bool operator==(const type_info& __arg) const {
90 typedef ::std:: locale locale_t;
95 template<typename _CharT, typename _Traits> class basic_ios : public ios_base {
97 template<typename _CharT, typename _Traits> class basic_ostream : virtual public basic_ios<_CharT, _Traits> {
98 public: typedef _CharT char_type;
99 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
100 explicit basic_ostream(__streambuf_type* __sb) {
107 template <class Ch, class Tr = ::std:: char_traits<Ch>, class Alloc = std::allocator<Ch> > class basic_format;
108 typedef basic_format<char > format;
110 enum format_error_bits {
111 bad_format_string_bit = 1, too_few_args_bit = 2, too_many_args_bit = 4, out_of_range_bit = 8, all_error_bits = 255, no_error_bits=0 };
113 template<class Ch, class Tr, class Alloc, class T> basic_format<Ch, Tr, Alloc>& feed (basic_format<Ch,Tr, Alloc>& self, T x);
121 using namespace mpl_;
125 template< typename T, T N > struct integral_c {
126 static const T value = N;
130 template <class T, T val> struct integral_constant : public mpl::integral_c<T, val> {
131 typedef integral_constant<bool,false> type;
142 template< bool C , typename T1 , typename T2 > struct if_c {
145 template< typename T1 = na , typename T2 = na , typename T3 = na > struct if_ {
146 private: typedef if_c< static_cast<bool>(T1::value) , T2 , T3 > almost_type_;
147 public: typedef typename almost_type_::type type;
150 template< typename T > struct is_reference : ::boost::integral_constant<bool,false> {
153 template <bool found, std::size_t target, class TestType> struct lower_alignment_helper {
156 namespace optional_detail {
157 template <class T> class aligned_storage {
160 template<class T> struct types_when_isnt_ref {
161 typedef T * pointer_type ;
164 template<class T> struct types_when_is_ref {
167 struct optional_tag {
170 template<class T> class optional_base : public optional_tag {
171 typedef types_when_isnt_ref<T> types_when_not_ref ;
172 typedef types_when_is_ref<T> types_when_ref ;
173 typedef typename is_reference<T>::type is_reference_predicate ;
174 typedef typename mpl::if_<is_reference_predicate,types_when_ref,types_when_not_ref>::type types ;
175 typedef typename types::pointer_type pointer_type ;
179 template<class T> class optional : public optional_detail::optional_base<T> {
180 typedef optional_detail::optional_base<T> base ;
181 public : typedef optional<T> this_type ;
182 typedef typename base::pointer_type pointer_type ;
185 template<class T> inline typename optional<T>::pointer_type get_pointer ( optional<T>& opt ) {
187 template < typename MemberType, int UniqueID = 0 > class base_from_member {
188 protected: MemberType member;
189 template < typename T0 , typename T1 > explicit base_from_member( T0 x0 , T1 x1 ) : member( x0 , x1 ) {
193 typedef int sp_int32_t;
194 inline sp_int32_t atomic_decrement( sp_int32_t * pw ) {
195 return __sync_fetch_and_add( pw, -1 );
201 class sp_counted_base {
202 sp_int32_t use_count_;
203 sp_int32_t weak_count_;
204 public: sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) {
207 if( atomic_decrement( &use_count_ ) == 1 ) {
212 private: sp_counted_base * pi_;
213 public: shared_count(): pi_(0) {
215 template<class P, class D> shared_count(P p, D d): pi_(0) {
216 if( pi_ != 0 ) pi_->release();
218 shared_count & operator= (shared_count const & r) {
222 template<class T> class shared_ptr {
223 public: typedef T element_type;
224 template<class Y, class D> shared_ptr(Y * p, D d): px(p), pn(p, d) {
227 boost::detail::shared_count pn;
230 template<class Ch, class Tr, class Alloc> class basic_altstringbuf : public ::std::basic_streambuf<Ch, Tr> {
232 template <class Ch, class Tr, class Alloc> class basic_oaltstringstream : private base_from_member< shared_ptr< basic_altstringbuf< Ch, Tr, Alloc> > >, public ::std::basic_ostream<Ch, Tr> {
235 typedef ::std::basic_ostream<Ch, Tr> stream_t;
236 typedef boost::base_from_member<boost::shared_ptr< basic_altstringbuf<Ch,Tr, Alloc> > > pbase_type;
237 typedef basic_altstringbuf<Ch, Tr, Alloc> stringbuf_t;
238 public: typedef Alloc allocator_type;
239 basic_oaltstringstream() : pbase_type(new stringbuf_t), stream_t(rdbuf()) {
241 basic_oaltstringstream(stringbuf_t * buf) : pbase_type(buf, No_Op() ), stream_t(rdbuf()) {
243 stringbuf_t * rdbuf() const {
247 template<class Ch, class Tr> struct stream_format_state {
249 template<class Ch, class Tr, class Alloc> struct format_item {
250 typedef ::std::basic_string<Ch, Tr, Alloc> string_type;
251 static std::streamsize max_streamsize() {
258 template<class Ch, class Tr, class Alloc> class basic_format {
259 public: typedef Ch CharT;
260 typedef std::basic_string<Ch, Tr, Alloc> string_type;
261 typedef io::detail::format_item<Ch, Tr, Alloc> format_item_t;
262 typedef io::basic_altstringbuf<Ch, Tr, Alloc> internal_streambuf_t;
263 explicit basic_format(const Ch* str=__null);
264 template<class T> basic_format& operator%(const T& x) {
265 return io::detail::feed<CharT, Tr, Alloc, const T&>(*this,x);
267 std::vector<format_item_t> items_;
269 internal_streambuf_t buf_;
270 boost::optional<io::detail::locale_t> loc_;
273 class format_error : public std::exception {
276 template< class Ch, class Tr, class Alloc, class T> void put( T x, const format_item<Ch, Tr, Alloc>& specs, typename basic_format<Ch, Tr, Alloc>::string_type& res, typename basic_format<Ch, Tr, Alloc>::internal_streambuf_t & buf, io::detail::locale_t *loc_p = __null) {
277 basic_oaltstringstream<Ch, Tr, Alloc> oss( &buf);
278 const std::ios_base::fmtflags fl=oss.flags();
279 const bool internal = (fl & std::ios_base::internal) != 0;
280 const std::streamsize w = oss.width();
281 const bool two_stepped_padding= internal && (w!=0);
282 if(! two_stepped_padding) {
285 template< class Ch, class Tr, class Alloc, class T> void distribute (basic_format<Ch,Tr, Alloc>& self, T x) {
286 for(unsigned long i=0;
287 i < self.items_.size();
289 if(self.items_[i].argN_ == self.cur_arg_) {
290 put<Ch, Tr, Alloc, T> (x, self.items_[i], self.items_[i].res_, self.buf_, boost::get_pointer(self.loc_) );
294 template<class Ch, class Tr, class Alloc, class T> basic_format<Ch, Tr, Alloc>& feed (basic_format<Ch,Tr, Alloc>& self, T x) {
295 distribute<Ch, Tr, Alloc, T> (self, x);
301 boost::format f("%d\n");