id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 6160,support for (istream >> array < char >),giecrilj@…,Marshall Clow,"1. `array < T >` is a replacement for `T []` 1. the standard library provides the syntax `(istream >> char [])` and `(ostream << char const [])` 1. Currently, `(istream >> array < char >)` does not mean anything 1. this functionality cannot be simulated even with `std:: copy_n < istreambuf_iterator >` without manual termination and much verbosity == My implementation == {{{ #!cpp #include /* for ::boost:: array */ #include #if +BOOST_VERSION <= 0313720 #include /* for ::std:: setw */ namespace boost { /* helper classes to prevent ambiguity in matching array < char > */ namespace detail_ { /* normally, other char for every character type is char */ template < class P_C > class other_char { public: typedef char type; }; /* but other_char is undefined for char */ template <> class other_char < char > {}; /* class same_stream fails for istream */ template < class P_S, class P_C = typename other_char < typename P_S:: char_type >:: type > class same_stream { public: typedef P_S stream; }; } /* template input */ template < class P_C, class P_T, ::std:: size_t P_N > static inline ::std:: basic_istream < P_C, P_T > &operator >> (::std:: basic_istream < P_C, P_T > &p_s, ::boost:: array < P_C, P_N > &p_a) { return p_s >> ::std:: setw (p_a. static_size) >> p_a. data (); } /* character input, disabled for type char to avoid ambiguity */ template < class P_C, class P_T, ::std:: size_t P_N > static inline typename detail_:: same_stream < ::std:: basic_istream < P_C, P_T > >:: stream &operator >> (::std:: basic_istream < P_C, P_T > &p_s, ::boost:: array < char, P_N > &p_a) { return p_s >> ::std:: setw (p_a. static_size) >> p_a. data (); } /* template output */ template < class P_C, class P_T, ::std:: size_t P_N > static inline ::std:: basic_ostream < P_C, P_T > &operator << (::std:: basic_ostream < P_C, P_T > &p_s, ::boost:: array < P_C, P_N > const &p_a) { return p_s << p_a. begin (); } /* character output, disabled for type char */ template < class P_C, class P_T, ::std:: size_t P_N > static inline typename detail_:: same_stream < ::std:: basic_ostream < P_C, P_T > >:: stream &operator << (::std:: basic_ostream < P_C, P_T > &p_s, ::boost:: array < char, P_N > const &p_a) { return p_s << p_a. begin (); }} #endif /* BOOST_VERSION */ #include /* for EXIT_SUCCESS */ #include /* for BUFSIZ */ #include /* for ::std:: cin */ int main () { // char (&x) [+BOOST_VERSION] = 0; #ifdef ARRAY_IN_NATIVE /* native code */ char t [+BUFSIZ]; return ::std:: cin >> ::std:: setw (+BUFSIZ) >> t && ::std:: cout << t << '\n'? +EXIT_SUCCESS: +EXIT_FAILURE; #else /* ARRAY_IN_NATIVE */ /* equivalent Boost code */ ::boost:: array < char, +BUFSIZ > t; /* check that character input compiles for wchar_t */ (void) sizeof (std:: wcin >> t); return ::std:: cin >> t && ::std:: cout << t << '\n'? +EXIT_SUCCESS: +EXIT_FAILURE; #endif /* ARRAY_IN_NATIVE */ } }}} ",Feature Requests,assigned,To Be Determined,array,Boost 1.44.0,Cosmetic,,,