]>
Commit | Line | Data |
---|---|---|
1 | extern "C++" { | |
2 | namespace std { | |
3 | class exception {}; | |
4 | } | |
5 | } | |
6 | namespace __gnu_cxx { | |
7 | template<typename _Tp> class new_allocator { | |
8 | public: | |
9 | typedef _Tp& reference; | |
10 | template<typename _Tp1> struct rebind { | |
11 | typedef new_allocator<_Tp1> other; | |
12 | }; | |
13 | }; | |
14 | } | |
15 | namespace std { | |
16 | template<class _CharT> struct char_traits; | |
17 | template<typename _StateT> class fpos {}; | |
18 | template<typename _Iterator, typename _Container> class __normal_iterator {}; | |
19 | template<typename _Tp> inline const _Tp& min(const _Tp& __a, const _Tp& __b) {} | |
20 | ||
21 | template<typename _Tp> class allocator: public __gnu_cxx::new_allocator<_Tp> {}; | |
22 | template<typename _Tp, typename _Alloc> struct _Vector_base { | |
23 | typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type; | |
24 | }; | |
25 | template<typename _Tp, typename _Alloc = std::allocator<_Tp> > class vector : protected _Vector_base<_Tp, _Alloc> { | |
26 | typedef _Vector_base<_Tp, _Alloc> _Base; | |
27 | typedef typename _Base::_Tp_alloc_type _Tp_alloc_type; | |
28 | public: typedef _Tp value_type; | |
29 | typedef typename _Tp_alloc_type::reference reference; | |
30 | long unsigned int size() const {} | |
31 | reference operator[](long unsigned int __n) {} | |
32 | }; | |
33 | template<typename _CharT, typename _Traits, typename _Alloc> class basic_string {}; | |
34 | class locale {}; | |
35 | enum _Ios_Fmtflags { _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 }; | |
36 | enum _Ios_Openmode { _S_beg = 0, _S_cur = 1, _S_end = 2, _S_ios_seekdir_end = 1L << 16 }; | |
37 | class ios_base { | |
38 | public: class failure : public exception {}; | |
39 | typedef _Ios_Fmtflags fmtflags; | |
40 | static const fmtflags internal = _S_internal; | |
41 | inline fmtflags flags() const {} | |
42 | inline long int width() const {} | |
43 | }; | |
44 | template<typename _CharT, typename _Traits> class basic_streambuf {}; | |
45 | template<typename _CharT, typename _Traits> class basic_ios : public ios_base {}; | |
46 | template<typename _CharT, typename _Traits> class basic_ostream : virtual public basic_ios<_CharT, _Traits> { | |
47 | public: typedef _CharT char_type; | |
48 | typedef basic_streambuf<_CharT, _Traits> __streambuf_type; | |
49 | explicit basic_ostream(__streambuf_type* __sb) {} | |
50 | }; | |
51 | } | |
52 | extern "C++" { | |
53 | namespace __cxxabiv1 { | |
54 | class type_info { | |
55 | bool operator==(const type_info& __arg) const {} | |
56 | }; | |
57 | } | |
58 | } | |
59 | namespace boost { | |
60 | template <class Ch, class Tr = ::std:: char_traits<Ch>, class Alloc = std::allocator<Ch> > class basic_format; | |
61 | typedef basic_format<char > format; | |
62 | namespace io { | |
63 | enum format_error_bits { 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 }; | |
64 | namespace detail { | |
65 | typedef ::std:: locale locale_t; | |
66 | template<class Ch, class Tr, class Alloc, class T> basic_format<Ch, Tr, Alloc>& feed (basic_format<Ch,Tr, Alloc>& self, T x); | |
67 | } | |
68 | } | |
69 | } | |
70 | namespace mpl_ { | |
71 | template< typename T, T N > struct integral_c { | |
72 | static const T value = N; | |
73 | }; | |
74 | struct na {}; | |
75 | } | |
76 | namespace boost { | |
77 | namespace mpl { | |
78 | using namespace mpl_; | |
79 | } | |
80 | template <class T, T val> struct integral_constant : public mpl::integral_c<T, val> { | |
81 | typedef integral_constant<bool,false> type; | |
82 | }; | |
83 | } | |
84 | namespace boost { | |
85 | namespace mpl { | |
86 | template< bool C , typename T1 , typename T2 > struct if_c { | |
87 | typedef T2 type; | |
88 | }; | |
89 | template< typename T1 = na , typename T2 = na , typename T3 = na > struct if_ { | |
90 | private: typedef if_c< static_cast<bool>(T1::value) , T2 , T3 > almost_type_; | |
91 | public: typedef typename almost_type_::type type; | |
92 | }; | |
93 | } | |
94 | template< typename T > struct is_reference : ::boost::integral_constant<bool,false> {}; | |
95 | namespace detail { | |
96 | template <bool found, long unsigned int target, class TestType> struct lower_alignment_helper { | |
97 | }; | |
98 | } | |
99 | namespace optional_detail { | |
100 | template <class T> class aligned_storage {}; | |
101 | template<class T> struct types_when_isnt_ref { | |
102 | typedef T * pointer_type; | |
103 | }; | |
104 | template<class T> struct types_when_is_ref {}; | |
105 | struct optional_tag {}; | |
106 | template<class T> class optional_base : public optional_tag { | |
107 | typedef types_when_isnt_ref<T> types_when_not_ref; | |
108 | typedef types_when_is_ref<T> types_when_ref; | |
109 | typedef typename is_reference<T>::type is_reference_predicate; | |
110 | typedef typename mpl::if_<is_reference_predicate,types_when_ref,types_when_not_ref>::type types; | |
111 | typedef typename types::pointer_type pointer_type; | |
112 | }; | |
113 | } | |
114 | template<class T> class optional : public optional_detail::optional_base<T> { | |
115 | typedef optional_detail::optional_base<T> base; | |
116 | public : typedef optional<T> this_type; | |
117 | typedef typename base::pointer_type pointer_type; | |
118 | }; | |
119 | template<class T> inline typename optional<T>::pointer_type get_pointer ( optional<T>& opt ) {} | |
120 | template < typename MemberType, int UniqueID = 0 > class base_from_member { | |
121 | protected: MemberType member; | |
122 | template < typename T0 , typename T1 > explicit base_from_member( T0 x0 , T1 x1 ) : member( x0 , x1 ) {} | |
123 | }; | |
124 | namespace detail { | |
125 | inline int atomic_decrement( int * pw ) { | |
126 | return __sync_fetch_and_add( pw, -1 ); | |
127 | } | |
128 | class sp_counted_base { | |
129 | int use_count_; | |
130 | int weak_count_; | |
131 | public: sp_counted_base(): use_count_( 1 ), weak_count_( 1 ) { | |
132 | } | |
133 | void release() { | |
134 | if( atomic_decrement( &use_count_ ) == 1 ) { | |
135 | } | |
136 | } | |
137 | }; | |
138 | class shared_count { | |
139 | private: sp_counted_base * pi_; | |
140 | public: shared_count(): pi_(0) { | |
141 | } | |
142 | template<class P, class D> shared_count(P p, D d): pi_(0) { | |
143 | if( pi_ != 0 ) pi_->release(); | |
144 | } | |
145 | shared_count & operator= (shared_count const & r) { | |
146 | } | |
147 | }; | |
148 | } | |
149 | template<class T> class shared_ptr { | |
150 | public: typedef T element_type; | |
151 | template<class Y, class D> shared_ptr(Y * p, D d): px(p), pn(p, d) { | |
152 | } | |
153 | T * px; | |
154 | boost::detail::shared_count pn; | |
155 | }; | |
156 | namespace io { | |
157 | template<class Ch, class Tr, class Alloc> class basic_altstringbuf : public ::std::basic_streambuf<Ch, Tr> { | |
158 | }; | |
159 | 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> { | |
160 | class No_Op { | |
161 | }; | |
162 | typedef ::std::basic_ostream<Ch, Tr> stream_t; | |
163 | typedef boost::base_from_member<boost::shared_ptr< basic_altstringbuf<Ch,Tr, Alloc> > > pbase_type; | |
164 | typedef basic_altstringbuf<Ch, Tr, Alloc> stringbuf_t; | |
165 | public: typedef Alloc allocator_type; | |
166 | basic_oaltstringstream() : pbase_type(new stringbuf_t), stream_t(rdbuf()) { | |
167 | } | |
168 | basic_oaltstringstream(stringbuf_t * buf) : pbase_type(buf, No_Op() ), stream_t(rdbuf()) { | |
169 | } | |
170 | stringbuf_t * rdbuf() const { | |
171 | } | |
172 | }; | |
173 | namespace detail { | |
174 | template<class Ch, class Tr> struct stream_format_state { | |
175 | }; | |
176 | template<class Ch, class Tr, class Alloc> struct format_item { | |
177 | typedef ::std::basic_string<Ch, Tr, Alloc> string_type; | |
178 | static long int max_streamsize() { | |
179 | } | |
180 | int argN_; | |
181 | string_type res_; | |
182 | }; | |
183 | } | |
184 | } | |
185 | template<class Ch, class Tr, class Alloc> class basic_format { | |
186 | public: typedef Ch CharT; | |
187 | typedef std::basic_string<Ch, Tr, Alloc> string_type; | |
188 | typedef io::detail::format_item<Ch, Tr, Alloc> format_item_t; | |
189 | typedef io::basic_altstringbuf<Ch, Tr, Alloc> internal_streambuf_t; | |
190 | explicit basic_format(const Ch* str=__null); | |
191 | template<class T> basic_format& operator%(const T& x) { | |
192 | return io::detail::feed<CharT, Tr, Alloc, const T&>(*this,x); | |
193 | } | |
194 | std::vector<format_item_t> items_; | |
195 | int cur_arg_; | |
196 | internal_streambuf_t buf_; | |
197 | boost::optional<io::detail::locale_t> loc_; | |
198 | }; | |
199 | namespace io { | |
200 | class format_error : public std::exception { | |
201 | }; | |
202 | namespace detail { | |
203 | 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) { | |
204 | basic_oaltstringstream<Ch, Tr, Alloc> oss( &buf); | |
205 | const std::ios_base::fmtflags fl=oss.flags(); | |
206 | const bool internal = (fl & std::ios_base::internal) != 0; | |
207 | const long int w = oss.width(); | |
208 | const bool two_stepped_padding= internal && (w!=0); | |
209 | if(! two_stepped_padding) { | |
210 | } | |
211 | } | |
212 | template< class Ch, class Tr, class Alloc, class T> void distribute (basic_format<Ch,Tr, Alloc>& self, T x) { | |
213 | for(unsigned long i=0; | |
214 | i < self.items_.size(); | |
215 | ++i) { | |
216 | if(self.items_[i].argN_ == self.cur_arg_) { | |
217 | put<Ch, Tr, Alloc, T> (x, self.items_[i], self.items_[i].res_, self.buf_, boost::get_pointer(self.loc_) ); | |
218 | } | |
219 | } | |
220 | } | |
221 | template<class Ch, class Tr, class Alloc, class T> basic_format<Ch, Tr, Alloc>& feed (basic_format<Ch,Tr, Alloc>& self, T x) { | |
222 | distribute<Ch, Tr, Alloc, T> (self, x); | |
223 | } | |
224 | } | |
225 | } | |
226 | } | |
227 | int main() { | |
228 | boost::format f("%d\n"); | |
229 | f %-123; | |
230 | } |