medal893

No iostream

Oct 1st, 2019
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.51 KB | None | 0 0
  1. #include <bits/basic_ios.h>
  2.  
  3. namespace std _GLIBCXX_VISIBILITY(default)
  4. {
  5. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  6.     extern istream cin;     /// Linked to standard input      //SETTING CIN
  7.     extern ostream cout;        /// Linked to standard output //SETTING Cout
  8.     static ios_base::Init __ioinit;                           //IOS_BASE
  9.  
  10.   template<typename _CharT, typename _Traits>
  11.     class basic_ostream : virtual public basic_ios<_CharT, _Traits>
  12.     {
  13.     public:
  14.       // Types (inherited from basic_ios):
  15.       typedef _CharT                    char_type;
  16.       typedef typename _Traits::int_type        int_type;
  17.       typedef typename _Traits::pos_type        pos_type;
  18.       typedef typename _Traits::off_type        off_type;
  19.       typedef _Traits                   traits_type;
  20.  
  21.       // Non-standard Types:
  22.       typedef basic_streambuf<_CharT, _Traits>      __streambuf_type;
  23.       typedef basic_ios<_CharT, _Traits>        __ios_type;
  24.       typedef basic_ostream<_CharT, _Traits>        __ostream_type;
  25.       typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> >
  26.                                 __num_put_type;
  27.       typedef ctype<_CharT>                 __ctype_type;
  28.  
  29.       explicit
  30.       basic_ostream(__streambuf_type* __sb)
  31.       { this->init(__sb); }
  32.       class sentry;
  33.       friend class sentry;
  34.  
  35.  
  36.       __ostream_type&
  37.       operator<<(__ostream_type& (*__pf)(__ostream_type&))
  38.       {
  39.     return __pf(*this);
  40.       }
  41.  
  42.       __ostream_type&
  43.       operator<<(__ios_type& (*__pf)(__ios_type&))
  44.       {
  45.     __pf(*this);
  46.     return *this;
  47.       }
  48.  
  49.       __ostream_type&
  50.       operator<<(ios_base& (*__pf) (ios_base&))
  51.       {
  52.     __pf(*this);
  53.     return *this;
  54.       }
  55.       __ostream_type&
  56.       operator<<(long __n)
  57.       { return _M_insert(__n); }
  58.  
  59.       __ostream_type&
  60.       operator<<(unsigned long __n)
  61.       { return _M_insert(__n); }
  62.  
  63.       __ostream_type&
  64.       operator<<(bool __n)
  65.       { return _M_insert(__n); }
  66.  
  67.       __ostream_type&
  68.       operator<<(short __n);
  69.  
  70.       __ostream_type&
  71.       operator<<(unsigned short __n)
  72.       {
  73.     return _M_insert(static_cast<unsigned long>(__n));
  74.       }
  75.  
  76.       __ostream_type&
  77.       operator<<(int __n);
  78.  
  79.       __ostream_type&
  80.       operator<<(unsigned int __n)
  81.       {
  82.     return _M_insert(static_cast<unsigned long>(__n));
  83.       }
  84.  
  85.       __ostream_type&
  86.       operator<<(long long __n)
  87.       { return _M_insert(__n); }
  88.  
  89.       __ostream_type&
  90.       operator<<(unsigned long long __n)
  91.       { return _M_insert(__n); }
  92.  
  93.       __ostream_type&
  94.       operator<<(double __f)
  95.       { return _M_insert(__f); }
  96.  
  97.       __ostream_type&
  98.       operator<<(float __f)
  99.       {
  100.     // _GLIBCXX_RESOLVE_LIB_DEFECTS
  101.     // 117. basic_ostream uses nonexistent num_put member functions.
  102.     return _M_insert(static_cast<double>(__f));
  103.       }
  104.  
  105.       __ostream_type&
  106.       operator<<(long double __f)
  107.       { return _M_insert(__f); }
  108.  
  109.       __ostream_type&
  110.       operator<<(const void* __p)
  111.       { return _M_insert(__p); }
  112.  
  113.  
  114.       __ostream_type&
  115.       operator<<(__streambuf_type* __sb);
  116.  
  117.       __ostream_type&
  118.       put(char_type __c);
  119.  
  120.  
  121.       void
  122.       _M_write(const char_type* __s, streamsize __n)
  123.       {
  124.     const streamsize __put = this->rdbuf()->sputn(__s, __n);
  125.     if (__put != __n)
  126.       this->setstate(ios_base::badbit);
  127.       }
  128.  
  129.       __ostream_type&
  130.       write(const char_type* __s, streamsize __n);
  131.      
  132.       __ostream_type&
  133.       flush();
  134.  
  135.  
  136.       pos_type
  137.       tellp();
  138.  
  139.  
  140.       __ostream_type&
  141.       seekp(pos_type);
  142.  
  143.        __ostream_type&
  144.       seekp(off_type, ios_base::seekdir);
  145.  
  146.     protected:
  147.       basic_ostream()
  148.       { this->init(0); }
  149.  
  150.       template<typename _ValueT>
  151.     __ostream_type&
  152.     _M_insert(_ValueT __v);
  153.     };
  154.  
  155.   template <typename _CharT, typename _Traits>
  156.     class basic_ostream<_CharT, _Traits>::sentry
  157.     {
  158.       // Data Members.
  159.       bool              _M_ok;
  160.       basic_ostream<_CharT, _Traits>&   _M_os;
  161.  
  162.     };
  163.  
  164.   template<typename _CharT, typename _Traits>
  165.     inline basic_ostream<_CharT, _Traits>&
  166.     operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
  167.     { return __ostream_insert(__out, &__c, 1); }
  168.  
  169.   template<typename _CharT, typename _Traits>
  170.     inline basic_ostream<_CharT, _Traits>&
  171.     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
  172.     { return (__out << __out.widen(__c)); }
  173.  
  174.   // Specialization
  175.   template <class _Traits>
  176.     inline basic_ostream<char, _Traits>&
  177.     operator<<(basic_ostream<char, _Traits>& __out, char __c)
  178.     { return __ostream_insert(__out, &__c, 1); }
  179.  
  180.   // Signed and unsigned
  181.   template<class _Traits>
  182.     inline basic_ostream<char, _Traits>&
  183.     operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
  184.     { return (__out << static_cast<char>(__c)); }
  185.  
  186.   template<class _Traits>
  187.     inline basic_ostream<char, _Traits>&
  188.     operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
  189.     { return (__out << static_cast<char>(__c)); }
  190.  
  191.  
  192.   template<typename _CharT, typename _Traits>                           // ENGLISH OUTPUT_COMPUTES
  193.     inline basic_ostream<_CharT, _Traits>&
  194.     operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
  195.     {
  196.       if (!__s)
  197.     __out.setstate(ios_base::badbit);
  198.       else
  199.     __ostream_insert(__out, __s,
  200.              static_cast<streamsize>(_Traits::length(__s)));
  201.       return __out;
  202.     }
  203.  
  204.   template<typename _CharT, typename _Traits>
  205.     basic_ostream<_CharT, _Traits> &
  206.     operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s);
  207.  
  208.   // Partial specializations
  209.   template<class _Traits>
  210.     inline basic_ostream<char, _Traits>&
  211.     operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
  212.     {
  213.       if (!__s)
  214.     __out.setstate(ios_base::badbit);
  215.       else
  216.     __ostream_insert(__out, __s,
  217.              static_cast<streamsize>(_Traits::length(__s)));
  218.       return __out;
  219.     }
  220.  
  221.   // Signed and unsigned
  222.   template<class _Traits>
  223.     inline basic_ostream<char, _Traits>&
  224.     operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
  225.     { return (__out << reinterpret_cast<const char*>(__s)); }               ///HHHHHHEEEEERE
  226.  
  227.  
  228. _GLIBCXX_END_NAMESPACE_VERSION
  229. }
  230. //istream=============================================================================================
  231.  
  232.  
  233.  
  234. namespace std _GLIBCXX_VISIBILITY(default)
  235. {
  236. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  237.  
  238.  
  239.   template<typename _CharT, typename _Traits>
  240.     class basic_istream : virtual public basic_ios<_CharT, _Traits>
  241.     {
  242.     public:
  243.       // Types (inherited from basic_ios (27.4.4)):
  244.       typedef _CharT                    char_type;
  245.       typedef typename _Traits::int_type        int_type;
  246.       typedef typename _Traits::pos_type        pos_type;
  247.       typedef typename _Traits::off_type        off_type;
  248.       typedef _Traits                   traits_type;
  249.  
  250.       // Non-standard Types:
  251.       typedef basic_streambuf<_CharT, _Traits>      __streambuf_type;
  252.       typedef basic_ios<_CharT, _Traits>        __ios_type;
  253.       typedef basic_istream<_CharT, _Traits>        __istream_type;
  254.       typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
  255.                             __num_get_type;
  256.       typedef ctype<_CharT>                 __ctype_type;
  257.  
  258.     protected:
  259.       streamsize        _M_gcount;
  260.  
  261.     public:
  262.      explicit
  263.       basic_istream(__streambuf_type* __sb)
  264.       : _M_gcount(streamsize(0))
  265.       { this->init(__sb); }
  266.  
  267.       /// Safe prefix/suffix operations.
  268.       class sentry;
  269.       friend class sentry;
  270.  
  271.       __istream_type&
  272.       operator>>(__istream_type& (*__pf)(__istream_type&))
  273.       { return __pf(*this); }
  274.  
  275.       __istream_type&
  276.       operator>>(__ios_type& (*__pf)(__ios_type&))
  277.       {
  278.     __pf(*this);
  279.     return *this;
  280.       }
  281.  
  282.       __istream_type&
  283.       operator>>(ios_base& (*__pf)(ios_base&))
  284.       {
  285.     __pf(*this);
  286.     return *this;
  287.       }
  288.  
  289. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
  290.       __istream_type&
  291.       operator>>(bool& __n)
  292.       { return _M_extract(__n); }
  293.  
  294.       __istream_type&
  295.       operator>>(short& __n);
  296.  
  297.       __istream_type&
  298.       operator>>(unsigned short& __n)
  299.       { return _M_extract(__n); }
  300.  
  301.       __istream_type&
  302.       operator>>(int& __n);
  303.  
  304.       __istream_type&
  305.       operator>>(unsigned int& __n)
  306.       { return _M_extract(__n); }
  307.  
  308.       __istream_type&
  309.       operator>>(long& __n)
  310.       { return _M_extract(__n); }
  311.  
  312.       __istream_type&
  313.       operator>>(unsigned long& __n)
  314.       { return _M_extract(__n); }
  315. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  316.       __istream_type&
  317.       operator>>(long long& __n)
  318.       { return _M_extract(__n); }
  319.  
  320.       __istream_type&
  321.       operator>>(unsigned long long& __n)
  322.       { return _M_extract(__n); }
  323.  
  324.      __istream_type&
  325.       operator>>(float& __f)
  326.       { return _M_extract(__f); }
  327.  
  328.       __istream_type&
  329.       operator>>(double& __f)
  330.       { return _M_extract(__f); }
  331.  
  332.       __istream_type&
  333.       operator>>(long double& __f)
  334.       { return _M_extract(__f); }
  335.  
  336.  
  337.       __istream_type&
  338.       operator>>(void*& __p)
  339.       { return _M_extract(__p); }
  340.  
  341.  
  342.       __istream_type&
  343.       operator>>(__streambuf_type* __sb);
  344.  
  345.       streamsize
  346.       gcount() const { return _M_gcount; }
  347.  
  348.       int_type get();
  349.  
  350.       __istream_type& get(char_type& __c);
  351.  
  352.  
  353.       __istream_type&
  354.       get(char_type* __s, streamsize __n, char_type __delim);
  355.  
  356.  
  357.       __istream_type&
  358.       get(char_type* __s, streamsize __n)
  359.       { return this->get(__s, __n, this->widen('\n')); }
  360.  
  361.  
  362.       __istream_type&
  363.       get(__streambuf_type& __sb, char_type __delim);
  364.  
  365.  
  366.       __istream_type&
  367.       get(__streambuf_type& __sb)
  368.       { return this->get(__sb, this->widen('\n')); }
  369.  
  370.  
  371.       __istream_type&
  372.       getline(char_type* __s, streamsize __n, char_type __delim);
  373.  
  374.  
  375.       __istream_type&
  376.       getline(char_type* __s, streamsize __n)
  377.       { return this->getline(__s, __n, this->widen('\n')); }
  378.  
  379.       __istream_type&
  380.       ignore(streamsize __n, int_type __delim);
  381.  
  382.       __istream_type&
  383.       ignore(streamsize __n);
  384.  
  385.       __istream_type&
  386.       ignore();
  387.  
  388.       int_type peek();
  389.  
  390.  
  391.       __istream_type&
  392.       read(char_type* __s, streamsize __n);
  393.  
  394.  
  395.       streamsize
  396.       readsome(char_type* __s, streamsize __n);
  397.  
  398.  
  399.       __istream_type&
  400.       putback(char_type __c);
  401.  
  402.  
  403.       __istream_type&
  404.       unget();
  405.  
  406.  
  407.       int sync();
  408.  
  409.  
  410.       pos_type tellg();
  411.  
  412.       __istream_type&seekg(pos_type);
  413.  
  414.       __istream_type&seekg(off_type, ios_base::seekdir);
  415.  
  416.     protected:
  417.       basic_istream()
  418.       : _M_gcount(streamsize(0))
  419.       { this->init(0); }
  420.  
  421.       template<typename _ValueT>
  422.     __istream_type&
  423.     _M_extract(_ValueT& __v);
  424.     };
  425.  
  426.   /// Explicit specialization declarations, defined in src/istream.cc.
  427.   template<>
  428.     basic_istream<char>&
  429.     basic_istream<char>::
  430.     getline(char_type* __s, streamsize __n, char_type __delim);
  431.  
  432.   template<>
  433.     basic_istream<char>&
  434.     basic_istream<char>::
  435.     ignore(streamsize __n);
  436.  
  437.   template<>
  438.     basic_istream<char>&
  439.     basic_istream<char>::
  440.     ignore(streamsize __n, int_type __delim);
  441.  
  442.  
  443.   template<typename _CharT, typename _Traits>
  444.     class basic_istream<_CharT, _Traits>::sentry
  445.     {
  446.       // Data Members.
  447.       bool _M_ok;
  448.  
  449.     public:
  450.       /// Easy access to dependent types.
  451.       typedef _Traits                   traits_type;
  452.       typedef basic_streambuf<_CharT, _Traits>      __streambuf_type;
  453.       typedef basic_istream<_CharT, _Traits>        __istream_type;
  454.       typedef typename __istream_type::__ctype_type     __ctype_type;
  455.       typedef typename _Traits::int_type        __int_type;
  456.  
  457.  
  458.       explicit
  459.       sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
  460.  
  461.       operator bool() const
  462.       { return _M_ok; }
  463.     };
  464.  
  465.   template<typename _CharT, typename _Traits>
  466.     class basic_iostream
  467.     : public basic_istream<_CharT, _Traits>,
  468.       public basic_ostream<_CharT, _Traits>
  469.     {
  470.     public:
  471.       typedef _CharT                    char_type;
  472.       typedef typename _Traits::int_type        int_type;
  473.       typedef typename _Traits::pos_type        pos_type;
  474.       typedef typename _Traits::off_type        off_type;
  475.       typedef _Traits                   traits_type;
  476.  
  477.       // Non-standard Types:
  478.       typedef basic_istream<_CharT, _Traits>        __istream_type;
  479.       typedef basic_ostream<_CharT, _Traits>        __ostream_type;
  480.       explicit
  481.       basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
  482.       : __istream_type(__sb), __ostream_type(__sb) { }
  483.     };
  484.  
  485. _GLIBCXX_END_NAMESPACE_VERSION
  486. } // namespace
  487.  
  488.  
  489. int main(){
  490.     int i;
  491.     std::cout<<"Hello World\n";
  492.     std::cin>>i;
  493.     std::cout<<i;
  494.     return 0;
  495. }
Add Comment
Please, Sign In to add comment