110d565efSmrg // Compatibility symbols for previous versions, C++0x bits -*- C++ -*- 210d565efSmrg 3*ec02198aSmrg // Copyright (C) 2009-2020 Free Software Foundation, Inc. 410d565efSmrg // 510d565efSmrg // This file is part of the GNU ISO C++ Library. This library is free 610d565efSmrg // software; you can redistribute it and/or modify it under the 710d565efSmrg // terms of the GNU General Public License as published by the 810d565efSmrg // Free Software Foundation; either version 3, or (at your option) 910d565efSmrg // any later version. 1010d565efSmrg 1110d565efSmrg // This library is distributed in the hope that it will be useful, 1210d565efSmrg // but WITHOUT ANY WARRANTY; without even the implied warranty of 1310d565efSmrg // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1410d565efSmrg // GNU General Public License for more details. 1510d565efSmrg 1610d565efSmrg // Under Section 7 of GPL version 3, you are granted additional 1710d565efSmrg // permissions described in the GCC Runtime Library Exception, version 1810d565efSmrg // 3.1, as published by the Free Software Foundation. 1910d565efSmrg 2010d565efSmrg // You should have received a copy of the GNU General Public License and 2110d565efSmrg // a copy of the GCC Runtime Library Exception along with this program; 2210d565efSmrg // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 2310d565efSmrg // <http://www.gnu.org/licenses/>. 2410d565efSmrg 2510d565efSmrg #define _GLIBCXX_COMPATIBILITY_CXX0X 2610d565efSmrg #define _GLIBCXX_USE_CXX11_ABI 0 2710d565efSmrg #define error_category error_categoryxx 2810d565efSmrg #define system_category system_categoryxx 2910d565efSmrg #define generic_category generic_categoryxx 3010d565efSmrg #define _V2 _V2xx 3110d565efSmrg #include <string> 3210d565efSmrg #include <system_error> 3310d565efSmrg #include <cstring> 3410d565efSmrg #undef error_category 3510d565efSmrg #undef system_category 3610d565efSmrg #undef generic_category 3710d565efSmrg #undef _V2 3810d565efSmrg 3910d565efSmrg #if __cplusplus < 201103L 4010d565efSmrg # error "compatibility-c++0x.cc must be compiled with -std=gnu++0x" 4110d565efSmrg #endif 4210d565efSmrg 4310d565efSmrg #ifdef _GLIBCXX_SHARED 4410d565efSmrg 4510d565efSmrg namespace std _GLIBCXX_VISIBILITY(default) 4610d565efSmrg { 47c7a68eb7Smrg _GLIBCXX_BEGIN_NAMESPACE_VERSION 48c7a68eb7Smrg 4910d565efSmrg // gcc-4.4.0 5010d565efSmrg // <mutex> exported std::lock_error 5110d565efSmrg #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1) 5210d565efSmrg class lock_error : public exception 5310d565efSmrg { 5410d565efSmrg public: 5510d565efSmrg virtual const char* 5610d565efSmrg _GLIBCXX_CONST what() const throw(); 5710d565efSmrg }; 5810d565efSmrg 5910d565efSmrg const char* what() const6010d565efSmrg lock_error::what() const throw() 6110d565efSmrg { return "std::lock_error"; } 6210d565efSmrg #endif 6310d565efSmrg 6410d565efSmrg // We need these due to the symbols exported since GLIBCXX_3.4.10. 6510d565efSmrg // See libstdc++/41662 for details. 6610d565efSmrg 6710d565efSmrg #ifndef _GLIBCXX_LONG_DOUBLE_COMPAT_IMPL 6810d565efSmrg template<> 6910d565efSmrg struct hash<string> 7010d565efSmrg { 7110d565efSmrg size_t operator()(string) const; 7210d565efSmrg }; 7310d565efSmrg 7410d565efSmrg size_t operator ()(string __s) const7510d565efSmrg hash<string>::operator()(string __s) const 7610d565efSmrg { return _Hash_impl::hash(__s.data(), __s.length()); } 7710d565efSmrg 7810d565efSmrg template<> 7910d565efSmrg struct hash<const string&> 8010d565efSmrg { 8110d565efSmrg size_t operator()(const string&) const; 8210d565efSmrg }; 8310d565efSmrg 8410d565efSmrg size_t operator ()(const string & __s) const8510d565efSmrg hash<const string&>::operator()(const string& __s) const 8610d565efSmrg { return _Hash_impl::hash(__s.data(), __s.length()); } 8710d565efSmrg 8810d565efSmrg #ifdef _GLIBCXX_USE_WCHAR_T 8910d565efSmrg template<> 9010d565efSmrg struct hash<wstring> 9110d565efSmrg { 9210d565efSmrg size_t operator()(wstring) const; 9310d565efSmrg }; 9410d565efSmrg 9510d565efSmrg size_t operator ()(wstring __s) const9610d565efSmrg hash<wstring>::operator()(wstring __s) const 9710d565efSmrg { return _Hash_impl::hash(__s.data(), __s.length() * sizeof(wchar_t)); } 9810d565efSmrg 9910d565efSmrg template<> 10010d565efSmrg struct hash<const wstring&> 10110d565efSmrg { 10210d565efSmrg size_t operator()(const wstring&) const; 10310d565efSmrg }; 10410d565efSmrg 10510d565efSmrg size_t operator ()(const wstring & __s) const10610d565efSmrg hash<const wstring&>::operator()(const wstring& __s) const 10710d565efSmrg { return _Hash_impl::hash(__s.data(), __s.length() * sizeof(wchar_t)); } 10810d565efSmrg #endif 10910d565efSmrg #endif 11010d565efSmrg 11110d565efSmrg template<> 11210d565efSmrg struct hash<error_code> 11310d565efSmrg { 11410d565efSmrg size_t operator()(error_code) const; 11510d565efSmrg }; 11610d565efSmrg 11710d565efSmrg size_t operator ()(error_code __e) const11810d565efSmrg hash<error_code>::operator()(error_code __e) const 11910d565efSmrg { 120*ec02198aSmrg const size_t __tmp = std::_Hash_impl::hash(__e.value()); 121*ec02198aSmrg return std::_Hash_impl::__hash_combine(&__e.category(), __tmp); 12210d565efSmrg } 12310d565efSmrg 12410d565efSmrg // gcc-4.7.0 12510d565efSmrg // <chrono> changes is_monotonic to is_steady. 12610d565efSmrg namespace chrono 12710d565efSmrg { 12810d565efSmrg struct system_clock 12910d565efSmrg { 13010d565efSmrg static constexpr bool is_monotonic = false; 13110d565efSmrg }; 13210d565efSmrg constexpr bool system_clock::is_monotonic; 13310d565efSmrg } // namespace chrono 13410d565efSmrg 13510d565efSmrg // gcc-5 replaces this with _V2::error_category 13610d565efSmrg class error_category 13710d565efSmrg { 13810d565efSmrg public: 13910d565efSmrg error_category() noexcept; 14010d565efSmrg 14110d565efSmrg virtual ~error_category(); 14210d565efSmrg 14310d565efSmrg error_category(const error_category&) = delete; 14410d565efSmrg error_category& operator=(const error_category&) = delete; 14510d565efSmrg 14610d565efSmrg virtual const char* 14710d565efSmrg name() const noexcept = 0; 14810d565efSmrg 14910d565efSmrg virtual string 15010d565efSmrg message(int) const = 0; 15110d565efSmrg 15210d565efSmrg virtual error_condition 15310d565efSmrg default_error_condition(int __i) const noexcept; 15410d565efSmrg 15510d565efSmrg virtual bool 15610d565efSmrg equivalent(int __i, const error_condition& __cond) const noexcept; 15710d565efSmrg 15810d565efSmrg virtual bool 15910d565efSmrg equivalent(const error_code& __code, int __i) const noexcept; 16010d565efSmrg 16110d565efSmrg bool operator <(const error_category & __other) const16210d565efSmrg operator<(const error_category& __other) const noexcept 16310d565efSmrg { return less<const error_category*>()(this, &__other); } 16410d565efSmrg 16510d565efSmrg bool operator ==(const error_category & __other) const16610d565efSmrg operator==(const error_category& __other) const noexcept 16710d565efSmrg { return this == &__other; } 16810d565efSmrg 16910d565efSmrg bool operator !=(const error_category & __other) const17010d565efSmrg operator!=(const error_category& __other) const noexcept 17110d565efSmrg { return this != &__other; } 17210d565efSmrg }; 17310d565efSmrg 17410d565efSmrg // gcc-4.9.0 17510d565efSmrg // LWG 2145 changes this constructor to constexpr i.e. inline 17610d565efSmrg error_category::error_category() noexcept = default; 17710d565efSmrg 17810d565efSmrg error_category::~error_category() noexcept = default; 17910d565efSmrg 18010d565efSmrg namespace 18110d565efSmrg { 18210d565efSmrg using std::string; 18310d565efSmrg 18410d565efSmrg struct generic_error_category : public std::error_category 18510d565efSmrg { 18610d565efSmrg virtual const char* namestd::__anon78667d2e0111::generic_error_category18710d565efSmrg name() const noexcept 18810d565efSmrg { return "generic"; } 18910d565efSmrg 19010d565efSmrg virtual string messagestd::__anon78667d2e0111::generic_error_category19110d565efSmrg message(int i) const 19210d565efSmrg { 19310d565efSmrg // XXX locale issues: how does one get or set loc. 19410d565efSmrg // _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc) 19510d565efSmrg return string(strerror(i)); 19610d565efSmrg } 19710d565efSmrg }; 19810d565efSmrg 19910d565efSmrg struct system_error_category : public std::error_category 20010d565efSmrg { 20110d565efSmrg virtual const char* namestd::__anon78667d2e0111::system_error_category20210d565efSmrg name() const noexcept 20310d565efSmrg { return "system"; } 20410d565efSmrg 20510d565efSmrg virtual string messagestd::__anon78667d2e0111::system_error_category20610d565efSmrg message(int i) const 20710d565efSmrg { 20810d565efSmrg // XXX locale issues: how does one get or set loc. 20910d565efSmrg // _GLIBCXX_HAVE_STRERROR_L, strerror_l(i, cloc) 21010d565efSmrg return string(strerror(i)); 21110d565efSmrg } 21210d565efSmrg }; 21310d565efSmrg 21410d565efSmrg const generic_error_category generic_category_instance{}; 21510d565efSmrg const system_error_category system_category_instance{}; 21610d565efSmrg } 21710d565efSmrg 21810d565efSmrg const error_category& system_category()21910d565efSmrg system_category() noexcept { return system_category_instance; } 22010d565efSmrg 22110d565efSmrg const error_category& generic_category()22210d565efSmrg generic_category() noexcept { return generic_category_instance; } 22310d565efSmrg 22410d565efSmrg namespace _V2 22510d565efSmrg { 22610d565efSmrg _GLIBCXX_CONST const error_categoryxx& system_category() noexcept; 22710d565efSmrg _GLIBCXX_CONST const error_categoryxx& generic_category() noexcept; 22810d565efSmrg } 22910d565efSmrg 23010d565efSmrg error_condition default_error_condition(int __i) const23110d565efSmrg error_category::default_error_condition(int __i) const noexcept 23210d565efSmrg { 23310d565efSmrg if (*this == system_category()) 23410d565efSmrg return error_condition(__i, _V2::system_category()); 23510d565efSmrg return error_condition(__i, _V2::generic_category()); 23610d565efSmrg } 23710d565efSmrg 23810d565efSmrg bool equivalent(int __i,const error_condition & __cond) const23910d565efSmrg error_category::equivalent(int __i, 24010d565efSmrg const error_condition& __cond) const noexcept 24110d565efSmrg { return default_error_condition(__i) == __cond; } 24210d565efSmrg 24310d565efSmrg bool equivalent(const error_code & __code,int __i) const24410d565efSmrg error_category::equivalent(const error_code& __code, int __i) const noexcept 24510d565efSmrg { 24610d565efSmrg if (*this == system_category() 24710d565efSmrg && __code.category() == _V2::system_category()) 24810d565efSmrg return __code.value() == __i; 24910d565efSmrg if (*this == generic_category() 25010d565efSmrg && __code.category() == _V2::generic_category()) 25110d565efSmrg return __code.value() == __i; 25210d565efSmrg return false; 25310d565efSmrg } 25410d565efSmrg 255c7a68eb7Smrg _GLIBCXX_END_NAMESPACE_VERSION 25610d565efSmrg } 25710d565efSmrg #endif 258