diff --git a/Makefile b/Makefile index 8c3e697..43bf249 100644 --- a/Makefile +++ b/Makefile @@ -249,4 +249,4 @@ source: https://en.cppreference.com/w/ ; \ popd > /dev/null - ./export.py --url=http://en.cppreference.com/mwiki reference/cppreference-export-ns0,4,8,10.xml 0 4 8 10 + ./export.py --url=https://en.cppreference.com/mwiki reference/cppreference-export-ns0,4,8,10.xml 0 4 8 10 diff --git a/headers/README.md b/headers/README.md index b3de6df..64c605b 100644 --- a/headers/README.md +++ b/headers/README.md @@ -1,50 +1,52 @@ Information ----------- - + This directory contains dummy C++ standard library that contains only the declarations of the C++ standard library interface, to be used as an aid in code completion. -Real standard library implementations often use complex C++ techniques in order -to provide full compliance and perform optimizations. This leads to code -completion implementations being unable to resolve typedef result and function -return types, and thus being unable to provide code completion of class members -when given instance variable. This issue becomes more and more important with +Real standard library implementations often use complex C++ techniques in order +to provide full compliance and perform optimizations. This leads to code +completion implementations being unable to resolve typedef result and function +return types, and thus being unable to provide code completion of class members +when given instance variable. This issue becomes more and more important with widespread use of C++ 'auto' type specifier, because code completion of members of such variables depend on function return types being correctly resolved. This dummy library performs various steps to simplify the exposed interface, to make code completion more useful. In addition to that, descriptive parameter names are exposed instead of uglified identifiers used in real standard library -implementations. The parameter names correspond to those provided for +implementations. The parameter names correspond to those provided for respective functions in the cppreference.com C++ reference. +To simplify, noexcept specifiers are omitted from declarations. + Configuration ------------- -The exposed interface depends on the values of the following preprocessor +The exposed interface depends on the values of the following preprocessor macros: - CPPREFERENCE_STDVER: defines the standard version of the interface. Possible values are 1998, 2003, 2011, 2014, 2017 which correspond to the respective C++ standards. - - - CPPREFERENCE_SIMPLIFY_TYPEDEFS: non-zero value results in simplified - typedefs being exposed. Usage of various traits is greatly reduced; the - typedefs refer to types that would be resolved in most common cases. + + - CPPREFERENCE_SIMPLIFY_TYPEDEFS: non-zero value results in simplified + typedefs being exposed. Usage of various traits is greatly reduced; the + typedefs refer to types that would be resolved in most common cases. Enabling this is recommended. Usage ----- -The primary target for this dummy C++ standard library is the Qt Creator IDE, +The primary target for this dummy C++ standard library is the Qt Creator IDE, though the code might be useful in other IDEs. -For each Qt Creator project, perform the following steps to replace the +For each Qt Creator project, perform the following steps to replace the C++ library used by code completion: - Add the path to this directory to the $PROJECT.includes file - Define CPPREFERENCE_STDVER and/or CPPREFERENCE_SIMPLIFY_TYPEDEFS to correct - values in the $PROJECT.config file. \ No newline at end of file + values in the $PROJECT.config file. diff --git a/headers/algorithm b/headers/algorithm index 596f60c..d2401ae 100644 --- a/headers/algorithm +++ b/headers/algorithm @@ -19,6 +19,7 @@ #include #endif #include // for std::pair +#include // for std::iterator_traits namespace std { @@ -38,36 +39,80 @@ UnaryFunction for_each(InputIt first, InputIt last, UnaryFunction f); template typename iterator_traits::difference_type -count(InputIt first, InputIt last, const T& value); + count(InputIt first, InputIt last, const T& value); template typename iterator_traits::difference_type -count_if(InputIt first, InputIt last, UnaryPredicate p); + count_if(InputIt first, InputIt last, UnaryPredicate p); +#if CPPREFERENCE_STDVER >= 2020 template std::pair -mismatch(InputIt1 first1, InputIt1 last1, - InputIt2 first2); +constexpr mismatch(InputIt1 first1, InputIt1 last1, + InputIt2 first2); template std::pair -mismatch(InputIt1 first1, InputIt1 last1, - InputIt2 first2, - BinaryPredicate p); +constexpr mismatch(InputIt1 first1, InputIt1 last1, + InputIt2 first2, + BinaryPredicate p); +#else +template +std::pair + mismatch(InputIt1 first1, InputIt1 last1, + InputIt2 first2); + +template +std::pair + mismatch(InputIt1 first1, InputIt1 last1, + InputIt2 first2, + BinaryPredicate p); +#endif + +#if CPPREFERENCE_STDVER >= 2017 +template +std::pair + mismatch(ExecutionPolicy&& policy, + InputIt1 first1, InputIt1 last1, + InputIt2 first2); + +template +std::pair + mismatch(ExecutionPolicy&& policy, + InputIt1 first1, InputIt1 last1, + InputIt2 first2, + BinaryPredicate p); +#endif #if CPPREFERENCE_STDVER >= 2014 template std::pair -mismatch(InputIt1 first1, InputIt1 last1, - InputIt2 first2, InputIt2 last2); + mismatch(InputIt1 first1, InputIt1 last1, + InputIt2 first2, InputIt2 last2); template std::pair -mismatch(InputIt1 first1, InputIt1 last1, - InputIt2 first2, InputIt2 last2, - BinaryPredicate p); + mismatch(InputIt1 first1, InputIt1 last1, + InputIt2 first2, InputIt2 last2, + BinaryPredicate p); +#endif + +#if CPPREFERENCE_STDVER >= 2017 +template +std::pair + mismatch(ExecutionPolicy&& policy, + InputIt1 first1, InputIt1 last1, + InputIt2 first2, InputIt2 last2); + +template +std::pair + mismatch(ExecutionPolicy&& policy, + InputIt1 first1, InputIt1 last1, + InputIt2 first2, InputIt2 last2, + BinaryPredicate p); #endif + template bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2); @@ -87,6 +132,29 @@ bool equal(InputIt1 first1, InputIt1 last1, BinaryPredicate p); #endif +#if CPPREFERENCE_STDVER >= 2017 +template +bool equal(ExecutionPolicy&& policy, + InputIt1 first1, InputIt1 last1, + InputIt2 first2); + +template +bool equal(ExecutionPolicy&& policy, + InputIt1 first1, InputIt1 last1, + InputIt2 first2, BinaryPredicate p); + +template +bool equal(ExecutionPolicy&& policy, + InputIt1 first1, InputIt1 last1, + InputIt2 first2, InputIt2 last2); + +template +bool equal(ExecutionPolicy&& policy, + InputIt1 first1, InputIt1 last1, + InputIt2 first2, InputIt2 last2, + BinaryPredicate p); +#endif + template InputIt find(InputIt first, InputIt last, const T& value); @@ -555,32 +623,32 @@ template constexpr ForwardIt max_element(ForwardIt first, ForwardIt last, Compare cmp); #endif -#if CPPREFERENCE_STDVER <2014 +#if CPPREFERENCE_STDVER >= 2014 template -const T& min(const T& a, const T& b); +constexpr const T& min(const T& a, const T& b); template -const T& min(const T& a, const T& b, Compare comp); +constexpr const T& min(const T& a, const T& b, Compare comp); #else template -constexpr const T& min(const T& a, const T& b); +const T& min(const T& a, const T& b); template -constexpr const T& min(const T& a, const T& b, Compare comp); +const T& min(const T& a, const T& b, Compare comp); #endif -#if CPPREFERENCE_STDVER >= 2011 +#if CPPREFERENCE_STDVER >= 2014 template -T min(std::initializer_list ilist); +constexpr T min(std::initializer_list ilist); template -T min(std::initializer_list ilist, Compare comp); -#elif CPPREFERENCE_STDVER >= 2014 +constexpr T min(std::initializer_list ilist, Compare comp); +#elif CPPREFERENCE_STDVER >= 2011 template -constexpr T min(std::initializer_list ilist); +T min(std::initializer_list ilist); template -constexpr T min(std::initializer_list ilist, Compare comp); +T min(std::initializer_list ilist, Compare comp); #endif #if CPPREFERENCE_STDVER <2017 @@ -597,32 +665,32 @@ template constexpr ForwardIt min_element(ForwardIt first, ForwardIt last, Compare cmp); #endif -#if CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2014 +#if CPPREFERENCE_STDVER >= 2014 template -std::pair minmax(const T& a, const T& b); +constexpr std::pair minmax(const T& a, const T& b); template -std::pair minmax(const T& a, const T& b, - Compare comp); - +constexpr std::pair minmax(const T& a, const T& b, + Compare comp); template -std::pair minmax(std::initializer_list ilist); +constexpr std::pair minmax(std::initializer_list ilist); template -std::pair minmax(std::initializer_list ilist, Compare comp); +constexpr std::pair minmax(std::initializer_list ilist, Compare comp); -#elif CPPREFERENCE_STDVER >= 2014 +#elif CPPREFERENCE_STDVER >= 2011 template -constexpr std::pair minmax(const T& a, const T& b); +std::pair minmax(const T& a, const T& b); template -constexpr std::pair minmax(const T& a, const T& b, - Compare comp); +std::pair minmax(const T& a, const T& b, + Compare comp); + template -constexpr std::pair minmax(std::initializer_list ilist); +std::pair minmax(std::initializer_list ilist); template -constexpr std::pair minmax(std::initializer_list ilist, Compare comp); +std::pair minmax(std::initializer_list ilist, Compare comp); #endif #if CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2017 @@ -652,7 +720,15 @@ bool lexicographical_compare(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp); -#if CPPREFERENCE_STDVER >= 2011 +#if CPPREFERENCE_STDVER >= 2020 +template +constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, + ForwardIt2 first2); + +template +constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, + ForwardIt2 first2, BinaryPredicate p); +#elif CPPREFERENCE_STDVER >= 2011 template bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2); @@ -662,7 +738,17 @@ bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, BinaryPredicate p); #endif -#if CPPREFERENCE_STDVER >= 2011 +#if CPPREFERENCE_STDVER >= 2020 +template +constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, + ForwardIt2 first2, ForwardIt2 last2); + +template +constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, + ForwardIt2 first2, ForwardIt2 last2, + BinaryPredicate p); + +#elif CPPREFERENCE_STDVER >= 2011 template bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2); diff --git a/headers/array b/headers/array index 2969810..020f29d 100644 --- a/headers/array +++ b/headers/array @@ -46,13 +46,6 @@ public: typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; - // constructor - array& operator=(const array& other); -#if CPPREFERENCE_STDVER>= 2011 - array& operator=(array&& other); - array& operator=(initializer_list ilist); -#endif - void assign(size_type count, const value_type& value); template void assign(InputIt first, InputIt last); @@ -60,18 +53,49 @@ public: void assign(std::initializer_list ilist); #endif - allocator_type get_allocator() const; - // element access +#if CPPREFERENCE_STDVER >= 2017 + constexpr reference at(size_type n); + constexpr const_reference at(size_type n) const; +#else reference at(size_type n); const_reference at(size_type n) const; - reference operator[](size_type n); +#endif + +#if CPPREFERENCE_STDVER >= 2017 + constexpr reference operator[](size_type n); +#else + reference operator[](size_type n); +#endif +#if CPPREFERENCE_STDVER >= 2014 + constexpr const_reference operator[](size_type n) const; +#else const_reference operator[](size_type n) const; +#endif - reference front(); +#if CPPREFERENCE_STDVER >= 2017 + constexpr reference front(); +#else + reference front(); +#endif + +#if CPPREFERENCE_STDVER >= 2014 + constexpr const_reference front() const; +#else const_reference front() const; - reference back(); +#endif + +#if CPPREFERENCE_STDVER >= 2017 + constexpr reference back(); +#else + reference back(); +#endif + +#if CPPREFERENCE_STDVER >= 2014 + constexpr const_reference back() const; +#else const_reference back() const; +#endif T* data(); const T* data() const; @@ -94,11 +118,17 @@ public: bool empty() const; size_type size() const; - size_type max_size() const; +#if CPPREFERENCE_STDVER >= 2014 + constexpr size_type max_size() const; +#else + constexpr size_type max_size(); +#endif void fill(const T& value); void swap(array& other); + + T internal_data[N]; // exposure-only }; template diff --git a/headers/atomic b/headers/atomic index d246cc5..0142c7b 100644 --- a/headers/atomic +++ b/headers/atomic @@ -16,6 +16,9 @@ #ifndef CPPREFERENCE_ATOMIC_H #define CPPREFERENCE_ATOMIC_H +#include // for ptrdiff_t +#include + namespace std { #if CPPREFERENCE_STDVER>= 2011 @@ -127,9 +130,9 @@ struct atomic { // member of atomic T fetch_xor(T arg, - memory_xorder = std::memory_xorder_seq_cst); + memory_order = std::memory_order_seq_cst); T fetch_xor(T arg, - memory_xorder = std::memory_xorder_seq_cst) volatile; + memory_order = std::memory_order_seq_cst) volatile; // member of atomic T operator++(); diff --git a/headers/bitset b/headers/bitset index e868f70..c457ced 100644 --- a/headers/bitset +++ b/headers/bitset @@ -16,6 +16,10 @@ #ifndef CPPREFERENCE_BITSET_H #define CPPREFERENCE_BITSET_H +#include // for size_t +#include +#include + namespace std { template @@ -128,10 +132,10 @@ bitset operator^(const bitset& lhs, const bitset& rhs); template std::basic_ostream& operator<<(std::basic_ostream& os, - const bitset& x); + const bitset& x); template std::basic_istream& operator>>(std::basic_istream& is, - bitset& x); + bitset& x); } // namespace std diff --git a/headers/chrono b/headers/chrono index 9833e88..874ca9a 100644 --- a/headers/chrono +++ b/headers/chrono @@ -18,6 +18,7 @@ #if CPPREFERENCE_STDVER>= 2011 #include +#include // for time_t namespace std { namespace chrono { @@ -35,7 +36,7 @@ public: duration& operator=(const duration& other) = default; - constexpr rep count() const; + constexpr Rep count() const; static constexpr duration zero(); static constexpr duration min(); @@ -51,9 +52,9 @@ public: duration& operator+=(const duration& d); duration& operator-=(const duration& d); - duration& operator*=(const rep& rhs); - duration& operator/=(const rep& rhs); - duration& operator%=(const rep& rhs); + duration& operator*=(const Rep& rhs); + duration& operator/=(const Rep& rhs); + duration& operator%=(const Rep& rhs); duration& operator%=(const duration& rhs); }; @@ -157,16 +158,26 @@ public: #else typedef Clock clock; typedef Duration duration; - typedef Duration::rep rep; - typedef Duration::period period; + typedef typename Duration::rep rep; + typedef typename Duration::period period; #endif +#if CPPREFERENCE_STDVER >= 2014 + constexpr time_point(); + constexpr explicit time_point(const duration& d); + + template + constexpr time_point(const time_point& t); + + constexpr duration time_since_epoch() const; +#else time_point(); explicit time_point(const duration& d); template time_point(const time_point& t); duration time_since_epoch() const; +#endif time_point& operator+=(const duration& d); time_point& operator-=(const duration& d); @@ -216,8 +227,15 @@ template bool operator>=(const time_point& lhs, const time_point& rhs); +#if CPPREFERENCE_STDVER >= 2014 +template +constexpr time_point time_point_cast( + const time_point& t); +#else template -time_point time_point_cast(const time_point& t); +time_point time_point_cast( + const time_point& t); +#endif class system_clock { public: @@ -226,7 +244,7 @@ public: typedef duration duration; typedef time_point time_point; - constexpr static bool is_steady; + constexpr static bool is_steady = false; static std::chrono::time_point now(); static std::time_t to_time_t(const time_point& t); @@ -240,7 +258,7 @@ public: typedef duration duration; typedef time_point time_point; - constexpr static bool is_steady; + constexpr static bool is_steady = false; static std::chrono::time_point now(); }; @@ -252,7 +270,7 @@ public: typedef duration duration; typedef time_point time_point; - constexpr static bool is_steady; + constexpr static bool is_steady = false; static std::chrono::time_point now(); }; diff --git a/headers/codecvt b/headers/codecvt index 477ca77..0b73905 100644 --- a/headers/codecvt +++ b/headers/codecvt @@ -18,6 +18,10 @@ #if CPPREFERENCE_STDVER >= 2011 +#include // for size_t +#include // for mbstate_t +#include // for codecvt + namespace std { enum codecvt_mode { @@ -26,11 +30,10 @@ enum codecvt_mode { little_endian = 1 }; -template < - class Elem, - unsigned long Maxcode = 0x10ffff, - std::codecvt_mode Mode = (std::codecvt_mode)0 - > class codecvt_utf8 : public std::codecvt { +template(0)> +class codecvt_utf8 : public std::codecvt { public: explicit codecvt_utf8(std::size_t refs = 0); ~codecvt_utf8(); @@ -38,7 +41,7 @@ public: template + std::codecvt_mode Mode = static_cast(0) > class codecvt_utf16 : public std::codecvt { public: explicit codecvt_utf16(std::size_t refs = 0); @@ -47,7 +50,7 @@ public: template + std::codecvt_mode Mode = static_cast(0) > class codecvt_utf8_utf16 : public std::codecvt { public: explicit codecvt_utf8_utf16(std::size_t refs = 0); diff --git a/headers/complex b/headers/complex index 086a863..6e3e252 100644 --- a/headers/complex +++ b/headers/complex @@ -16,6 +16,8 @@ #ifndef CPPREFERENCE_COMPLEX_H #define CPPREFERENCE_COMPLEX_H +#include + namespace std { template @@ -23,23 +25,48 @@ class complex { public: typedef T value_type; +#if CPPREFERENCE_STDVER >= 2014 + constexpr complex(const T& re = T(), const T& im = T()); + + constexpr complex(const complex& other); + + template + constexpr complex(const complex& other); +#else complex(const T& re = T(), const T& im = T()); complex(const complex& other); template complex(const complex& other); +#endif complex& operator=(const T& x); template complex& operator=(const complex& cx); +#if CPPREFERENCE_STDVER >= 2014 + constexpr T real() const; +#else T real() const; +#endif +#if CPPREFERENCE_STDVER >= 2020 + constexpr void real(T value); +#else void real(T value); +#endif +#if CPPREFERENCE_STDVER >= 2014 + constexpr T imag() const; +#else T imag() const; +#endif +#if CPPREFERENCE_STDVER >= 2020 + constexpr void imag(T value); +#else void imag(T value); +#endif complex& operator+=(const T& other); @@ -61,11 +88,11 @@ public: template complex& operator/=(const complex& other); - template - complex operator+(const complex& val); + template + complex operator+(const complex& val); - template - complex operator-(const complex& val); + template + complex operator-(const complex& val); }; template @@ -104,6 +131,20 @@ complex operator/(const complex& lhs, const T& rhs); template complex operator/(const T& lhs, const complex& rhs); +#if CPPREFERENCE_STDVER >= 2014 +template +constexpr bool operator==(const complex& lhs, const complex& rhs); +template +constexpr bool operator!=(const complex& lhs, const complex& rhs); +template +constexpr bool operator<(const complex& lhs, const complex& rhs); +template +constexpr bool operator<=(const complex& lhs, const complex& rhs); +template +constexpr bool operator>(const complex& lhs, const complex& rhs); +template +constexpr bool operator>=(const complex& lhs, const complex& rhs); +#else template bool operator==(const complex& lhs, const complex& rhs); template @@ -116,6 +157,8 @@ template bool operator>(const complex& lhs, const complex& rhs); template bool operator>=(const complex& lhs, const complex& rhs); +#endif + template std::basic_ostream& @@ -127,11 +170,19 @@ std::basic_istream& operator>>(std::basic_istream& is, std::complex& x); +#if CPPREFERENCE_STDVER >= 2014 +template +constexpr T real(const complex& z); + +template +constexpr T imag(const complex& z); +#else template T real(const complex& z); template T imag(const complex& z); +#endif template T abs(const complex& z); diff --git a/headers/condition_variable b/headers/condition_variable index a05f1fc..66db3a9 100644 --- a/headers/condition_variable +++ b/headers/condition_variable @@ -18,6 +18,8 @@ #if CPPREFERENCE_STDVER>= 2011 +#include // for unique_lock + namespace std { enum class cv_status { diff --git a/headers/csetjmp b/headers/csetjmp index c867e15..aef488b 100644 --- a/headers/csetjmp +++ b/headers/csetjmp @@ -24,6 +24,6 @@ void longjmp(std::jmp_buf env, int status); } // namespace std -void setjmp(jmp_buf buf); // actually a macro +void setjmp(std::jmp_buf buf); // actually a macro #endif // CPPREFERENCE_CSETJMP_H diff --git a/headers/cstdarg b/headers/cstdarg index 038c09f..f067307 100644 --- a/headers/cstdarg +++ b/headers/cstdarg @@ -18,16 +18,32 @@ namespace std { -struct va_list; // actually a typedef +#ifdef va_start +typedef ::va_list va_list; +#else +struct va_list {}; // actually a typedef +#endif } // namespace std -void va_start(std::va_list ap, int parm_n); // actually a macro +#ifndef va_start +template +void va_start(std::va_list ap, T parm_n); // actually a macro +#endif + +#ifndef va_arg #define va_arg(x, T) T() +#endif + #if CPPREFERENCE_STDVER>= 2011 +#ifndef va_copy void va_copy(std::va_list desc, std::va_list src); // actually a macro #endif +#endif + +#ifndef va_end void va_end(std::va_list ap); // actually a macro +#endif #endif // CPPREFERENCE_CSTDARG_H diff --git a/headers/cstddef b/headers/cstddef index 84da4b5..c5fdece 100644 --- a/headers/cstddef +++ b/headers/cstddef @@ -16,8 +16,6 @@ #ifndef CPPREFERENCE_CSTDDEF_H #define CPPREFERENCE_CSTDDEF_H -namespace std { - #ifndef offsetof #define offsetof(type,member_designator) 0 // SIMPLIFIED #endif @@ -27,10 +25,17 @@ namespace std { namespace std { // dummy impl -typedef long long ptrdiff_t; -typedef long long size_t; -typedef long long max_align_t; + +typedef long ptrdiff_t; +typedef unsigned long size_t; +typedef long max_align_t; +#if CPPREFERENCE_STDVER >= 2011 +#if CPPREFERENCE_SIMPLIFY_TYPEDEFS typedef void* nullptr_t; +#else +typedef decltype(nullptr) nullptr_t; +#endif +#endif } // namespace std #endif // CPPREFERENCE_CSTDDEF_H diff --git a/headers/cstdio b/headers/cstdio index f4f0198..331e3c3 100644 --- a/headers/cstdio +++ b/headers/cstdio @@ -16,9 +16,10 @@ #ifndef CPPREFERENCE_CSTDIO_H #define CPPREFERENCE_CSTDIO_H -#define stdin (::std::FILE*)(NULL) // actually a valid pointer -#define stdout (::std::FILE*)(NULL) -#define stderr (::std::FILE*)(NULL) +#define stdin (reinterpret_cast<::std::FILE*>(NULL)) // actually a valid pointer +#define stdout (reinterpret_cast<::std::FILE*>(NULL)) +#define stderr (reinterpret_cast<::std::FILE*>(NULL)) + #define EOR 0 #define FOPEN_MAX 0 #define FILENAME_MAX 0 @@ -32,6 +33,9 @@ #define TMP_MAX 0 #define L_tmpnam 0 +#include +#include + namespace std { struct FILE; @@ -62,7 +66,7 @@ int fscanf(std::FILE* stream, const char* format, ...); int sscanf(const char* buffer, const char* format, ...); #if CPPREFERENCE_STDVER>= 2011 -int vscanf(const char* format, v_list vlist); +int vscanf(const char* format, va_list vlist); int vfscanf(std::FILE* stream, const char* format, va_list vlist); int vsscanf(const char* buffer, const char* format, va_list vlist); #endif diff --git a/headers/cstdlib b/headers/cstdlib index 0b838a5..0d18b0f 100644 --- a/headers/cstdlib +++ b/headers/cstdlib @@ -16,6 +16,8 @@ #ifndef CPPREFERENCE_CSTDLIB_H #define CPPREFERENCE_CSTDLIB_H +#include + namespace std { // math utils diff --git a/headers/cstring b/headers/cstring index 131b33f..f019f3e 100644 --- a/headers/cstring +++ b/headers/cstring @@ -16,6 +16,8 @@ #ifndef CPPREFERENCE_CSTRING_H #define CPPREFERENCE_CSTRING_H +#include // for size_t + namespace std { char* strcpy(char* dest, const char* src); diff --git a/headers/ctime b/headers/ctime index 90cb500..660b89a 100644 --- a/headers/ctime +++ b/headers/ctime @@ -16,6 +16,8 @@ #ifndef CPPREFERENCE_CTIME_H #define CPPREFERENCE_CTIME_H +#include // for size_t + #define CLOCKS_PER_SEC 0 // unspecified namespace std { diff --git a/headers/cuchar b/headers/cuchar index d6dde80..faccadf 100644 --- a/headers/cuchar +++ b/headers/cuchar @@ -18,8 +18,17 @@ #if CPPREFERENCE_STDVER>= 2011 +#include // for size_t +#include // for mbstate_t + +#ifndef __STDC_UTF_16__ #define __STDC_UTF_16__ +#endif + +#ifndef __STDC_UTF_16__ #define __STDC_UTF_32__ +#endif + namespace std { std::size_t mbrtoc16(char16_t* pc16, diff --git a/headers/cwchar b/headers/cwchar index 35f1a64..9c8a2ef 100644 --- a/headers/cwchar +++ b/headers/cwchar @@ -16,6 +16,10 @@ #ifndef CPPREFERENCE_CWCHAR_H #define CPPREFERENCE_CWCHAR_H +#include // for size_t +#include // for wint_t +#include // for FILE + namespace std { // wide strings diff --git a/headers/deque b/headers/deque index 894c776..1371f17 100644 --- a/headers/deque +++ b/headers/deque @@ -70,6 +70,7 @@ public: deque(size_type count, const T& value, const Allocator& alloc = Allocator()); +#endif #if CPPREFERENCE_STDVER <2014 explicit deque(size_type n); diff --git a/headers/detail/cppreference_unspecified b/headers/detail/cppreference_unspecified new file mode 100644 index 0000000..3e4476c --- /dev/null +++ b/headers/detail/cppreference_unspecified @@ -0,0 +1,35 @@ +/* Copyright (C) 2019 Povilas Kanapickas + + This file is part of cppreference-doc + + This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 + Unported License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative + Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 or + any later version published by the Free Software Foundation; with no + Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +*/ + +#ifndef CPPREFERENCE_DETAIL_CPPREFERENCE_UNSPECIFIED_H +#define CPPREFERENCE_DETAIL_CPPREFERENCE_UNSPECIFIED_H + +// this is non-standard header + +namespace std { + +#if CPPREFERENCE_STDVER >= 2011 +using CPPREFERENCE_UNSPECIFIED_TYPE = int; +constexpr int CPPREFERENCE_UNSPECIFIED_TYPE_VALUE = 0; +using CPPREFERENCE_SIMPLIFIED_TYPE = int; +#else +typedef int CPPREFERENCE_UNSPECIFIED_TYPE; +static const int CPPREFERENCE_UNSPECIFIED_TYPE_VALUE = 0; +typedef int CPPREFERENCE_SIMPLIFIED_TYPE; +#endif + +} // namespace std + +#endif // CPPREFERENCE_DETAIL_LOCALE_FWD_H diff --git a/headers/detail/locale_fwd b/headers/detail/locale_fwd new file mode 100644 index 0000000..e67b511 --- /dev/null +++ b/headers/detail/locale_fwd @@ -0,0 +1,27 @@ +/* Copyright (C) 2019 Povilas Kanapickas + + This file is part of cppreference-doc + + This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 + Unported License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative + Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 or + any later version published by the Free Software Foundation; with no + Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +*/ + +#ifndef CPPREFERENCE_DETAIL_LOCALE_FWD_H +#define CPPREFERENCE_DETAIL_LOCALE_FWD_H + +// this is non-standard header + +namespace std { + +class locale; + +} // namespace std + +#endif // CPPREFERENCE_DETAIL_LOCALE_FWD_H diff --git a/headers/detail/string_fwd b/headers/detail/string_fwd new file mode 100644 index 0000000..dedac09 --- /dev/null +++ b/headers/detail/string_fwd @@ -0,0 +1,42 @@ +/* Copyright (C) 2019 Povilas Kanapickas + + This file is part of cppreference-doc + + This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 + Unported License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative + Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 or + any later version published by the Free Software Foundation; with no + Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +*/ + +#ifndef CPPREFERENCE_DETAIL_STRING_FWD_H +#define CPPREFERENCE_DETAIL_STRING_FWD_H + +// this is non-standard header + +namespace std { + +template struct char_traits; + +template class allocator; + +template < + class CharT, + class Traits = std::char_traits, + class Allocator = std::allocator +> class basic_string; + +typedef basic_string string; +typedef basic_string wstring; +#if CPPREFERENCE_STDVER>= 2011 +typedef basic_string u16string; +typedef basic_string u32string; +#endif + +} // namespace std + +#endif // CPPREFERENCE_DETAIL_STRING_FWD_H diff --git a/headers/detail/string_view_fwd b/headers/detail/string_view_fwd new file mode 100644 index 0000000..477ef6f --- /dev/null +++ b/headers/detail/string_view_fwd @@ -0,0 +1,35 @@ +/* Copyright (C) 2019 Povilas Kanapickas + + This file is part of cppreference-doc + + This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 + Unported License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative + Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 or + any later version published by the Free Software Foundation; with no + Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +*/ + +#ifndef CPPREFERENCE_DETAIL_STRING_VIEW_FWD_H +#define CPPREFERENCE_DETAIL_STRING_VIEW_FWD_H + +// this is non-standard header + +namespace std { + +template struct char_traits; + +template> +class basic_string_view; + +using string_view = basic_string_view; +using wstring_view = basic_string_view; +using u16string_view = basic_string_view; +using u32string_view = basic_string_view; + +} // namespace std + +#endif // CPPREFERENCE_DETAIL_STRING_VIEW_FWD_H diff --git a/headers/exception b/headers/exception index 1481710..841df33 100644 --- a/headers/exception +++ b/headers/exception @@ -22,11 +22,14 @@ class exception { public: exception(); exception(const exception& other); + virtual ~exception(); exception& operator=(const exception& other); virtual const char* what() const; }; #if CPPREFERENCE_STDVER>= 2011 +typedef void* exception_ptr; // actually unspecified + class nested_exception { public: nested_exception(); @@ -50,9 +53,7 @@ void unexpected(); typedef void (*unexpected_handler)(); typedef void (*terminate_handler)(); -#if CPPREFERENCE_STDVER>= 2011 -typedef void* exception_ptr; // actually unspecified -#endif // CPPREFERENCE_STDVER>= 2011 + bool uncaught_exception(); #if CPPREFERENCE_STDVER>= 2017 diff --git a/headers/fstream b/headers/fstream index 13c31e1..4068529 100644 --- a/headers/fstream +++ b/headers/fstream @@ -16,20 +16,30 @@ #ifndef CPPREFERENCE_FSTREAM_H #define CPPREFERENCE_FSTREAM_H +#include +#include + namespace std { -template < +template< class CharT, - class Traits = std::char_traits - > class basic_filebuf : public std::basic_streambuf { + class Traits /* = std::char_traits */ +> class basic_filebuf : public basic_streambuf { + public: + typedef CharT char_type; + typedef Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + basic_filebuf(); #if CPPREFERENCE_STDVER>= 2011 - basic_filebuf(const std::basic_filebuf& rhs) = delete; - basic_filebuf(std::basic_filebuf&& rhs); - std::basic_filebuf& operator=(std::basic_filebuf&& rhs); - std::basic_filebuf& operator=(const std::basic_filebuf& rhs) = delete; - void swap(std::basic_filebuf& rhs); + basic_filebuf(const basic_filebuf& rhs) = delete; + basic_filebuf(basic_filebuf&& rhs); + basic_filebuf& operator=(basic_filebuf&& rhs); + basic_filebuf& operator=(const basic_filebuf& rhs) = delete; + void swap(basic_filebuf& rhs); #endif virtual ~basic_filebuf(); @@ -43,8 +53,8 @@ protected: virtual streamsize showmanyc(); virtual int_type underflow(); virtual int_type uflow(); - virtual int_type pbackfail(int_type c = Traits_type::eof()); - virtual int_type overflow(int_type c = Traits_type::eof()); + virtual int_type pbackfail(int_type c = traits_type::eof()); + virtual int_type overflow(int_type c = traits_type::eof()); virtual basic_streambuf* setbuf(char_type* s, streamsize n); virtual pos_type seekoff(off_type off, ios_base::seekdir dir, ios_base::openmode which = ios_base::in | ios_base::out); @@ -59,9 +69,15 @@ typedef basic_filebuf wfilebuf; template < class CharT, - class Traits = std::char_traits - > class basic_fstream : public std::basic_iostream { + class Traits /* = std::char_traits */ +> class basic_fstream : public std::basic_iostream { public: + typedef CharT char_type; + typedef Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; + basic_fstream(); explicit basic_fstream(const char* filename, ios_base::openmode mode = ios_base::in | ios_base::out); @@ -100,8 +116,8 @@ typedef basic_fstream wfstream; template < class CharT, - class Traits = std::char_traits - > class basic_ifstream : public std::basic_istream { + class Traits /* = std::char_traits */ +> class basic_ifstream : public std::basic_istream { public: basic_ifstream(); explicit basic_ifstream(const char* filename, @@ -141,8 +157,8 @@ typedef basic_ifstream wifstream; template < class CharT, - class Traits = std::char_traits - > class basic_ofstream : public std::basic_ostream { + class Traits /* = std::char_traits */ +> class basic_ofstream : public std::basic_ostream { public: basic_ofstream(); explicit basic_ofstream(const char* filename, diff --git a/headers/functional b/headers/functional index e3cbb5b..4963dfa 100644 --- a/headers/functional +++ b/headers/functional @@ -16,9 +16,21 @@ #ifndef CPPREFERENCE_FUNCTIONAL_H #define CPPREFERENCE_FUNCTIONAL_H +#include // for exception +#include // for allocator_arg_t +#include +#include + namespace std { #if CPPREFERENCE_STDVER >= 2011 + +template +class function; + +template +class reference_wrapper; + template class function { public: @@ -27,8 +39,11 @@ public: function(std::nullptr_t); function(const function& other); function(function&& other); + template - function(F f); + function(F f) { (void) f; } + +#if CPPREFERENCE_STDVER < 2017 template function(std::allocator_arg_t, const Alloc& alloc); @@ -46,6 +61,7 @@ public: template function(std::allocator_arg_t, const Alloc& alloc, F f); +#endif ~function(); @@ -66,7 +82,7 @@ public: explicit operator bool() const; - R operator()(ArgTypes... args) const; + R operator()(Args... args) const; const std::type_info& target_type() const; @@ -102,7 +118,7 @@ public: template std::function mem_fn(R T::* pm); -template +template std::function bind(F&& f, Args&& ... args); template @@ -110,7 +126,7 @@ std::function bind(F&& f, Args&& ... args); #if CPPREFERENCE_STDVER >= 2017 template -std::result_of_t < F&& (ArgTypes&& ...) > invoke(F&& f, ArgTypes&& ... args); +std::result_of_t invoke(F&& f, ArgTypes&&... args); #endif // SIMPLIFIED: the inherited type is simplified @@ -142,8 +158,8 @@ public: typedef void first_argument_type; typedef void second_argument_type; - reference_wrapper(T& x); - reference_wrapper(T&& x) = delete; + template + reference_wrapper(U&& x); reference_wrapper(const reference_wrapper& other); reference_wrapper& operator=(const reference_wrapper& other); @@ -176,7 +192,11 @@ void cref(const T&&) = delete; #endif // CPPREFERENCE_STDVER >= 2011 +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct plus { typedef T result_type; typedef T first_argument_type; @@ -184,7 +204,11 @@ struct plus { T operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct minus { typedef T result_type; typedef T first_argument_type; @@ -192,7 +216,11 @@ struct minus { T operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct multiplies { typedef T result_type; typedef T first_argument_type; @@ -200,7 +228,11 @@ struct multiplies { T operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct divides { typedef T result_type; typedef T first_argument_type; @@ -208,7 +240,11 @@ struct divides { T operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct modulus { typedef T result_type; typedef T first_argument_type; @@ -216,14 +252,22 @@ struct modulus { T operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct negate { typedef T result_type; typedef T argument_type; T operator()(const T& arg) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct equal_to { typedef bool result_type; typedef T first_argument_type; @@ -231,7 +275,11 @@ struct equal_to { bool operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct not_equal_to { typedef bool result_type; typedef T first_argument_type; @@ -239,7 +287,11 @@ struct not_equal_to { bool operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct greater { typedef bool result_type; typedef T first_argument_type; @@ -247,7 +299,11 @@ struct greater { bool operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct less { typedef bool result_type; typedef T first_argument_type; @@ -255,7 +311,11 @@ struct less { bool operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct greater_equal { typedef bool result_type; typedef T first_argument_type; @@ -263,7 +323,11 @@ struct greater_equal { bool operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct less_equal { typedef bool result_type; typedef T first_argument_type; @@ -271,7 +335,11 @@ struct less_equal { bool operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct logical_and { typedef bool result_type; typedef T first_argument_type; @@ -279,7 +347,11 @@ struct logical_and { bool operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct logical_or { typedef bool result_type; typedef T first_argument_type; @@ -287,14 +359,22 @@ struct logical_or { bool operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct logical_not { typedef bool result_type; typedef T argument_type; bool operator()(const T& arg) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct bit_and { typedef T result_type; typedef T first_argument_type; @@ -302,7 +382,11 @@ struct bit_and { T operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct bit_or { typedef T result_type; typedef T first_argument_type; @@ -310,7 +394,11 @@ struct bit_or { T operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct bit_xor { typedef T result_type; typedef T first_argument_type; @@ -318,13 +406,18 @@ struct bit_xor { T operator()(const T& lhs, const T& rhs) const; }; +#if CPPREFERENCE_STDVER >= 2014 template +#else +template +#endif struct bit_not { typedef T result_type; typedef T argument_type; T operator()(const T& arg) const; }; +#if CPPREFERENCE_STDVER <= 2020 template struct unary_negate { typedef bool result_type; @@ -341,7 +434,8 @@ struct binary_negate { typedef typename Predicate::second_argument_type second_argument_type; explicit binary_negate(const Predicate& pred); - result_type operator()(const T& lhs, const T& rhs) const; + result_type operator()(const first_argument_type& lhs, + const second_argument_type& rhs) const; }; template @@ -349,6 +443,7 @@ std::unary_negate not1(const Predicate& pred); template std::binary_negate not2(const Predicate& pred); +#endif #if CPPREFERENCE_STDVER >= 2011 template diff --git a/headers/future b/headers/future index c69d339..c74f6c7 100644 --- a/headers/future +++ b/headers/future @@ -17,10 +17,21 @@ #define CPPREFERENCE_FUTURE_H #if CPPREFERENCE_STDVER>= 2011 +#include +#include // for allocator_arg_t #include +#include // for error_code namespace std { +template +class future; + +template +class shared_future; + +enum class future_status; + template class promise { // SIMPLIFIED: removed R& and void specializations public: @@ -37,7 +48,7 @@ public: void swap(promise& other); - std::future get_future(); + future get_future(); void set_value(const R& value); void set_value(R&& value); @@ -54,8 +65,11 @@ public: template void swap(promise& lhs, promise& rhs); -template -class packaged_task { +template +class packaged_task; + +template +class packaged_task { public: packaged_task(); @@ -104,8 +118,8 @@ public: std::shared_future share(); T get(); // member only of generic specialization - T& get(); // member only of T& specialization - void get(); // member only of void specialization + // T& get(); // member only of T& specialization + // void get(); // member only of void specialization bool valid() const; @@ -132,8 +146,8 @@ public: shared_future& operator=(shared_future&& other); T get(); // member only of generic specialization - T& get(); // member only of T& specialization - void get(); // member only of void specialization + // T& get(); // member only of T& specialization + // void get(); // member only of void specialization bool valid() const; @@ -170,13 +184,33 @@ public: const std::error_code& code() const; }; +#if CPPREFERENCE_STDVER >= 2020 +template +[[nodiscard]] +std::future> + async(Function&& f, Args&& ... args); + +template +[[nodiscard]] +std::future> + async(std::launch policy, Function&& f, Args&& ... args); +#elif CPPREFERENCE_STDVER >= 2017 +template +std::future> + async(Function&& f, Args&& ... args); + +template +std::future> + async(std::launch policy, Function&& f, Args&& ... args); +#else template std::future::type> -async(Function&& f, Args&& ... args); + async(Function&& f, Args&& ... args); template std::future::type> -async(std::launch policy, Function&& f, Args&& ... args); + async(std::launch policy, Function&& f, Args&& ... args); +#endif const std::error_category& future_category(); diff --git a/headers/initializer_list b/headers/initializer_list index 41bc03e..30ce679 100644 --- a/headers/initializer_list +++ b/headers/initializer_list @@ -18,6 +18,8 @@ #if CPPREFERENCE_STDVER>= 2011 +#include // for size_t + namespace std { template @@ -31,15 +33,28 @@ public: typedef const T* iterator; typedef const T* const_iterator; +#if CPPREFERENCE_STDVER >= 2014 + constexpr initializer_list(); + + constexpr size_t size() const; + constexpr const T* begin() const; + constexpr const T* end() const; +#else initializer_list(); size_t size() const; const T* begin() const; const T* end() const; +#endif }; +#if CPPREFERENCE_STDVER >= 2014 +template constexpr const T* begin(initializer_list il); +template constexpr const T* end(initializer_list il); +#else template const T* begin(initializer_list il); template const T* end(initializer_list il); +#endif } // namespace std diff --git a/headers/iomanip b/headers/iomanip index 67ffa8a..a88e9cf 100644 --- a/headers/iomanip +++ b/headers/iomanip @@ -16,7 +16,8 @@ #ifndef CPPREFERENCE_IOMANIP_H #define CPPREFERENCE_IOMANIP_H -#include +#include +#include // for tm namespace std { diff --git a/headers/ios b/headers/ios index 1749696..615812d 100644 --- a/headers/ios +++ b/headers/ios @@ -19,13 +19,24 @@ #if CPPREFERENCE_STDVER>= 2011 #include #endif +#include +#include namespace std { +typedef int __impl_defined_type; +static const __impl_defined_type __impl_defined_value = 0; + typedef int streamoff; typedef int streamsize; template class fpos; +#if CPPREFERENCE_STDVER>= 2011 +enum class io_errc { + stream +}; +#endif + class ios_base { private: ios_base(const ios_base& other); @@ -51,47 +62,47 @@ public: class Init; - typedef int openmode; // actually impl-defined - static constexpr openmode app; - static constexpr openmode binary; - static constexpr openmode in; - static constexpr openmode out; - static constexpr openmode trunc; - static constexpr openmode ate; - - typedef int fmtflags; // actually impl-defined - static constexpr fmtflags dec; - static constexpr fmtflags oct; - static constexpr fmtflags hex; - static constexpr fmtflags basefield; - - static constexpr fmtflags left; - static constexpr fmtflags right; - static constexpr fmtflags internal; - static constexpr fmtflags adjustfield; - - static constexpr fmtflags scientific; - static constexpr fmtflags fixed; - static constexpr fmtflags floatfield; - - static constexpr fmtflags boolalpha; - static constexpr fmtflags showbase; - static constexpr fmtflags showpoint; - static constexpr fmtflags showpos; - static constexpr fmtflags skipws; - static constexpr fmtflags unitbuf; - static constexpr fmtflags uppercase; - - typedef int iostate; // actually impl-defined - static constexpr iostate goodbit; - static constexpr iostate badbit; - static constexpr iostate failbit; - static constexpr iostate eofbit; - - typedef int seekdir; // actually impl-defined - static constexpr seekdir beg; - static constexpr seekdir end; - static constexpr seekdir cur; + typedef __impl_defined_type openmode; + static constexpr openmode app = __impl_defined_value; + static constexpr openmode binary = __impl_defined_value; + static constexpr openmode in = __impl_defined_value; + static constexpr openmode out = __impl_defined_value; + static constexpr openmode trunc = __impl_defined_value; + static constexpr openmode ate = __impl_defined_value; + + typedef __impl_defined_type fmtflags; + static constexpr fmtflags dec = __impl_defined_value; + static constexpr fmtflags oct = __impl_defined_value; + static constexpr fmtflags hex = __impl_defined_value; + static constexpr fmtflags basefield = __impl_defined_value; + + static constexpr fmtflags left = __impl_defined_value; + static constexpr fmtflags right = __impl_defined_value; + static constexpr fmtflags internal = __impl_defined_value; + static constexpr fmtflags adjustfield = __impl_defined_value; + + static constexpr fmtflags scientific = __impl_defined_value; + static constexpr fmtflags fixed = __impl_defined_value; + static constexpr fmtflags floatfield = __impl_defined_value; + + static constexpr fmtflags boolalpha = __impl_defined_value; + static constexpr fmtflags showbase = __impl_defined_value; + static constexpr fmtflags showpoint = __impl_defined_value; + static constexpr fmtflags showpos = __impl_defined_value; + static constexpr fmtflags skipws = __impl_defined_value; + static constexpr fmtflags unitbuf = __impl_defined_value; + static constexpr fmtflags uppercase = __impl_defined_value; + + typedef __impl_defined_type iostate; + static constexpr iostate goodbit = __impl_defined_value; + static constexpr iostate badbit = __impl_defined_value; + static constexpr iostate failbit = __impl_defined_value; + static constexpr iostate eofbit = __impl_defined_value; + + typedef __impl_defined_type seekdir; + static constexpr seekdir beg = __impl_defined_value; + static constexpr seekdir end = __impl_defined_value; + static constexpr seekdir cur = __impl_defined_value; enum event { erase_event, @@ -124,7 +135,7 @@ public: }; template> + class Traits /* = std::char_traits */> class basic_ios : public ios_base { public: typedef CharT char_type; @@ -171,9 +182,6 @@ public: std::basic_ostream* tie() const; std::basic_ostream* tie(std::basic_ostream* str); - char narrow(char_type c, char dfault) const; - char_type widen(char c) const; - protected: basic_ios(); void init(std::basic_streambuf* sb); @@ -221,10 +229,6 @@ ios_base& hexfloat(ios_base& str); ios_base& defaultfloat(ios_base& str); #if CPPREFERENCE_STDVER>= 2011 -enum class io_errc { - stream -}; - std::error_code make_error_code(std::io_errc e); std::error_condition make_error_condition(std::io_errc e); const std::error_category& iostream_category(); diff --git a/headers/iosfwd b/headers/iosfwd index a22df58..1f7c14b 100644 --- a/headers/iosfwd +++ b/headers/iosfwd @@ -16,12 +16,16 @@ #ifndef CPPREFERENCE_IOSFWD_H #define CPPREFERENCE_IOSFWD_H +#include // for mbstate_t + namespace std { template struct char_traits; template class allocator; +typedef int streamoff; + class ios_base; template> class basic_ios; @@ -80,9 +84,10 @@ typedef basic_istringstream wistringstream; typedef basic_ostringstream wostringstream; typedef basic_stringstream wstringstream; -template class fpos; -typedef fpos::state_type> streampos; -typedef fpos::state_type> wstreampos; +template class fpos; + // state type in below typedefs is actually impl-defined type char_traits::state_type +typedef fpos streampos; +typedef fpos wstreampos; } // namespace std diff --git a/headers/istream b/headers/istream index 8fb7ecc..36762cf 100644 --- a/headers/istream +++ b/headers/istream @@ -16,13 +16,22 @@ #ifndef CPPREFERENCE_ISTREAM_H #define CPPREFERENCE_ISTREAM_H +#include +#include + namespace std { template < class CharT, - class Traits = std::char_traits + class Traits /* = std::char_traits */ > class basic_istream : virtual public std::basic_ios { public: + typedef CharT char_type; + typedef Traits traits_type; + typedef typename Traits::int_type int_type; + typedef typename Traits::pos_type pos_type; + typedef typename Traits::off_type off_type; + explicit basic_istream(std::basic_streambuf* sb); virtual ~basic_istream(); @@ -41,21 +50,17 @@ public: basic_istream& operator>>(long double& value); basic_istream& operator>>(bool& value); basic_istream& operator>>(void*& value); - basic_istream& operator>>(basic_istream& st, - std::ios_base & (*func)(std::ios_base&)); - basic_istream& operator>>(basic_istream& st, - std::basic_ios& (*func)(std::basic_ios&)); - basic_istream& operator>>(basic_istream& st, - std::basic_istream & (*func)(std::basic_istream&)); - basic_istream& operator>>(basic_istream& st, - std::basic_streambuf* sb); + basic_istream& operator>>(std::ios_base & (*func)(std::ios_base&)); + basic_istream& operator>>(std::basic_ios& (*func)(std::basic_ios&)); + basic_istream& operator>>(basic_istream & (*func)(basic_istream&)); + basic_istream& operator>>(std::basic_streambuf* sb); int_type get(); basic_istream& get(char_type& ch); basic_istream& get(char_type* s, std::streamsize count); basic_istream& get(char_type* s, std::streamsize count, char_type delim); - basic_istream& get(basic_streambuf& strbuf); - basic_istream& get(basic_streambuf& strbuf, char_type delim); + basic_istream& get(basic_streambuf& strbuf); + basic_istream& get(basic_streambuf& strbuf, char_type delim); int_type peek(); basic_istream& unget(); @@ -100,8 +105,8 @@ extern wistream wcin; template < class CharT, - class Traits = std::char_traits - > class basic_iostream : public std::basic_istream, + class Traits /* = std::char_traits */ +> class basic_iostream : public std::basic_istream, public basic_ostream { public: explicit basic_iostream(std::basic_streambuf* sb); diff --git a/headers/iterator b/headers/iterator index 6ca93f0..6d7d5dc 100644 --- a/headers/iterator +++ b/headers/iterator @@ -17,9 +17,17 @@ #define CPPREFERENCE_ITERATOR_H #include // for size_t, ptrdiff_t +#include // char_traits +#include namespace std { +struct input_iterator_tag { }; +struct output_iterator_tag { }; +struct forward_iterator_tag : public input_iterator_tag { }; +struct bidirectional_iterator_tag : public forward_iterator_tag { }; +struct random_access_iterator_tag : public bidirectional_iterator_tag { }; + // SIMPLIFIED: template specializations are not supported, so the typedefs use // the T* specialization template @@ -39,11 +47,14 @@ struct iterator_traits { #endif }; -struct input_iterator_tag { }; -struct output_iterator_tag { }; -struct forward_iterator_tag : public input_iterator_tag { }; -struct bidirectional_iterator_tag : public forward_iterator_tag { }; -struct random_access_iterator_tag : public bidirectional_iterator_tag { }; +template +struct iterator_traits { + typedef ptrdiff_t difference_type; + typedef T value_type; + typedef T* pointer; + typedef T& reference; + typedef random_access_iterator_tag iterator_category; +}; template @@ -137,11 +148,14 @@ class move_iterator { public: typedef Iterator iterator_type; typedef Iterator pointer; - typedef value_type&& reference; #if CPPREFERENCE_SIMPLIFY_TYPEDEFS + typedef typename Iterator::value_type value_type; + typedef value_type&& reference; typedef typename ptrdiff_t difference_type; typedef typename Iterator::iterator_category iterator_category; #else + typedef typename iterator_traits::value_type value_type; + typedef value_type&& reference; typedef typename iterator_traits::difference_type difference_type; typedef typename iterator_traits::iterator_category iterator_category; #endif @@ -290,7 +304,7 @@ public: insert_iterator& operator++(int); protected: Container* container; - Container::iterator iter; + typename Container::iterator iter; }; template +template bool operator==(const istream_iterator& lhs, const istream_iterator& rhs); -template +template bool operator!=(const istream_iterator& lhs, const istream_iterator& rhs); @@ -360,12 +374,12 @@ template bool operator==(const ostream_iterator& lhs, const ostream_iterator& rhs); -template +template bool operator!=(const ostream_iterator& lhs, const ostream_iterator& rhs); -template > +template*/> class istreambuf_iterator { // SIMPLIFIED: does not inherit iterator public: typedef CharT char_type; @@ -378,10 +392,10 @@ public: typedef std::basic_streambuf streambuf_type; typedef std::basic_istream istream_type; - typedef T value_type; - typedef Distance difference_type; - typedef const T* pointer; - typedef const T& reference; + typedef CharT value_type; + typedef typename Traits::off_type difference_type; + typedef const CharT* pointer; // actually unspecified + typedef const CharT& reference; typedef input_iterator_tag iterator_category; istreambuf_iterator(); @@ -408,7 +422,7 @@ bool operator!=(const istreambuf_iterator& lhs, const istreambuf_iterator& rhs); template > + class Traits /* = std::char_traits*/ > class ostreambuf_iterator { // SIMPLIFIED: does not inherit iterator public: typedef CharT char_type; @@ -432,15 +446,21 @@ public: bool failed() const; }; -#if CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2014 +#if CPPREFERENCE_STDVER >= 2017 template -std::move_iterator make_move_iterator(const Iterator& i); +constexpr std::move_iterator make_move_iterator(Iterator i); + +template +constexpr std::reverse_iterator make_reverse_iterator(Iterator i); #elif CPPREFERENCE_STDVER >= 2014 template std::move_iterator make_move_iterator(Iterator i); template std::reverse_iterator make_reverse_iterator(Iterator i); +#elif CPPREFERENCE_STDVER >= 2011 +template +std::move_iterator make_move_iterator(const Iterator& i); #endif template @@ -467,28 +487,51 @@ ForwardIt next(ForwardIt it, template BidirIt prev(BidirIt it, typename std::iterator_traits::difference_type n = 1); +#endif + +#if CPPREFERENCE_STDVER >= 2017 +template +constexpr auto begin(C& c) -> decltype(c.begin()); +template +constexpr auto begin(const C& c) -> decltype(c.begin()); + +template +constexpr auto end(C& c) -> decltype(c.end()); + +template +constexpr auto end(const C& c) -> decltype(c.end()); + +#elif CPPREFERENCE_STDVER >= 2011 template auto begin(C& c) -> decltype(c.begin()); template auto begin(const C& c) -> decltype(c.begin()); -template -T* begin(T(&array)[N]); - template auto end(C& c) -> decltype(c.end()); template auto end(const C& c) -> decltype(c.end()); +#endif +#if CPPREFERENCE_STDVER >= 2014 template -T* end(T(&array)[N]); +constexpr T* begin(T(&array)[N]); +template +constexpr T* end(T(&array)[N]); + +#elif CPPREFERENCE_STDVER >= 2011 +template +T* begin(T(&array)[N]); + +template +T* end(T(&array)[N]); #endif -#if CPPREFERENCE_STDVER >= 2014 +#if CPPREFERENCE_STDVER >= 2014 template constexpr auto cbegin(const C& c) -> decltype(std::begin(c)); @@ -504,6 +547,9 @@ auto rbegin(const C& c) -> decltype(c.rbegin()); template reverse_iterator rbegin(T(&array)[N]); +template +reverse_iterator rbegin(std::initializer_list il); + template auto crbegin(const C& c) -> decltype(std::rbegin(c)); @@ -516,6 +562,9 @@ auto rend(const C& c) -> decltype(c.rend()); template reverse_iterator rend(T(&array)[N]); +template +reverse_iterator rend(std::initializer_list il); + template auto crend(const C& c) -> decltype(std::rend(c)); diff --git a/headers/limits b/headers/limits index 9611e7f..ec3fecb 100644 --- a/headers/limits +++ b/headers/limits @@ -69,39 +69,39 @@ public: static T signaling_NaN(); static T denorm_min(); #else - static constexpr bool is_specialized; - static constexpr bool is_signed; - static constexpr bool is_integer; - static constexpr bool is_exact; - static constexpr bool has_infinity; - static constexpr bool has_quiet_NaN; - static constexpr bool has_signaling_NaN; - static constexpr float_denorm_style has_denorm; - static constexpr bool has_denorm_loss; - static constexpr float_round_style round_style; - static constexpr bool is_iec559; - static constexpr bool is_bounded; - static constexpr bool is_modulo; - static constexpr int digits; - static constexpr int digits10; - static constexpr int max_digits10; // new in C++11 - static constexpr int radix; - static constexpr int min_exponent; - static constexpr int min_exponent10; - static constexpr int max_exponent; - static constexpr int max_exponent10; - static constexpr bool traps; - static constexpr bool tinyness_before; + static constexpr bool is_specialized = false; + static constexpr bool is_signed = false; + static constexpr bool is_integer = false; + static constexpr bool is_exact = false; + static constexpr bool has_infinity = false; + static constexpr bool has_quiet_NaN = false; + static constexpr bool has_signaling_NaN = false; + static constexpr float_denorm_style has_denorm = denorm_indeterminate; + static constexpr bool has_denorm_loss = false; + static constexpr float_round_style round_style = round_indeterminate; + static constexpr bool is_iec559 = false; + static constexpr bool is_bounded = false; + static constexpr bool is_modulo = false; + static constexpr int digits = 0; + static constexpr int digits10 = 0; + static constexpr int max_digits10 = 0; // new in C++11 + static constexpr int radix = 0; + static constexpr int min_exponent = 0; + static constexpr int min_exponent10 = 0; + static constexpr int max_exponent = 0; + static constexpr int max_exponent10 = 0; + static constexpr bool traps = false; + static constexpr bool tinyness_before = false; - static constexpr T min(); - static constexpr T lowest(); - static constexpr T max(); - static constexpr T epsilon(); - static constexpr T round_error(); - static constexpr T infinity(); - static constexpr T quiet_NaN(); - static constexpr T signaling_NaN(); - static constexpr T denorm_min(); + static constexpr T min() { return {}; } + static constexpr T lowest() { return {}; } + static constexpr T max() { return {}; } + static constexpr T epsilon() { return {}; } + static constexpr T round_error() { return {}; } + static constexpr T infinity() { return {}; } + static constexpr T quiet_NaN() { return {}; } + static constexpr T signaling_NaN() { return {}; } + static constexpr T denorm_min() { return {}; } #endif }; diff --git a/headers/list b/headers/list index 1b8806c..6db613a 100644 --- a/headers/list +++ b/headers/list @@ -70,6 +70,7 @@ public: list(size_type count, const T& value, const Allocator& alloc = Allocator()); +#endif #if CPPREFERENCE_STDVER <2014 explicit list(size_type n); diff --git a/headers/locale b/headers/locale index 91757a1..a938d00 100644 --- a/headers/locale +++ b/headers/locale @@ -16,7 +16,10 @@ #ifndef CPPREFERENCE_LOCALE_H #define CPPREFERENCE_LOCALE_H +#include // for tm +#include // for ios_base #include // for std::allocator +#include namespace std { @@ -82,12 +85,18 @@ template > class wstring_convert { public: + + using byte_string = basic_string, Byte_alloc>; + using wide_string = basic_string, Wide_alloc>; + using state_type = typename Codecvt::state_type; + using int_type = typename wide_string::traits_type::int_type; + explicit wstring_convert(Codecvt* pcvt = new Codecvt); wstring_convert(Codecvt* pcvt, state_type state); explicit wstring_convert(const byte_string& byte_err, const wide_string& wide_err = wide_string()); #if CPPREFERENCE_STDVER >= 2014 - wstring_convert(const std::wstring_convert&) = delete; + wstring_convert(const wstring_convert&) = delete; #endif ~wstring_convert(); @@ -114,11 +123,18 @@ class wbuffer_convert : public std::basic_streambuf { public: typedef typename Codecvt::state_type state_type; +#if CPPREFERENCE_STDVER >= 2011 + explicit wbuffer_convert(std::streambuf* bytebuf = nullptr, + Codecvt* pcvt = new Codecvt, + state_type state = state_type()); +#else explicit wbuffer_convert(std::streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, state_type state = state_type()); +#endif + #if CPPREFERENCE_STDVER >= 2014 - wbuffer_convert(const std::wbuffer_convert&) = delete; + wbuffer_convert(const wbuffer_convert&) = delete; #endif ~wbuffer_convert(); @@ -235,54 +251,57 @@ public: explicit codecvt(std::size_t refs = 0); - result out(StateT& state, + result out(State& state, const InternT* from, const InternT* from_end, const InternT*& from_next, ExternT* to, ExternT* to_end, ExternT*& to_next) const; - result in(stateT& state, - const externT* from, - const externT* from_end, - const externT*& from_next, - internT* to, - internT* to_end, - internT*& to_next) const; - result unshift(StateT& state, + + result in(State& state, + const ExternT* from, + const ExternT* from_end, + const ExternT*& from_next, + InternT* to, + InternT* to_end, + InternT*& to_next) const; + + result unshift(State& state, ExternT* to, ExternT* to_end, ExternT*& to_next) const; + int encoding() const; bool always_noconv() const; - int length(StateT& state, + int length(State& state, const ExternT* from, const ExternT* from_end, std::size_t max) const; int max_length() const; protected: - virtual result do_out(StateT& state, + virtual result do_out(State& state, const InternT* from, const InternT* from_end, const InternT*& from_next, ExternT* to, ExternT* to_end, ExternT*& to_next) const; - virtual result do_in(stateT& state, - const externT* from, - const externT* from_end, - const externT*& from_next, - internT* to, - internT* to_end, - internT*& to_next) const; - virtual result do_unshift(StateT& state, + virtual result do_in(State& state, + const ExternT* from, + const ExternT* from_end, + const ExternT*& from_next, + InternT* to, + InternT* to_end, + InternT*& to_next) const; + virtual result do_unshift(State& state, ExternT* to, ExternT* to_end, ExternT*& to_next) const; virtual int do_encoding() const; virtual bool do_always_noconv() const; - virtual int do_length(StateT& state, + virtual int do_length(State& state, const ExternT* from, const ExternT* from_end, std::size_t max) const; @@ -353,8 +372,8 @@ public: std::ios_base::iostate& err, std::tm* t) const; iter_type get_monthname(iter_type beg, iter_type end, std::ios_base& str, std::ios_base::iostate& err, std::tm* t) const; - iter_type do_get_year(iter_type s, iter_type end, std::ios_base& str, - std::ios_base::iostate& err, std::tm* t) const; + iter_type get_year(iter_type s, iter_type end, std::ios_base& str, + std::ios_base::iostate& err, std::tm* t) const; #if CPPREFERENCE_STDVER >= 2011 iter_type get(iter_type beg, iter_type end, std::ios_base& str, @@ -364,8 +383,8 @@ public: protected: virtual dateorder do_date_order() const; - virtual iter_type get_time(iter_type beg, iter_type end, std::ios_base& str, - std::ios_base::iostate& err, std::tm* t) const; + virtual iter_type do_get_time(iter_type beg, iter_type end, std::ios_base& str, + std::ios_base::iostate& err, std::tm* t) const; virtual iter_type do_get_date(iter_type beg, iter_type end, std::ios_base& str, std::ios_base::iostate& err, std::tm* t) const; virtual iter_type do_get_weekday(iter_type beg, iter_type end, std::ios_base& str, diff --git a/headers/map b/headers/map index b326f29..8f8d2cb 100644 --- a/headers/map +++ b/headers/map @@ -20,13 +20,14 @@ #include #endif -namespace std { - #include // for size_t, ptrdiff_t #include // for std::reverse_iterator +#include // for less #include // for std::allocator #include // for std::pair +namespace std { + template < class Key, class T, @@ -38,7 +39,6 @@ public: typedef T mapped_type; typedef pair value_type; typedef Compare key_compare; - typedef Compare value_compare; typedef Allocator allocator_type; typedef size_t size_type; // actual type unspecified typedef ptrdiff_t difference_type; // actual type not specified @@ -68,8 +68,8 @@ public: class value_compare { public: typedef bool result_type; - typedef first_argument_type value_type; - typedef second_argument_type value_type; + typedef value_type first_argument_type ; + typedef value_type second_argument_type; bool operator()(const value_type& lhs, const value_type& rhs) const; protected: @@ -77,14 +77,9 @@ public: Compare comp; }; -#if CPPREFERENCE_STDVER <2014 - explicit map(const Compare& comp = Compare(), - const Allocator& alloc = Allocator()); -#else map(); explicit map(const Compare& comp, const Allocator& alloc = Allocator()); -#endif #if CPPREFERENCE_STDVER>= 2011 explicit map(const Allocator& alloc); @@ -295,7 +290,6 @@ public: typedef T mapped_type; typedef pair value_type; typedef Compare key_compare; - typedef Compare value_compare; typedef Allocator allocator_type; typedef size_t size_type; // actual type unspecified typedef ptrdiff_t difference_type; // actual type not specified @@ -325,8 +319,8 @@ public: class value_compare { public: typedef bool result_type; - typedef first_argument_type value_type; - typedef second_argument_type value_type; + typedef value_type first_argument_type; + typedef value_type second_argument_type; bool operator()(const value_type& lhs, const value_type& rhs) const; protected: @@ -334,14 +328,9 @@ public: Compare comp; }; -#if CPPREFERENCE_STDVER <2014 - explicit multimap(const Compare& comp = Compare(), - const Allocator& alloc = Allocator()); -#else multimap(); explicit multimap(const Compare& comp, const Allocator& alloc = Allocator()); -#endif #if CPPREFERENCE_STDVER>= 2011 explicit multimap(const Allocator& alloc); diff --git a/headers/memory b/headers/memory index 9a74fa7..a578e19 100644 --- a/headers/memory +++ b/headers/memory @@ -16,11 +16,18 @@ #ifndef CPPREFERENCE_MEMORY_H #define CPPREFERENCE_MEMORY_H +#include // for exception +#include // for basic_ostream +#include // for output_iterator_tag #include // for std::pair namespace std { +template class auto_ptr; + #if CPPREFERENCE_STDVER>= 2011 +template class weak_ptr; + template struct default_delete { constexpr default_delete() = default; @@ -42,11 +49,10 @@ template < public: // SIMPLIFIED: the array specialization is omitted -#if CPPREFERENCE_SIMPLIFY_TYPEDEFS + // SIMPLIFIED: pointer would be std::remove_reference::type::pointer if that type + // exists, but our default_delete does not have that member type typedef T* pointer; -#else - typedef typename std::remove_reference::type::pointer pointer; -#endif + typedef T element_type; typedef Deleter deleter_type; @@ -83,7 +89,7 @@ public: explicit operator bool() const; T& operator*() const; // SIMPLIFIED - pointer operator->(); + pointer operator->() const; // only in array versions T& operator[](size_t i) const; @@ -102,7 +108,6 @@ unique_ptr make_unique(Args&& ... args); #endif - template class shared_ptr { public: typedef T element_type; @@ -327,12 +332,15 @@ void swap(weak_ptr& lhs, weak_ptr& rhs); #endif // CPPREFERENCE_STDVER>= 2011 +template +class auto_ptr_ref; + template class auto_ptr { public: typedef T element_type; - explicit auto_ptr(X* p = 0); + explicit auto_ptr(T* p = 0); auto_ptr(auto_ptr& r); @@ -349,7 +357,8 @@ public: template auto_ptr& operator=(auto_ptr& r); - auto_ptr& operator=(auto_ptr_ref m); + template + auto_ptr& operator=(auto_ptr_ref m); template operator auto_ptr_ref(); @@ -408,7 +417,6 @@ public: template struct allocator { - // SIMPLIFIED: allocator specialization is not provided typedef T value_type; typedef T* pointer; typedef const T* const_pointer; @@ -434,7 +442,12 @@ struct allocator { pointer address(reference x) const; const_pointer address(const_reference x) const; - pointer allocate(size_type n, std::allocator::const_pointer hint = 0); +#if CPPREFERENCE_STDVER >= 2011 + pointer allocate(size_type n, void* hint = nullptr); +#else + pointer allocate(size_type n, void* hint = 0); +#endif + void deallocate(pointer p, size_type n); size_type max_size() const; @@ -449,6 +462,19 @@ struct allocator { void destroy(U* p); }; +template<> +struct allocator { + typedef void value_type; + typedef void* pointer; + typedef const void* const_pointer; +#if CPPREFERENCE_STDVER>= 2014 + typedef true_type propagate_on_container_move_assignment; +#endif + template struct rebind { + typedef allocator other; + }; +}; + template bool operator==(const allocator& lhs, const allocator& rhs); @@ -475,10 +501,10 @@ struct allocator_traits { // SIMPLIFIED: actually is alias template and uses Alloc::rebind template - class rebind_alloc : public Alloc {}; + class rebind_alloc : public Alloc {}; // SIMPLIFIED: actually is alias template template - class rebind_traits : public allocator_traits> {}; + class rebind_traits : public allocator_traits> {}; static pointer allocate(Alloc& a, size_type n); static pointer allocate(Alloc& a, size_type n, const_void_pointer hint); @@ -510,7 +536,7 @@ enum class pointer_safety { template struct pointer_traits { typedef Ptr pointer; - typedef void element_type; // SIMPLIFIED + typedef int element_type; // SIMPLIFIED typedef ptrdiff_t difference_type; template diff --git a/headers/mutex b/headers/mutex index 170a73b..d38a68d 100644 --- a/headers/mutex +++ b/headers/mutex @@ -18,6 +18,8 @@ #if CPPREFERENCE_STDVER>= 2011 +#include + namespace std { struct defer_lock_t { }; diff --git a/headers/new b/headers/new index 9fe03e9..08970b7 100644 --- a/headers/new +++ b/headers/new @@ -16,6 +16,8 @@ #ifndef CPPREFERENCE_NEW_H #define CPPREFERENCE_NEW_H +#include + namespace std { /* SIMPLIFIED: these are implicitly declared even if is not included. @@ -65,7 +67,7 @@ std::new_handler get_new_handler(); #endif std::new_handler set_new_handler(std::new_handler new_p); -class bad_alloc : public std::exception { +class bad_alloc : public exception { public: bad_alloc(); bad_alloc& operator=(const bad_alloc& other); diff --git a/headers/optional b/headers/optional new file mode 100644 index 0000000..c243716 --- /dev/null +++ b/headers/optional @@ -0,0 +1,232 @@ +/* Copyright (C) 2019 Povilas Kanapickas + + This file is part of cppreference-doc + + This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 + Unported License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative + Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 or + any later version published by the Free Software Foundation; with no + Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +*/ + +#ifndef CPPREFERENCE_OPTIONAL_H +#define CPPREFERENCE_OPTIONAL_H + +#if CPPREFERENCE_STDVER >= 2017 + +#include // hash +#include // in_place_t, ... +#include // decay_t +#include // exception + +namespace std { + +struct nullopt_t {}; + +inline constexpr nullopt_t nullopt; + +class bad_optional_access : public exception { +public: + ~bad_optional_access() override; + const char * what() const override; +}; + +template +class optional { +public: + using value_type = T; + + constexpr optional(); + constexpr optional(std::nullopt_t); + constexpr optional(const optional& other); + + constexpr optional(optional&& other); + + template + optional(const optional& other); + + template + optional(optional&& other); + + template + constexpr explicit optional(in_place_t, Args&&... args); + + template + constexpr explicit optional(in_place_t, + initializer_list ilist, + Args&&... args); + + template + constexpr optional(U&& value); + + ~optional(); + + optional& operator=(std::nullopt_t); + + constexpr optional& operator=(const optional& other); + + constexpr optional& operator=(optional&& other); + + template + optional& operator=(U&& value); + + template + optional& operator=(const optional& other); + + template + optional& operator=(optional&& other); + + constexpr const T* operator->() const; + + constexpr T* operator->(); + + constexpr const T& operator*() const&; + + constexpr T& operator*() &; + + constexpr const T&& operator*() const&&; + + constexpr T&& operator*() &&; + + constexpr explicit operator bool() const; + + constexpr bool has_value() const; + + constexpr T& value() &; + constexpr const T & value() const &; + + constexpr T&& value() &&; + constexpr const T&& value() const &&; + + template< class U > + constexpr T value_or(U&& default_value) const&; + + template< class U > + constexpr T value_or(U&& default_value) &&; + + void swap(optional& other); + + void reset(); + + template + T& emplace(Args&&... args); + + template + T& emplace(initializer_list ilist, Args&&... args); +}; + +template +constexpr bool operator==(const optional& lhs, const optional& rhs); + +template +constexpr bool operator!=(const optional& lhs, const optional& rhs); + +template +constexpr bool operator<(const optional& lhs, const optional& rhs); + +template +constexpr bool operator<=(const optional& lhs, const optional& rhs); + +template +constexpr bool operator>(const optional& lhs, const optional& rhs); + +template +constexpr bool operator>=(const optional& lhs, const optional& rhs); + +template +constexpr bool operator==(const optional& opt, nullopt_t); + +template +constexpr bool operator==(nullopt_t, const optional& opt); + +template +constexpr bool operator!=(const optional& opt, nullopt_t); + +template +constexpr bool operator!=(nullopt_t, const optional& opt); + +template +constexpr bool operator<(const optional& opt, nullopt_t); + +template +constexpr bool operator<(nullopt_t, const optional& opt); + +template +constexpr bool operator<=(const optional& opt, nullopt_t); + +template +constexpr bool operator<=(nullopt_t, const optional& opt); + +template +constexpr bool operator>(const optional& opt, nullopt_t); + +template +constexpr bool operator>(nullopt_t, const optional& opt); + +template +constexpr bool operator>=(const optional& opt, nullopt_t); + +template +constexpr bool operator>=(nullopt_t, const optional& opt); + + +template +constexpr bool operator==(const optional& opt, const U& value); + +template +constexpr bool operator==(const T& value, const optional& opt); + +template +constexpr bool operator!=(const optional& opt, const U& value); + +template +constexpr bool operator!=(const T& value, const optional& opt); + +template +constexpr bool operator<(const optional& opt, const U& value); + +template +constexpr bool operator<(const T& value, const optional& opt); + +template +constexpr bool operator<=(const optional& opt, const U& value); + +template +constexpr bool operator<=(const T& value, const optional& opt); + +template +constexpr bool operator>(const optional& opt, const U& value); + +template +constexpr bool operator>(const T& value, const optional& opt); + +template +constexpr bool operator>=(const optional& opt, const U& value); + +template +constexpr bool operator>=(const T& value, const optional& opt); + +template +constexpr optional> make_optional(T&& value); + +template +constexpr optional make_optional(Args&&... args); + +template +constexpr optional make_optional(initializer_list il, Args&&... args); + +template +void swap(optional& lhs, optional& rhs); + +template +struct hash> {}; + + +} // namespace std + +#endif // CPPREFERENCE_STDVER >= 2017 +#endif // CPPREFERENCE_OPTIONAL_H diff --git a/headers/ostream b/headers/ostream index 690caae..0e79325 100644 --- a/headers/ostream +++ b/headers/ostream @@ -16,13 +16,22 @@ #ifndef CPPREFERENCE_OSTREAM_H #define CPPREFERENCE_OSTREAM_H +#include +#include + namespace std { template < class CharT, - class Traits = std::char_traits - > class basic_ostream : virtual public std::basic_ios { + class Traits /* = std::char_traits */ +> class basic_ostream : virtual public std::basic_ios { public: + typedef CharT char_type; + typedef Traits traits_type; + typedef typename Traits::int_type int_type; + typedef typename Traits::pos_type pos_type; + typedef typename Traits::off_type off_type; + explicit basic_ostream(std::basic_streambuf* sb); virtual ~basic_ostream(); diff --git a/headers/progress b/headers/progress deleted file mode 100644 index c0f4019..0000000 --- a/headers/progress +++ /dev/null @@ -1,11 +0,0 @@ - -done: -algorithm -array -atomic -cassert -cfenv -ciso646 -deque -list -vector diff --git a/headers/queue b/headers/queue index 704cc75..d24bce5 100644 --- a/headers/queue +++ b/headers/queue @@ -19,6 +19,9 @@ #if CPPREFERENCE_STDVER>= 2011 #include #endif +#include +#include +#include // less namespace std { diff --git a/headers/random b/headers/random index 97c9858..f405d19 100644 --- a/headers/random +++ b/headers/random @@ -18,6 +18,10 @@ #if CPPREFERENCE_STDVER >= 2011 #include +#include +#include // for numeric_limits +#include // for basic_iostream, basic_ostream +#include namespace std { @@ -86,24 +90,25 @@ template < > class mersenne_twister_engine { public: typedef UIntType result_type; - static constexpr size_t word_size; - static constexpr size_t state_size; - static constexpr size_t shift_size; - static constexpr size_t mask_bits; - static constexpr UIntType xor_mask; - static constexpr size_t tampering_u; - static constexpr UIntType tampering_d; - static constexpr size_t tampering_s; - static constexpr UIntType tampering_b; - static constexpr size_t tampering_t; - static constexpr UIntType tampering_c; - static constexpr size_t tampering_l; - static constexpr UIntType initialization_multiplier; + static constexpr size_t word_size = 0; + static constexpr size_t state_size = 0; + static constexpr size_t shift_size = 0; + static constexpr size_t mask_bits = 0; + static constexpr UIntType xor_mask = 0; + static constexpr size_t tampering_u = 0; + static constexpr UIntType tampering_d = 0; + static constexpr size_t tampering_s = 0; + static constexpr UIntType tampering_b = 0; + static constexpr size_t tampering_t = 0; + static constexpr UIntType tampering_c = 0; + static constexpr size_t tampering_l = 0; + static constexpr UIntType initialization_multiplier = 0; + static constexpr UIntType default_seed = 0; explicit mersenne_twister_engine(result_type value = default_seed); template - explicit mersenne_twister_engine(Sseq& s); + explicit mersenne_twister_engine(Sseq& seed); mersenne_twister_engine(const mersenne_twister_engine& other); @@ -176,15 +181,15 @@ template < > class subtract_with_carry_engine { public: typedef UIntType result_type; - static constexpr size_t word_size; - static constexpr size_t short_lag; - static constexpr size_t long_lag; - static constexpr UIntType default_seed; + static constexpr size_t word_size = 0; + static constexpr size_t short_lag = 0; + static constexpr size_t long_lag = 0; + static constexpr UIntType default_seed = 0; explicit subtract_with_carry_engine(result_type value = default_seed); template - explicit subtract_with_carry_engine(Sseq& s); + explicit subtract_with_carry_engine(Sseq& seed); subtract_with_carry_engine(const subtract_with_carry_engine& other); @@ -222,7 +227,7 @@ operator>>(std::basic_istream& ist, subtract_with_carry_engine& e); typedef std::subtract_with_carry_engine ranlux24_base; -typedef std::subtract_with_carry_engine ranlex48_base; +typedef std::subtract_with_carry_engine ranlux48_base; template < class Engine, @@ -230,8 +235,8 @@ template < > class discard_block_engine { public: typedef typename Engine::result_type result_type; - static constexpr size_t block_size; - static constexpr size_t used_size; + static constexpr size_t block_size = 0; + static constexpr size_t used_size = 0; discard_block_engine(); @@ -320,7 +325,7 @@ template < > class shuffle_order_engine { public: typedef typename Engine::result_type result_type; - static constexpr size_t table_size; + static constexpr size_t table_size = 0; shuffle_order_engine(); @@ -378,7 +383,7 @@ public: typedef void* param_type; // TODO explicit uniform_int_distribution(IntType a = 0, - IntType b = std::numeric_limits::max()); + IntType b = numeric_limits::max()); explicit uniform_int_distribution(const param_type& params); void reset(); diff --git a/headers/ratio b/headers/ratio index 4f754d4..a736717 100644 --- a/headers/ratio +++ b/headers/ratio @@ -27,12 +27,13 @@ template type; - static constexpr intmax_t num; - static constexpr intmax_t den; + static constexpr intmax_t num = Num; + static constexpr intmax_t den = Denom; }; -typedef ratio<1, 1000000000000000000000000> yocto; -typedef ratio<1, 1000000000000000000000> zepto; +// only defined if intmax_t can represent the denominator +// typedef ratio<1, 1000000000000000000000000> yocto; +// typedef ratio<1, 1000000000000000000000> zepto; typedef ratio<1, 1000000000000000000> atto; typedef ratio<1, 1000000000000000> femto; typedef ratio<1, 1000000000000> pico; @@ -49,8 +50,9 @@ typedef ratio< 1000000000, 1> giga; typedef ratio< 1000000000000, 1> tera; typedef ratio< 1000000000000000, 1> peta; typedef ratio< 1000000000000000000, 1> exa; -typedef ratio< 1000000000000000000000, 1> zetta; -typedef ratio<1000000000000000000000000, 1> yotta; +// only defined if intmax_t can represent the nominator +// typedef ratio< 1000000000000000000000, 1> zetta; +// typedef ratio<1000000000000000000000000, 1> yotta; // SIMPLIFIED: the following are alias templates template diff --git a/headers/regex b/headers/regex index 1d1922d..6d48a41 100644 --- a/headers/regex +++ b/headers/regex @@ -20,53 +20,57 @@ #include // for std::initializer_list #include // for std::allocator +#include +#include +#include +#include namespace std { namespace regex_constants { -typedef int syntax_option_type; // actually unspecified -constexpr syntax_option_type icase; -constexpr syntax_option_type nosubs; -constexpr syntax_option_type optimize; -constexpr syntax_option_type collate; -constexpr syntax_option_type ECMAScript; -constexpr syntax_option_type basic; -constexpr syntax_option_type extended; -constexpr syntax_option_type awk; -constexpr syntax_option_type grep; -constexpr syntax_option_type egrep; +typedef CPPREFERENCE_UNSPECIFIED_TYPE syntax_option_type; +constexpr syntax_option_type icase = 0; +constexpr syntax_option_type nosubs = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr syntax_option_type optimize = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr syntax_option_type collate = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr syntax_option_type ECMAScript = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr syntax_option_type basic = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr syntax_option_type extended = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr syntax_option_type awk = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr syntax_option_type grep = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr syntax_option_type egrep = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; -typedef int match_flag_type; // actually unspecified +typedef CPPREFERENCE_UNSPECIFIED_TYPE match_flag_type; constexpr match_flag_type match_default = 0; -constexpr match_flag_type match_not_bol; -constexpr match_flag_type match_not_eol; -constexpr match_flag_type match_not_bow; -constexpr match_flag_type match_not_eow; -constexpr match_flag_type match_any; -constexpr match_flag_type match_not_null; -constexpr match_flag_type match_continuous; -constexpr match_flag_type match_prev_avail; +constexpr match_flag_type match_not_bol = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr match_flag_type match_not_eol = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr match_flag_type match_not_bow = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr match_flag_type match_not_eow = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr match_flag_type match_any = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr match_flag_type match_not_null = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr match_flag_type match_continuous = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr match_flag_type match_prev_avail = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; constexpr match_flag_type format_default = 0; -constexpr match_flag_type format_sed; -constexpr match_flag_type format_no_copy; -constexpr match_flag_type format_first_only; - -typedef int error_type; // actually unspecified - -constexpr error_type error_collate; -constexpr error_type error_ctype; -constexpr error_type error_escape; -constexpr error_type error_backref; -constexpr error_type error_brack; -constexpr error_type error_paren; -constexpr error_type error_brace; -constexpr error_type error_badbrace; -constexpr error_type error_range; -constexpr error_type error_space; -constexpr error_type error_badrepeat; -constexpr error_type error_complexity; -constexpr error_type error_stack; +constexpr match_flag_type format_sed = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr match_flag_type format_no_copy = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr match_flag_type format_first_only = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; + +typedef CPPREFERENCE_UNSPECIFIED_TYPE error_type; + +constexpr error_type error_collate = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_ctype = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_escape = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_backref = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_brack = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_paren = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_brace = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_badbrace = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_range = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_space = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_badrepeat = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_complexity = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; +constexpr error_type error_stack = CPPREFERENCE_UNSPECIFIED_TYPE_VALUE; } // namespace regex_constants @@ -154,7 +158,7 @@ public: basic_regex& assign(basic_regex&& that); basic_regex& assign(const CharT* s, flag_type f = std::regex_constants::ECMAScript); - basic_regex& assign(const charT* ptr, size_t count, + basic_regex& assign(const CharT* ptr, size_t count, flag_type f = std::regex_constants::ECMAScript); template @@ -188,6 +192,8 @@ public: typedef typename std::iterator_traits::value_type value_type; typedef typename std::iterator_traits::difference_type difference_type; #endif + using string_type = std::basic_string; + bool matched; constexpr sub_match(); @@ -217,7 +223,7 @@ template < class Alloc = std::allocator> > class match_results { public: - typedef Allocator allocator_type; + typedef Alloc allocator_type; typedef sub_match value_type; typedef value_type& reference; typedef const value_type& const_reference; @@ -228,7 +234,7 @@ public: typedef typename std::iterator_traits::value_type char_type; typedef std::basic_string string_type; - explicit match_results(const Allocator& a = Allocator()); + explicit match_results(const Alloc& a = Alloc()); match_results(const match_results& rhs); match_results(match_results&& rhs); ~match_results(); @@ -259,16 +265,16 @@ public: const_iterator cend() const; template - OutputIter format(OutputIt out, - const char_type* fmt_first, const char_type* fmt_last, - std::regex_constants::match_flag_type flags = - std::regex_constants::format_default) const; + OutputIt format(OutputIt out, + const char_type* fmt_first, const char_type* fmt_last, + std::regex_constants::match_flag_type flags = + std::regex_constants::format_default) const; template - OutputIter format(OutputIt out, - const basic_string& fmt, - std::regex_constants::match_flag_type flags = - std::regex_constants::format_default) const; + OutputIt format(OutputIt out, + const basic_string& fmt, + std::regex_constants::match_flag_type flags = + std::regex_constants::format_default) const; template std::basic_string @@ -306,7 +312,7 @@ template < class Traits = std::regex_traits > class regex_iterator { public: - typedef match_result value_type; + typedef match_results value_type; typedef ptrdiff_t difference_type; typedef const value_type* pointer; typedef const value_type& reference; @@ -358,26 +364,26 @@ public: typedef basic_regex regex_type; regex_token_iterator(); - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + regex_token_iterator(BidirIt a, BidirIt b, const regex_type& re, int submatch = 0, std::regex_constants::match_flag_type m = std::regex_constants::match_default); - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + regex_token_iterator(BidirIt a, BidirIt b, const regex_type& re, const std::vector& submatches, std::regex_constants::match_flag_type m = std::regex_constants::match_default); - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + regex_token_iterator(BidirIt a, BidirIt b, const regex_type& re, std::initializer_list submatches, std::regex_constants::match_flag_type m = std::regex_constants::match_default); template - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + regex_token_iterator(BidirIt a, BidirIt b, const regex_type& re, const int (&submatches)[N], std::regex_constants::match_flag_type m = @@ -386,26 +392,26 @@ public: regex_token_iterator(const regex_token_iterator& other); #if CPPREFERENCE_STDVER>= 2014 - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + regex_token_iterator(BidirIt a, BidirIt b, regex_type&& re, int submatch = 0, std::regex_constants::match_flag_type m = std::regex_constants::match_default) = delete; - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + regex_token_iterator(BidirIt a, BidirIt b, regex_type&& re, const std::vector& submatches, std::regex_constants::match_flag_type m = std::regex_constants::match_default) = delete; - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + regex_token_iterator(BidirIt a, BidirIt b, regex_type&& re, std::initializer_list submatches, std::regex_constants::match_flag_type m = std::regex_constants::match_default) = delete; template - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + regex_token_iterator(BidirIt a, BidirIt b, regex_type&& re, const int (&submatches)[N], std::regex_constants::match_flag_type m = @@ -420,8 +426,8 @@ public: const value_type& operator*() const; const value_type* operator->() const; - regex_iterator& operator++(); - regex_iterator operator++(int); + regex_token_iterator& operator++(); + regex_token_iterator operator++(int); }; typedef regex_token_iterator cregex_token_iterator; @@ -483,7 +489,7 @@ bool regex_search(BidirIt first, BidirIt last, template bool regex_search(const CharT* str, - std::match_results& m, + std::match_results& m, const std::basic_regex& e, std::regex_constants::match_flag_type flags = std::regex_constants::match_default); diff --git a/headers/scoped_allocator b/headers/scoped_allocator index cc90815..ec7ec81 100644 --- a/headers/scoped_allocator +++ b/headers/scoped_allocator @@ -18,6 +18,7 @@ #if CPPREFERENCE_STDVER>= 2011 +#include // for allocator_traits #include // for std::pair #include // for std::true_type @@ -62,17 +63,17 @@ public: scoped_allocator_adaptor(); - template + template scoped_allocator_adaptor(OuterA2&& outerAlloc, const InnerAllocs& ... innerAllocs); scoped_allocator_adaptor(const scoped_allocator_adaptor& other); scoped_allocator_adaptor(scoped_allocator_adaptor&& other); - template + template scoped_allocator_adaptor(const scoped_allocator_adaptor& other); - template + template scoped_allocator_adaptor(scoped_allocator_adaptor&& other); ~scoped_allocator_adaptor(); diff --git a/headers/set b/headers/set index 777ed85..f366713 100644 --- a/headers/set +++ b/headers/set @@ -21,6 +21,7 @@ #endif #include // for size_t, ptrdiff_t +#include // for less #include // for std::reverse_iterator #include // for std::allocator #include // for std::pair @@ -56,22 +57,16 @@ public: typedef typename std::allocator_traits::pointer pointer; typedef typename std::allocator_traits::const_pointer const_pointer; #endif - typedef T* iterator; // actual type is unspecified - typedef const T* const_iterator; // actual type is unspecified + typedef Key* iterator; // actual type is unspecified + typedef const Key* const_iterator; // actual type is unspecified typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; // constructor - -#if CPPREFERENCE_STDVER <2014 - explicit set(const Compare& comp = Compare(), - const Allocator& alloc = Allocator()); -#else set(); explicit set(const Compare& comp, const Allocator& alloc = Allocator()); -#endif #if CPPREFERENCE_STDVER>= 2011 explicit set(const Allocator& alloc); @@ -175,8 +170,10 @@ public: // lookup size_type count(const Key& key) const; +#if CPPREFERENCE_STDVER >= 2014 template size_type count(const K& x) const; +#endif iterator find(const Key& key); const_iterator find(const Key& key) const; @@ -281,22 +278,16 @@ public: typedef typename std::allocator_traits::pointer pointer; typedef typename std::allocator_traits::const_pointer const_pointer; #endif - typedef T* iterator; // actual type is unspecified - typedef const T* const_iterator; // actual type is unspecified + typedef Key* iterator; // actual type is unspecified + typedef const Key* const_iterator; // actual type is unspecified typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; // constructor - -#if CPPREFERENCE_STDVER <2014 - explicit multiset(const Compare& comp = Compare(), - const Allocator& alloc = Allocator()); -#else multiset(); explicit multiset(const Compare& comp, const Allocator& alloc = Allocator()); -#endif #if CPPREFERENCE_STDVER>= 2011 explicit multiset(const Allocator& alloc); @@ -400,8 +391,10 @@ public: // lookup size_type count(const Key& key) const; +#if CPPREFERENCE_STDVER >= 2014 template size_type count(const K& x) const; +#endif iterator find(const Key& key); const_iterator find(const Key& key) const; diff --git a/headers/shared_mutex b/headers/shared_mutex index dccf753..23a837e 100644 --- a/headers/shared_mutex +++ b/headers/shared_mutex @@ -18,6 +18,9 @@ #if CPPREFERENCE_STDVER>= 2014 +#include +#include // try_to_lock_t and friends + namespace std { #if CPPREFERENCE_STDVER>= 2017 diff --git a/headers/sstream b/headers/sstream index 756498c..edce346 100644 --- a/headers/sstream +++ b/headers/sstream @@ -16,6 +16,7 @@ #ifndef CPPREFERENCE_SSTREAM_H #define CPPREFERENCE_SSTREAM_H +#include // for default template arguments #include // for streams #include // for std::allocator @@ -23,10 +24,15 @@ namespace std { template < class CharT, - class Traits = std::char_traits, - class Allocator = std::allocator + class Traits /* = std::char_traits */, + class Allocator /*= std::allocator */ > class basic_stringbuf : public std::basic_streambuf { public: + typedef CharT char_type; + typedef Traits traits_type; + typedef typename traits_type::int_type int_type; + typedef typename traits_type::pos_type pos_type; + typedef typename traits_type::off_type off_type; #if CPPREFERENCE_STDVER>= 2011 typedef Allocator allocator_type; @@ -35,15 +41,15 @@ public: explicit basic_stringbuf(std::ios_base::openmode which = std::ios_base::in | std::ios_base::out); - explicit basic_stringbuf(const std::basic_string& new_str, + explicit basic_stringbuf(const std::basic_string& new_str, std::ios_base::openmode which = std::ios_base::in | std::ios_base::out); #if CPPREFERENCE_STDVER>= 2011 basic_stringbuf(const basic_stringbuf& rhs) = delete; basic_stringbuf(basic_stringbuf&& rhs); - std::basic_stringbuf& operator=(std::basic_stringbuf&& rhs); - std::basic_stringbuf& operator=(const std::basic_stringbuf& rhs) = delete; - void swap(std::basic_stringbuf& rhs); + basic_stringbuf& operator=(basic_stringbuf&& rhs); + basic_stringbuf& operator=(const basic_stringbuf& rhs) = delete; + void swap(basic_stringbuf& rhs); #endif virtual ~basic_stringbuf(); @@ -53,8 +59,8 @@ public: protected: virtual int_type underflow(); - virtual int_type pbackfail(int_type c = Traits_type::eof()); - virtual int_type overflow(int_type c = Traits_type::eof()); + virtual int_type pbackfail(int_type c = traits_type::eof()); + virtual int_type overflow(int_type c = traits_type::eof()); virtual basic_streambuf* setbuf(char_type* s, streamsize n); virtual pos_type seekoff(off_type off, ios_base::seekdir dir, ios_base::openmode which = ios_base::in | ios_base::out); @@ -64,8 +70,8 @@ protected: #if CPPREFERENCE_STDVER>= 2011 template -void swap(std::basic_stringbuf& lhs, - std::basic_stringbuf& rhs); +void swap(basic_stringbuf& lhs, + basic_stringbuf& rhs); #endif typedef basic_stringbuf stringbuf; @@ -73,9 +79,9 @@ typedef basic_stringbuf wstringbuf; template < class CharT, - class Traits = std::char_traits, - class Allocator = std::allocator - > class basic_stringstream : public std::basic_iostream { + class Traits /* = std::char_traits */, + class Allocator /*= std::allocator */ +> class basic_stringstream : public std::basic_iostream { public: #if CPPREFERENCE_STDVER>= 2011 @@ -91,7 +97,7 @@ public: void swap(basic_stringstream& other); #endif - std::basic_stringbuf* rdbuf() const; + basic_stringbuf* rdbuf() const; std::basic_string str() const; void str(const std::basic_string& new_str); @@ -108,9 +114,9 @@ typedef basic_stringstream wstringstream; template < class CharT, - class Traits = std::char_traits, - class Allocator = std::allocator - > class basic_istringstream : public std::basic_ostream { + class Traits /* = std::char_traits */, + class Allocator /* = std::allocator */ +> class basic_istringstream : public std::basic_ostream { public: #if CPPREFERENCE_STDVER>= 2011 @@ -126,7 +132,7 @@ public: void swap(basic_istringstream& other); #endif - std::basic_stringbuf* rdbuf() const; + basic_stringbuf* rdbuf() const; std::basic_string str() const; void str(const std::basic_string& new_str); @@ -143,9 +149,9 @@ void swap(std::basic_istringstream& lhs, template < class CharT, - class Traits = std::char_traits, - class Allocator = std::allocator - > class basic_ostringstream : public std::basic_ostream { + class Traits /* = std::char_traits */, + class Allocator /* = std::allocator */ +> class basic_ostringstream : public std::basic_ostream { public: #if CPPREFERENCE_STDVER>= 2011 @@ -161,7 +167,7 @@ public: void swap(basic_ostringstream& other); #endif - std::basic_stringbuf* rdbuf() const; + basic_stringbuf* rdbuf() const; std::basic_string str() const; void str(const std::basic_string& new_str); diff --git a/headers/stack b/headers/stack index 75aeac4..a8c8d35 100644 --- a/headers/stack +++ b/headers/stack @@ -20,6 +20,8 @@ #include #endif +#include + namespace std { template < diff --git a/headers/stdexcept b/headers/stdexcept index 5c3a330..c313b3e 100644 --- a/headers/stdexcept +++ b/headers/stdexcept @@ -17,6 +17,7 @@ #define CPPREFERENCE_STDEXCEPT_H #include +#include namespace std { diff --git a/headers/streambuf b/headers/streambuf index 04dc92d..d765b50 100644 --- a/headers/streambuf +++ b/headers/streambuf @@ -16,9 +16,11 @@ #ifndef CPPREFERENCE_STREAMBUF_H #define CPPREFERENCE_STREAMBUF_H +#include // for locale + namespace std { -template> +template*/ > class basic_streambuf { public: typedef CharT char_type; diff --git a/headers/string b/headers/string index 9d91810..153d33a 100644 --- a/headers/string +++ b/headers/string @@ -21,11 +21,42 @@ #endif #include // for size_t, ptrdiff_t +#include // for mbstate_t +#include #include // for std::reverse_iterator #include // for std::allocator +#include +#include namespace std { +template +class char_traits { +public: + typedef CharT char_type; + typedef int int_type; // impl-defined integer type + typedef streamoff off_type; // actually impl-defined + typedef streampos pos_type; // actually impl-defined + typedef mbstate_t state_type; // actually impl-defined + + static void assign(char_type& r, const char_type& a); + static char_type* assign(char_type* p, size_t count, char_type a); + static bool eq(char_type a, char_type b); + static bool lt(char_type a, char_type b); + static char_type* move(char_type* desc, const char_type* src, size_t count); + static char_type* copy(char_type* desc, const char_type* src, size_t count); + + static int compare(const char_type* s1, const char_type* s2, size_t count); + static size_t length(const char_type* s); + static const char_type* find(const char_type* p, size_t count, const char_type& ch); + + static char_type to_char_type(int_type c); + static int_type to_int_type(char_type c); + static bool eq_int_type(int_type c1, int_type c2); + static int_type eof(); + static int_type not_eof(int_type c); +}; + template class fpos { public: @@ -58,37 +89,10 @@ typedef fpos::state_type> u16streampos; typedef fpos::state_type> u32streampos; #endif -template -class char_traits { -public: - typedef CharT char_type; - typedef int int_type; // impl-defined integer type - typedef streamoff off_type; // actually impl-defined - typedef streampos pos_type; // actually impl-defined - typedef mbstate_t state_type; // actually impl-defined - - static void assign(char_type& r, const char_type& a); - static char_type* assign(char_type* p, size_t count, char_type a); - static bool eq(char_type a, char_type b); - static bool lt(char_type a, char_type b); - static char_type* move(char_type* desc, const char_type* src, size_t count); - static char_type* copy(char_type* desc, const char_type* src, size_t count); - - static int compare(const char_type* s1, const char_type* s2, size_t count); - static size_t length(const char_type* s); - static const char_type* find(const char_type* p, size_t count, const char_type& ch); - - static char_type to_char_type(int_type c); - static int_type to_int_type(char_type c); - static bool eq_int_type(int_type c1, int_type c2); - static int_type eof(); - static int_type not_eof(int_type c); -}; - template < class CharT, - class Traits = std::char_traits, - class Allocator = std::allocator + class Traits /* = std::char_traits */, + class Allocator /* = std::allocator */ > class basic_string { public: typedef Traits traits_type; @@ -139,7 +143,7 @@ public: basic_string(const basic_string& other, size_type pos, - size_type count = std::basic_string::npos, + size_type count = npos, const Allocator& alloc = Allocator()); basic_string(const CharT* s, @@ -162,6 +166,11 @@ public: basic_string(std::initializer_list init, const Allocator& alloc = Allocator()); #endif +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + basic_string(basic_string_view sv, const Allocator& alloc = Allocator()); +#endif ~basic_string(); @@ -172,6 +181,11 @@ public: basic_string& operator=(basic_string&& other); basic_string& operator=(initializer_list ilist); #endif +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + basic_string& operator=(basic_string_view sv); +#endif basic_string& assign(size_type count, const CharT& ch); basic_string& assign(const basic_string& str); @@ -185,6 +199,12 @@ public: size_type count = npos); #endif +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + basic_string& assign(basic_string_view sv); +#endif + basic_string& assign(const CharT* s, size_type count); @@ -198,6 +218,13 @@ public: basic_string& assign(std::initializer_list ilist); #endif +#if CPPREFERENCE_STDVER >= 2017 + template + basic_string& assign(const T& t); + template + basic_string& assign(const T& t, size_type pos, size_type count = npos); +#endif + allocator_type get_allocator() const; // element access @@ -205,6 +232,9 @@ public: const_reference at(size_type n) const; reference operator[](size_type n); const_reference operator[](size_type n) const; +#if CPPREFERENCE_STDVER >= 2017 + operator basic_string_view() const noexcept; +#endif #if CPPREFERENCE_STDVER>= 2011 CharT& front(); @@ -260,6 +290,12 @@ public: size_type index_str, size_type count = npos); #endif +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + basic_string& insert(size_type index, basic_string_view sv); +#endif + #if CPPREFERENCE_STDVER <2011 iterator insert(iterator pos, CharT ch); void insert(iterator pos, size_type count, CharT ch); @@ -273,6 +309,15 @@ public: iterator insert(const_iterator pos, std::initializer_list ilist); #endif +#if CPPREFERENCE_STDVER >= 2017 + template + basic_string& insert(size_type pos, const T& t); + + template + basic_string& insert(size_type index, const T& t, + size_type index_str, size_type count = npos); +#endif + basic_string& erase(size_type index = 0, size_type count = npos); #if CPPREFERENCE_STDVER <2011 iterator erase(iterator pos); @@ -296,14 +341,19 @@ public: basic_string& append(size_type count, CharT ch); basic_string& append(const basic_string& str); -#if CPPREFERENCE_STDVER <2014 +#if CPPREFERENCE_STDVER >= 2014 basic_string& append(const basic_string& str, size_type pos, - size_type count); + size_type count = npos); #else basic_string& append(const basic_string& str, size_type pos, - size_type count = npos); + size_type count); +#endif +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + basic_string& append(basic_string_view sv); #endif basic_string& append(const CharT* s, size_type count); @@ -315,12 +365,25 @@ public: basic_string& append(std::initializer_list ilist); #endif +#if CPPREFERENCE_STDVER > 2017 + template + basic_string& append(const T& t); + + template + basic_string& append(const T& t, size_type pos, size_type count = npos); +#endif + basic_string& operator+=(const basic_string& str); basic_string& operator+=(CharT ch); basic_string& operator+=(const CharT* s); #if CPPREFERENCE_STDVER> 2011 basic_string& operator+=(std::initializer_list ilist); #endif +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + basic_string& operator+=(basic_string_view sv); +#endif int compare(const basic_string& str) const; int compare(size_type pos1, size_type count1, @@ -328,7 +391,6 @@ public: #if CPPREFERENCE_STDVER <2014 int compare(size_type pos1, size_type count1, - const basic_string& str, size_type pos2, size_type count2) const; #else @@ -336,12 +398,43 @@ public: const basic_string& str, size_type pos2, size_type count2 = npos) const; #endif +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + int compare(basic_string_view sv) const noexcept; + int compare(size_type pos1, size_type count1, + basic_string_view sv) const; +#endif + int compare(const CharT* s) const; int compare(size_type pos1, size_type count1, const CharT* s) const; int compare(size_type pos1, size_type count1, const CharT* s, size_type count2) const; +#if CPPREFERENCE_STDVER >= 2017 + template + int compare(const T& t) const; + + template + int compare(size_type pos1, size_type count1, const T& t) const; + + template + int compare(size_type pos1, size_type count1, + const T& t, + size_type pos2, size_type count2 = npos) const; +#endif + +#if CPPREFERENCE_STDVER >= 2020 + bool starts_with(basic_string_view sv) const noexcept; + bool starts_with(CharT c) const noexcept; + bool starts_with(const CharT* s) const; + + bool ends_with(basic_string_view sv) const noexcept; + bool ends_with(CharT c) const noexcept; + bool ends_with(const CharT* s) const; +#endif + basic_string& replace(size_type pos, size_type count, const basic_string& str); basic_string& replace(const_iterator first, const_iterator last, @@ -359,6 +452,15 @@ public: size_type pos2, size_type count2 = npos); #endif +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + basic_string& replace(size_type pos, size_type count, + basic_string_view sv); + basic_string& replace(const_iterator first, const_iterator last, + basic_string_view sv); +#endif + template basic_string& replace(const_iterator first, const_iterator last, InputIt first2, InputIt last2); @@ -384,6 +486,19 @@ public: basic_string& replace(const_iterator first, const_iterator last, std::initializer_list ilist); +#if CPPREFERENCE_STDVER >= 2017 + template + basic_string& replace(size_type pos,size_type count, const T& t); + + template + basic_string& replace(const_iterator first, const_iterator last, + const T& t); + + template + basic_string& replace(size_type pos, size_type count, const T& t, + size_type pos2, size_type count2 = npos); +#endif + basic_string substr(size_type pos = 0, size_type count = npos) const; @@ -395,31 +510,71 @@ public: // search size_type find(const basic_string& str, size_type pos = 0) const; + +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + size_type find(basic_string_view sv, + size_type pos = 0); +#endif + size_type find(const CharT* s, size_type pos, size_type count) const; size_type find(const CharT* s, size_type pos = 0) const; size_type find(CharT ch, size_type pos = 0) const; size_type rfind(const basic_string& str, size_type pos = npos) const; + +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + size_type rfind(basic_string_view sv, + size_type pos = npos); +#endif + size_type rfind(const CharT* s, size_type pos, size_type count) const; size_type rfind(const CharT* s, size_type pos = npos) const; size_type rfind(CharT ch, size_type pos = npos) const; size_type find_first_of(const basic_string& str, size_type pos = 0) const; +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + size_type find_first_of(basic_string_view sv, + size_type pos = 0); +#endif size_type find_first_of(const CharT* s, size_type pos, size_type count) const; size_type find_first_of(const CharT* s, size_type pos = 0) const; size_type find_first_of(CharT ch, size_type pos = 0) const; size_type find_first_not_of(const basic_string& str, size_type pos = 0) const; +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + size_type find_first_not_of(basic_string_view sv, + size_type pos = 0); +#endif size_type find_first_not_of(const CharT* s, size_type pos, size_type count) const; size_type find_first_not_of(const CharT* s, size_type pos = 0) const; size_type find_first_not_of(CharT ch, size_type pos = 0) const; size_type find_last_of(const basic_string& str, size_type pos = npos) const; +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + size_type find_last_of(basic_string_view sv, + size_type pos = npos); +#endif size_type find_last_of(const CharT* s, size_type pos, size_type count) const; size_type find_last_of(const CharT* s, size_type pos = npos) const; size_type find_last_of(CharT ch, size_type pos = npos) const; size_type find_last_not_of(const basic_string& str, size_type pos = npos) const; +#if CPPREFERENCE_STDVER >= 2017 + // SIMPLIFIED: the C++20 standard specifies a template that only accepts types convertible + // to string_view, but not to const Char* + size_type find_last_not_of(basic_string_view sv, + size_type pos = npos); +#endif size_type find_last_not_of(const CharT* s, size_type pos, size_type count) const; size_type find_last_not_of(const CharT* s, size_type pos = npos) const; size_type find_last_not_of(CharT ch, size_type pos = npos) const; @@ -590,26 +745,26 @@ std::basic_istream& getline(std::basic_istream&& i #endif #if CPPREFERENCE_STDVER>= 2011 -int stoi(const std::string& str, std::size_t* pos = 0, int base = 10); -int stoi(const std::wstring& str, std::size_t* pos = 0, int base = 10); - -long stol(const std::string& str, std::size_t* pos = 0, int base = 10); -long stol(const std::wstring& str, std::size_t* pos = 0, int base = 10); - -long long stoll(const std::string& str, std::size_t* pos = 0, int base = 10); -long long stoll(const std::wstring& str, std::size_t* pos = 0, int base = 10); - -unsigned long stoul(const std::string& str, std::size_t* pos = 0, int base = 10); -unsigned long stoul(const std::wstring& str, std::size_t* pos = 0, int base = 10); -unsigned long long stoull(const std::string& str, std::size_t* pos = 0, int base = 10); -unsigned long long stoull(const std::wstring& str, std::size_t* pos = 0, int base = 10); - -float stof(const std::string& str, std::size_t* pos = 0); -float stof(const std::wstring& str, std::size_t* pos = 0); -double stod(const std::string& str, std::size_t* pos = 0); -double stod(const std::wstring& str, std::size_t* pos = 0); -long double stold(const std::string& str, std::size_t* pos = 0); -long double stold(const std::wstring& str, std::size_t* pos = 0); +int stoi(const std::string& str, std::size_t* pos = nullptr, int base = 10); +int stoi(const std::wstring& str, std::size_t* pos = nullptr, int base = 10); + +long stol(const std::string& str, std::size_t* pos = nullptr, int base = 10); +long stol(const std::wstring& str, std::size_t* pos = nullptr, int base = 10); + +long long stoll(const std::string& str, std::size_t* pos = nullptr, int base = 10); +long long stoll(const std::wstring& str, std::size_t* pos = nullptr, int base = 10); + +unsigned long stoul(const std::string& str, std::size_t* pos = nullptr, int base = 10); +unsigned long stoul(const std::wstring& str, std::size_t* pos = nullptr, int base = 10); +unsigned long long stoull(const std::string& str, std::size_t* pos = nullptr, int base = 10); +unsigned long long stoull(const std::wstring& str, std::size_t* pos = nullptr, int base = 10); + +float stof(const std::string& str, std::size_t* pos = nullptr); +float stof(const std::wstring& str, std::size_t* pos = nullptr); +double stod(const std::string& str, std::size_t* pos = nullptr); +double stod(const std::wstring& str, std::size_t* pos = nullptr); +long double stold(const std::string& str, std::size_t* pos = nullptr); +long double stold(const std::wstring& str, std::size_t* pos = nullptr); std::string to_string(int value); std::string to_string(long value); diff --git a/headers/string_view b/headers/string_view new file mode 100644 index 0000000..f9c0d50 --- /dev/null +++ b/headers/string_view @@ -0,0 +1,213 @@ +/* Copyright (C) 2018 Povilas Kanapickas + + This file is part of cppreference-doc + + This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 + Unported License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative + Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 or + any later version published by the Free Software Foundation; with no + Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +*/ + +#ifndef CPPREFERENCE_STRING_VIEW_H +#define CPPREFERENCE_STRING_VIEW_H + +#if CPPREFERENCE_STDVER >= 2017 + +#include // for std::reverse_iterator +#include + +namespace std { + +template*/> +class basic_string_view { +public: + using traits_type = Traits; + using value_type = CharT; + + using size_type = size_t; + using difference_type = ptrdiff_t; + using reference = const CharT&; + using const_reference = const CharT&; + using pointer = const CharT*; + using const_pointer = const CharT*; + + using const_iterator = const CharT*; + using iterator = const_iterator; + using const_reverse_iterator = std::reverse_iterator; + using reverse_iterator = const_reverse_iterator; + static const size_type npos = static_cast(-1); + + // [string.view.cons], construct/copy + + constexpr basic_string_view() noexcept; + constexpr basic_string_view( + const basic_string_view& other) noexcept = default; + + constexpr basic_string_view(const CharT* s) noexcept; + + constexpr basic_string_view(const CharT* s, size_type length) noexcept; + + constexpr basic_string_view& + operator=(const basic_string_view& other) noexcept = default; + + + constexpr const_iterator begin() const noexcept; + constexpr const_iterator cbegin() const noexcept; + + constexpr const_iterator end() const noexcept; + constexpr const_iterator cend() const noexcept; + + constexpr const_reverse_iterator rbegin() const noexcept; + constexpr const_reverse_iterator crbegin() const noexcept; + + constexpr const_reverse_iterator rend() const noexcept; + constexpr const_reverse_iterator crend() const noexcept; + + constexpr size_type size() const noexcept; + constexpr size_type length() const noexcept; + + constexpr size_type max_size() const noexcept; + constexpr bool empty() const noexcept; + + constexpr const CharT& operator[](size_type pos) const noexcept; + + constexpr const CharT& at(size_type pos) const; + + constexpr const CharT& front() const noexcept; + + constexpr const CharT& back() const noexcept; + + constexpr const CharT* data() const noexcept; + + constexpr void remove_prefix(size_type count) noexcept; + + constexpr void remove_suffix(size_type count) noexcept; + + constexpr void swap(basic_string_view& other) noexcept; + + size_type copy(CharT* str, size_type length, size_type pos = 0) const; + + constexpr basic_string_view substr(size_type pos, + size_type length = npos) const; + + constexpr int compare(basic_string_view str) const noexcept; + constexpr int compare(size_type pos1, size_type count1, + basic_string_view str) const; + constexpr int compare(size_type pos1, size_type count1, + basic_string_view str, + size_type pos2, size_type count2) const; + + constexpr int compare(const CharT* s) const noexcept; + constexpr int compare(size_type pos1, size_type count1, + const CharT* s) const; + constexpr int compare(size_type pos1, size_type count1, + const CharT* s, size_type count2) const; + + constexpr size_type find(basic_string_view str, + size_type pos = 0) const noexcept; + constexpr size_type find(CharT ch, size_type pos = 0) const noexcept; + constexpr size_type find(const CharT* s, + size_type pos, size_type count) const noexcept; + constexpr size_type find(const CharT* s, size_type pos = 0) const noexcept; + + constexpr size_type rfind(basic_string_view str, + size_type pos = npos) const noexcept; + constexpr size_type rfind(CharT ch, + size_type pos = npos) const noexcept; + constexpr size_type rfind(const CharT* s, + size_type pos, size_type count) const noexcept; + constexpr size_type rfind(const CharT* s, + size_type pos = npos) const noexcept; + + constexpr size_type find_first_of(basic_string_view str, + size_type pos = 0) const noexcept; + constexpr size_type find_first_of(CharT ch, size_type pos = 0) const noexcept; + constexpr size_type find_first_of(const CharT* s, + size_type pos, size_type count) const noexcept; + constexpr size_type find_first_of(const CharT* s, size_type pos = 0) const noexcept; + + constexpr size_type find_first_not_of(basic_string_view str, + size_type pos = 0) const noexcept; + constexpr size_type find_first_not_of(CharT ch, size_type pos = 0) const noexcept; + constexpr size_type find_first_not_of(const CharT* s, + size_type pos, size_type count) const noexcept; + constexpr size_type find_first_not_of(const CharT* s, size_type pos = 0) const noexcept; + + constexpr size_type find_last_of(basic_string_view str, + size_type pos = npos) const noexcept; + constexpr size_type find_last_of(CharT ch, size_type pos=npos) const noexcept; + constexpr size_type find_last_of(const CharT* s, size_type pos, + size_type count) const noexcept; + constexpr size_type find_last_of(const CharT* s, size_type pos = npos) const noexcept; + + constexpr size_type find_last_not_of(basic_string_view str, + size_type pos = npos) const noexcept; + constexpr size_type find_last_not_of(CharT ch, size_type pos = npos) const noexcept; + constexpr size_type find_last_not_of(const CharT* s, + size_type pos, size_type count) const noexcept; + constexpr size_type find_last_not_of(const CharT* s, + size_type pos = npos) const noexcept; +}; + +using string_view = basic_string_view; +using wstring_view = basic_string_view; +using u16string_view = basic_string_view; +using u32string_view = basic_string_view; + +template +constexpr bool +operator==(basic_string_view lhs, + basic_string_view rhs) noexcept; + +template +constexpr bool +operator!=(basic_string_view lhs, + basic_string_view rhs) noexcept; + +template +constexpr bool +operator<(basic_string_view lhs, + basic_string_view rhs) noexcept; + +template +constexpr bool +operator<=(basic_string_view lhs, + basic_string_view rhs) noexcept; + +template +constexpr bool +operator>(basic_string_view lhs, + basic_string_view rhs) noexcept; + +template +constexpr bool +operator>=(basic_string_view lhs, + basic_string_view rhs) noexcept; + +inline namespace literals { +inline namespace string_view_literals { + +constexpr string_view operator "" sv(const char* str, size_t len) noexcept; + +#if CPPREFERENCE_STDVER >= 2020 +constexpr u8string_view + operator "" sv(const char8_t* str, size_t len) noexcept; +#endif + +constexpr u16string_view operator "" sv(const char16_t* str, size_t len) noexcept; +constexpr u32string_view operator "" sv(const char32_t* str, size_t len) noexcept; +constexpr wstring_view operator "" sv(const wchar_t* str, size_t len) noexcept; + +} // namespace string_view_literals +} // namespace literals + +} // namespace std + +#endif // CPPREFERENCE_STDVER >= 2017 + +#endif // CPPREFERENCE_STRING_VIEW_H diff --git a/headers/system_error b/headers/system_error index 5384801..68d8d0d 100644 --- a/headers/system_error +++ b/headers/system_error @@ -18,8 +18,15 @@ #if CPPREFERENCE_STDVER>= 2011 +#include +#include // for integral_constant +#include // for runtime_error + namespace std { +class error_condition; +class error_code; + class error_category { public: error_category(const error_category& other) = delete; diff --git a/headers/thread b/headers/thread index 45a9ae6..8aca56c 100644 --- a/headers/thread +++ b/headers/thread @@ -18,6 +18,9 @@ #if CPPREFERENCE_STDVER>= 2011 +#include +#include + namespace std { class thread { diff --git a/headers/tuple b/headers/tuple index 42be358..4fc8a88 100644 --- a/headers/tuple +++ b/headers/tuple @@ -18,7 +18,10 @@ #if CPPREFERENCE_STDVER >= 2011 +#include // for size_t +#include // for allocator_arg_t #include // for std::pair +#include // for integral_constant namespace std { @@ -86,28 +89,36 @@ public: }; template -tuple make_tuple(Types&& ... args); +class tuple_size > : public std::integral_constant { }; -template +template +class tuple_element > { + typedef void type; +}; // SIMPLIFIED + +template +tuple make_tuple(Types&& ... args); + +template tuple tie(Types& ... args); -template -tuple < Types&& ... > forward_as_tuple(Types&& ... args); +template +tuple forward_as_tuple(Types&& ... args); -template +template std::tuple tuple_cat(Tuples&& ... args); template typename std::tuple_element >::type& -get(tuple& t); + get(tuple& t); template typename std::tuple_element >::type&& -get(tuple&& t); + get(tuple&& t); template typename std::tuple_element >::type const& -get(const tuple& t); + get(const tuple& t); template bool operator==(const tuple& lhs, @@ -131,14 +142,6 @@ bool operator>=(const tuple& lhs, template void swap(tuple& lhs, tuple& rhs); -template -class tuple_size > : public std::integral_constant { }; - -template -class tuple_element > { - typedef void type; -}; // SIMPLIFIED - const void* ignore; // SIMPLIFIED } // namespace std diff --git a/headers/type_traits b/headers/type_traits index a2d2989..e6df9da 100644 --- a/headers/type_traits +++ b/headers/type_traits @@ -18,6 +18,8 @@ #if CPPREFERENCE_STDVER>= 2011 +#include // for size_t + namespace std { template @@ -25,14 +27,19 @@ struct integral_constant { typedef T value_type; typedef integral_constant type; - static constexpr T value; + static constexpr T value = v; constexpr operator value_type() const; - constexpr operator()() const; + constexpr T operator()() const; }; typedef integral_constant false_type; typedef integral_constant true_type; +#if CPPREFERENCE_STDVER >= 2017 +template +using bool_constant = integral_constant; +#endif + // SIMPLIFIED: the actual base type depends on T // primary type categories template struct is_void : integral_constant {}; @@ -52,6 +59,23 @@ template struct is_rvalue_reference : integral_constant {} template struct is_member_object_pointer : integral_constant {}; template struct is_member_function_pointer : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_void_v = false; +template inline constexpr bool is_null_pointer_v = false; +template inline constexpr bool is_integral_v = false; +template inline constexpr bool is_floating_point_v = false; +template inline constexpr bool is_array_v = false; +template inline constexpr bool is_enum_v = false; +template inline constexpr bool is_union_v = false; +template inline constexpr bool is_class_v = false; +template inline constexpr bool is_function_v = false; +template inline constexpr bool is_pointer_v = false; +template inline constexpr bool is_lvalue_reference_v = false; +template inline constexpr bool is_rvalue_reference_v = false; +template inline constexpr bool is_member_object_pointer_v = false; +template inline constexpr bool is_member_function_pointer_v = false; +#endif + // composite type categories template struct is_fundamental : integral_constant {}; template struct is_arithmetic : integral_constant {}; @@ -61,6 +85,16 @@ template struct is_compound : integral_constant {}; template struct is_reference : integral_constant {}; template struct is_member_pointer : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_fundamental_v = false; +template inline constexpr bool is_arithmetic_v = false; +template inline constexpr bool is_scalar_v = false; +template inline constexpr bool is_object_v = false; +template inline constexpr bool is_compound_v = false; +template inline constexpr bool is_reference_v = false; +template inline constexpr bool is_member_pointer_v = false; +#endif + // type properties template struct is_const : integral_constant {}; template struct is_volatile : integral_constant {}; @@ -71,138 +105,339 @@ template struct is_pod : integral_constant {}; template struct is_literal_type : integral_constant {}; template struct is_empty : integral_constant {}; template struct is_polymorphic : integral_constant {}; -#if CPPREFERENCE_STDVER>= 2014` +#if CPPREFERENCE_STDVER >= 2014 template struct is_final : integral_constant {}; #endif template struct is_abstract : integral_constant {}; template struct is_signed : integral_constant {}; template struct is_unsigned : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_const_v = false; +template inline constexpr bool is_volatile_v = false; +template inline constexpr bool is_trivial_v = false; +template inline constexpr bool is_trivially_copyable_v = false; +template inline constexpr bool is_standard_layout_v = false; +template inline constexpr bool is_pod_v = false; +template inline constexpr bool is_literal_type_v = false; +template inline constexpr bool is_empty_v = false; +template inline constexpr bool is_polymorphic_v = false; +template inline constexpr bool is_final_v = false; +template inline constexpr bool is_abstract_v = false; +template inline constexpr bool is_signed_v = false; +template inline constexpr bool is_unsigned_v = false; +#endif + // supported operations template struct is_constructible : integral_constant {}; template struct is_trivially_constructible : integral_constant {}; template struct is_nothrow_constructible : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_constructible_v = false; +template inline constexpr bool is_trivially_constructible_v = false; +template inline constexpr bool is_nothrow_constructible_v = false; +#endif + template struct is_default_constructible : integral_constant {}; template struct is_trivially_default_constructible : integral_constant {}; template struct is_nothrow_default_constructible : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_default_constructible_v = false; +template inline constexpr bool is_trivially_default_constructible_v = false; +template inline constexpr bool is_nothrow_default_constructible_v = false; +#endif + template struct is_copy_constructible : integral_constant {}; template struct is_trivially_copy_constructible : integral_constant {}; template struct is_nothrow_copy_constructible : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_copy_constructible_v = false; +template inline constexpr bool is_trivially_copy_constructible_v = false; +template inline constexpr bool is_nothrow_copy_constructible_v = false; +#endif + template struct is_move_constructible : integral_constant {}; template struct is_trivially_move_constructible : integral_constant {}; template struct is_nothrow_move_constructible : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_move_constructible_v = false; +template inline constexpr bool is_trivially_move_constructible_v = false; +template inline constexpr bool is_nothrow_move_constructible_v = false; +#endif + template struct is_assignable : integral_constant {}; template struct is_trivially_assignable : integral_constant {}; template struct is_nothrow_assignable : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_assignable_v = false; +template inline constexpr bool is_trivially_assignable_v = false; +template inline constexpr bool is_nothrow_assignable_v = false; +#endif + template struct is_copy_assignable : integral_constant {}; template struct is_trivially_copy_assignable : integral_constant {}; template struct is_nothrow_copy_assignable : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_copy_assignable_v = false; +template inline constexpr bool is_trivially_copy_assignable_v = false; +template inline constexpr bool is_nothrow_copy_assignable_v = false; +#endif + template struct is_move_assignable : integral_constant {}; template struct is_trivially_move_assignable : integral_constant {}; template struct is_nothrow_move_assignable : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_move_assignable_v = false; +template inline constexpr bool is_trivially_move_assignable_v = false; +template inline constexpr bool is_nothrow_move_assignable_v = false; +#endif + template struct is_destructible : integral_constant {}; template struct is_trivially_destructible : integral_constant {}; template struct is_nothrow_destructible : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_destructible_v = false; +template inline constexpr bool is_trivially_destructible_v = false; +template inline constexpr bool is_nothrow_destructible_v = false; +#endif + template struct has_virtual_destructor : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool has_virtual_destructor_v = false; +#endif + // property queries template struct alignment_of : integral_constant {}; template struct rank : integral_constant {}; template struct extent : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr size_t alignment_of_v = 0; +template inline constexpr size_t rank_v = 0; +template inline constexpr size_t extent_v = 0; +#endif + // type relationships template struct is_same : integral_constant {}; template struct is_base_of : integral_constant {}; template struct is_convertible : integral_constant {}; +#if CPPREFERENCE_STDVER >= 2014 +template inline constexpr bool is_same_v = false; +template inline constexpr bool is_base_of_v = false; +template inline constexpr bool is_convertible_v = false; +#endif + // const-volatility specifiers template struct remove_cv { - typedef T type; + typedef T type; // SIMPLIFIED type }; template struct remove_const { - typedef T type; + typedef T type; // SIMPLIFIED type }; template struct remove_volatile { - typedef T type; + typedef T type; // SIMPLIFIED type }; + +#if CPPREFERENCE_STDVER >= 2014 +template +using remove_cv_t = T; // SIMPLIFIED typedef +template +using remove_const_t = T; // SIMPLIFIED typedef +template +using remove_volatile_t = T; // SIMPLIFIED typedef +#endif + template struct add_cv { - typedef T type; + typedef T type; // SIMPLIFIED type }; template struct add_const { - typedef T type; + typedef T type; // SIMPLIFIED type }; template struct add_volatile { - typedef T type; + typedef T type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using add_cv_t = T; // SIMPLIFIED typedef +template +using add_const_t = T; // SIMPLIFIED typedef +template +using add_volatile_t = T; // SIMPLIFIED typedef +#endif + // references template struct remove_reference { - typedef T type; + typedef T type; // SIMPLIFIED type }; template struct add_lvalue_reference { - typedef T type; + typedef T type; // SIMPLIFIED type }; template struct add_rvalue_reference { - typedef T type; + typedef T type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using remove_reference_t = T; // SIMPLIFIED typedef +template +using add_lvalue_reference_t = T; // SIMPLIFIED typedef +template +using add_rvalue_reference_t = T; // SIMPLIFIED typedef +#endif + // pointers template struct remove_pointer { - typedef T type; + typedef T type; // SIMPLIFIED type }; template struct add_pointer { - typedef T type; + typedef T* type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using remove_pointer_t = T; // SIMPLIFIED typedef +template +using add_pointer_t = T*; // SIMPLIFIED typedef +#endif + // sign modifiers template struct make_signed { - typedef T type; + typedef T type; // SIMPLIFIED type }; template struct make_unsigned { - typedef T type; + typedef T type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using make_signed_t = T; // SIMPLIFIED typedef +template +using make_unsigned_t = T; // SIMPLIFIED typedef +#endif + // arrays template struct remove_extent { - typedef T type; + typedef T type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using remove_extent_t = T; // SIMPLIFIED typedef +#endif + template struct remove_all_extents { - typedef T type; + typedef T type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using remove_all_extents_t = T; // SIMPLIFIED typedef +#endif // miscellaneous transformations template struct aligned_storage { - typedef int type; + typedef int type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using aligned_storage_t = int; // SIMPLIFIED typedef +#endif + template struct aligned_union { - typedef int type; + typedef int type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using aligned_union_t = int; // SIMPLIFIED typedef +#endif + template struct decay { - typedef int type; + typedef T type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using decay_t = T; // SIMPLIFIED typedef +#endif + +#if CPPREFERENCE_SIMPLIFY_TYPEDEFS + template struct enable_if { - typedef int type; + typedef int type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using enable_if_t = int; // SIMPLIFIED typedef +#endif + +#else + +template struct enable_if {}; + +template +struct enable_if { + typedef T type; +}; +#if CPPREFERENCE_STDVER >= 2014 +template +using enable_if_t = typename enable_if::type; +#endif + +#endif // CPPREFERENCE_SIMPLIFY_TYPEDEFS + template struct conditional { - typedef int type; + typedef int type; // SIMPLIFIED type }; +#if CPPREFERENCE_STDVER >= 2014 +template +using conditional_t = int; // SIMPLIFIED typedef +#endif + template struct common_type { typedef int type; }; +#if CPPREFERENCE_STDVER >= 2014 +template +using common_type_t = int; +#endif + template struct underlying_type { - typedef int type; + typedef int type; // SIMPLIFIED type }; -template class result_of { +#if CPPREFERENCE_STDVER >= 2014 +template +using underlying_type_t = int; // SIMPLIFIED typedef +#endif + +#if CPPREFERENCE_STDVER < 2020 +template +class result_of { typedef int type; -}; // SIMPLIFIED: removed specializatio +}; // SIMPLIFIED: removed specializations +#endif + +#if CPPREFERENCE_STDVER >= 2014 && CPPREFERENCE_STDVER < 2020 +template +using result_of_t = int; // SIMPLIFIED typedef +#endif + +#if CPPREFERENCE_STDVER >= 2017 +template +class invoke_result { + typedef int type; +}; // SIMPLIFIED: removed specializations + +template +using invoke_result_t = int; // SIMPLIFIED typedef +#endif } // namespace std diff --git a/headers/typeindex b/headers/typeindex index f76d2a0..405117a 100644 --- a/headers/typeindex +++ b/headers/typeindex @@ -17,6 +17,7 @@ #define CPPREFERENCE_TYPEINDEX_H #if CPPREFERENCE_STDVER>= 2011 +#include // for size_t #include namespace std { diff --git a/headers/typeinfo b/headers/typeinfo index 65f865c..68b5293 100644 --- a/headers/typeinfo +++ b/headers/typeinfo @@ -16,6 +16,7 @@ #ifndef CPPREFERENCE_TYPEINFO_H #define CPPREFERENCE_TYPEINFO_H +#include // for size_t #include namespace std { diff --git a/headers/unordered_map b/headers/unordered_map index b1fc53c..ae667db 100644 --- a/headers/unordered_map +++ b/headers/unordered_map @@ -20,6 +20,7 @@ #include #include // for size_t, ptrdiff_t +#include // for hash #include // for std::reverse_iterator #include // for std::allocator #include // for std::pair @@ -56,6 +57,9 @@ public: typedef value_type* local_iterator; // actual type is unspecified typedef const value_type* const_local_iterator; // actual type is unspecified + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + // constructor // constructor #if CPPREFERENCE_STDVER <2014 @@ -107,7 +111,7 @@ public: unordered_map(unordered_map&& other, const Allocator& alloc); unordered_map(std::initializer_list init, - size_type bucket_count = /*implementation-defined*/, + size_type bucket_count = /*implementation-defined*/0, const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(), const Allocator& alloc = Allocator()); @@ -266,6 +270,9 @@ public: typedef T* local_iterator; // actual type is unspecified typedef const T* const_local_iterator; // actual type is unspecified + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + // constructor // constructor #if CPPREFERENCE_STDVER <2014 @@ -317,7 +324,7 @@ public: unordered_multimap(unordered_multimap&& other, const Allocator& alloc); unordered_multimap(std::initializer_list init, - size_type bucket_count = /*implementation-defined*/, + size_type bucket_count = /*implementation-defined*/0, const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(), const Allocator& alloc = Allocator()); diff --git a/headers/unordered_set b/headers/unordered_set index d4f9799..51f1086 100644 --- a/headers/unordered_set +++ b/headers/unordered_set @@ -20,6 +20,7 @@ #include #include // for size_t, ptrdiff_t +#include // for hash #include // for std::allocator #include // for std::pair @@ -103,7 +104,7 @@ public: unordered_set(unordered_set&& other, const Allocator& alloc); unordered_set(std::initializer_list init, - size_type bucket_count = /*implementation-defined*/, + size_type bucket_count = /*implementation-defined*/0, const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(), const Allocator& alloc = Allocator()); @@ -237,10 +238,10 @@ public: typedef typename std::allocator_traits::pointer pointer; typedef typename std::allocator_traits::const_pointer const_pointer; #endif - typedef T* iterator; // actual type is unspecified - typedef const T* const_iterator; // actual type is unspecified - typedef T* local_iterator; // actual type is unspecified - typedef const T* const_local_iterator; // actual type is unspecified + typedef Key* iterator; // actual type is unspecified + typedef const Key* const_iterator; // actual type is unspecified + typedef Key* local_iterator; // actual type is unspecified + typedef const Key* const_local_iterator; // actual type is unspecified // constructor @@ -294,7 +295,7 @@ public: unordered_multiset(unordered_multiset&& other, const Allocator& alloc); unordered_multiset(std::initializer_list init, - size_type bucket_count = /*implementation-defined*/, + size_type bucket_count = /*implementation-defined*/0, const Hash& hash = Hash(), const KeyEqual& equal = KeyEqual(), const Allocator& alloc = Allocator()); @@ -408,3 +409,5 @@ void swap(unordered_multiset& lhs, } // namespace std #endif // CPPREFERENCE_STDVER>= 2011 + +#endif // CPPREFERENCE_UNORDERED_SET_H diff --git a/headers/utility b/headers/utility index 1344924..56209e8 100644 --- a/headers/utility +++ b/headers/utility @@ -20,6 +20,9 @@ #include #endif +#include // for size_t +#include // for remove_reference + namespace std { #if CPPREFERENCE_STDVER>= 2011 @@ -42,62 +45,134 @@ template bool operator>=(const T& lhs, const T& rhs); } // namespace rel_ops -#if CPPREFERENCE_STDVER>= 2014 +#if CPPREFERENCE_STDVER >= 2020 +template +constexpr T exchange(T& obj, U && new_value); +#elif CPPREFERENCE_STDVER >= 2014 template T exchange(T& obj, U && new_value); #endif -#if CPPREFERENCE_STDVER>= 2011 +#if CPPREFERENCE_STDVER >= 2014 +template +constexpr T&& forward(typename std::remove_reference::type& t); + +template +constexpr T&& forward(typename std::remove_reference::type&& t); +#elif CPPREFERENCE_STDVER >= 2011 template T&& forward(typename std::remove_reference::type& t); template T&& forward(typename std::remove_reference::type&& t); +#endif +#if CPPREFERENCE_STDVER >= 2014 +template +constexpr T&& move(T&& t); // SIMPLIFIED: return type +#elif CPPREFERENCE_STDVER >= 2011 template -typename T&& move(T&& t); // SIMPLIFIED: return type +T&& move(T&& t); // SIMPLIFIED: return type +#endif +#if CPPREFERENCE_STDVER >= 2014 +template +constexpr T&& move_if_noexcept(T&& t); // SIMPLIFIED: return type +#elif CPPREFERENCE_STDVER >= 2011 template -typename T&& move_if_noexcept(T&& t); // SIMPLIFIED: return type +T&& move_if_noexcept(T&& t); // SIMPLIFIED: return type +#endif +#if CPPREFERENCE_STDVER >= 2011 template T declval(); // SIMPLIFIED: return type +#endif +#if CPPREFERENCE_STDVER >= 2011 struct piecewise_construct_t { }; constexpr piecewise_construct_t piecewise_construct; #endif +#if CPPREFERENCE_STDVER >= 2017 +struct in_place_t {}; +inline constexpr in_place_t in_place; + +template +struct in_place_type_t{}; + +template +inline constexpr in_place_type_t in_place_type; + +template +struct in_place_index_t; + +template +inline constexpr in_place_index_t in_place_index; +#endif + +template class tuple; + template < class T1, class T2 - > struct pair { +> struct pair { typedef T1 first_type; typedef T2 second_type; T1 first; T2 second; +#if CPPREFERENCE_STDVER >= 2011 + constexpr pair(); +#else pair(); +#endif + +#if CPPREFERENCE_STDVER >= 2014 + constexpr pair(const T1& x, const T2& y); + + template + constexpr pair(const pair& p); + + constexpr pair(const pair& p); +#else pair(const T1& x, const T2& y); template pair(const pair& p); -#if CPPREFERENCE_STDVER>= 2011 + pair(const pair& p); +#endif + +#if CPPREFERENCE_STDVER >= 2014 + template + constexpr pair(U1&& x, U2&& y); + + template + constexpr pair(pair&& p); + + constexpr pair(pair&& p); +#elif CPPREFERENCE_STDVER >= 2011 template pair(U1&& x, U2&& y); template pair(pair&& p); + pair(pair&& p); +#endif + +#if CPPREFERENCE_STDVER >= 2020 + template + constexpr pair(std::piecewise_construct_t, + std::tuple first_args, + std::tuple second_args); +#elif CPPREFERENCE_STDVER >= 2011 template pair(std::piecewise_construct_t, std::tuple first_args, std::tuple second_args); #endif - pair(const pair& p); - pair(pair&& p); - pair& operator=(const pair& other); template @@ -113,6 +188,20 @@ template < void swap(pair& other); }; +#if CPPREFERENCE_STDVER >= 2014 +template +constexpr bool operator==(const pair& lhs, const pair& rhs); +template +constexpr bool operator!=(const pair& lhs, const pair& rhs); +template +constexpr bool operator<(const pair& lhs, const pair& rhs); +template +constexpr bool operator<=(const pair& lhs, const pair& rhs); +template +constexpr bool operator>(const pair& lhs, const pair& rhs); +template +constexpr bool operator>=(const pair& lhs, const pair& rhs); +#else template bool operator==(const pair& lhs, const pair& rhs); template @@ -125,25 +214,40 @@ template bool operator>(const pair& lhs, const pair& rhs); template bool operator>=(const pair& lhs, const pair& rhs); +#endif -#if CPPREFERENCE_STDVER <2011 +#if CPPREFERENCE_STDVER >= 2014 template -std::pair make_pair(T1 t, T2 u); -#else +constexpr std::pair make_pair(T1&& t, T2&& u); +#elif CPPREFERENCE_STDVER >= 2011 template std::pair make_pair(T1&& t, T2&& u); +#else +template +std::pair make_pair(T1 t, T2 u); #endif template void swap(pair& lhs, pair& rhs); #if CPPREFERENCE_STDVER>= 2011 +template +class tuple_element; + template -typename std::tuple_element>::type& +typename tuple_element>::type& get(pair& p); // SIMPLIFIED: additional overloads omitted #endif +#if CPPREFERENCE_STDVER >= 2014 +template +class tuple_size; + +template +class tuple_size > : public std::integral_constant { }; +#endif + } // namespace std #endif // CPPREFERENCE_UTILITY_H diff --git a/headers/valarray b/headers/valarray index 4b61f6f..3b407b7 100644 --- a/headers/valarray +++ b/headers/valarray @@ -20,8 +20,17 @@ #include // for std::initializer_list #endif +#include + namespace std { +template class slice_array; +template class gslice_array; +template class mask_array; +template class indirect_array; +class slice; +class gslice; + template class valarray { public: @@ -50,16 +59,19 @@ public: valarray& operator=(valarray&& other); #endif valarray& operator=(const T& val); - valarray& operator=(const std::slice_array& other); - valarray& operator=(const std::gslice_array& other); - valarray& operator=(const std::mask_array& other); - valarray& operator=(const std::indirect_array& other); + valarray& operator=(const std::slice_array& other); + valarray& operator=(const std::gslice_array& other); + valarray& operator=(const std::mask_array& other); + valarray& operator=(const std::indirect_array& other); #if CPPREFERENCE_STDVER>= 2011 valarray& operator=(std::initializer_list il); #endif +#if CPPREFERENCE_STDVER>= 2011 T operator[](std::size_t pos) const; +#else const T& operator[](std::size_t pos) const; +#endif T& operator[](std::size_t pos); std::valarray operator[](std::slice slicearr) const; std::slice_array operator[](std::slice slicearr); diff --git a/headers/variant b/headers/variant new file mode 100644 index 0000000..fed65ff --- /dev/null +++ b/headers/variant @@ -0,0 +1,228 @@ +/* Copyright (C) 2019 Povilas Kanapickas + + This file is part of cppreference-doc + + This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 + Unported License. To view a copy of this license, visit + http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative + Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. + + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 or + any later version published by the Free Software Foundation; with no + Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. +*/ + +#ifndef CPPREFERENCE_VARIANT_H +#define CPPREFERENCE_VARIANT_H + +#if CPPREFERENCE_STDVER >= 2017 + +#include // exception +#include // hash +#include // in_place_type_t, ... +#include +#include + +namespace std { + +inline constexpr std::size_t variant_npos = static_cast(-1); + +struct monostate {}; + +class bad_variant_access : public exception { +public: + bad_variant_access(); + ~bad_variant_access() override; + const char * what() const override; +}; + +template +class variant; // forward declaration + +template +struct variant_alternative; // undefined + +template +struct variant_alternative> { + using type = CPPREFERENCE_SIMPLIFIED_TYPE; +}; + +template +struct variant_alternative> { + using type = CPPREFERENCE_SIMPLIFIED_TYPE; +}; + +template +struct variant_alternative> { + using type = CPPREFERENCE_SIMPLIFIED_TYPE; +}; + +template +struct variant_alternative> { + using type = CPPREFERENCE_SIMPLIFIED_TYPE; +}; + +template +using variant_alternative_t = typename variant_alternative::type; + + +template +class variant { +public: + constexpr variant(); + + constexpr variant(const variant& other); + + constexpr variant(variant&& other); + + template + constexpr variant(T&& t); + + template + constexpr explicit variant(in_place_type_t, Args&&... args); + + template + + constexpr explicit variant(in_place_type_t, + initializer_list il, Args&&... args); + + template + constexpr explicit variant(in_place_index_t, Args&&... args); + + template + constexpr explicit variant(in_place_index_t, + initializer_list il, Args&&... args); + + ~variant(); + + constexpr variant& operator=(const variant& rhs); + + constexpr variant& operator=(variant&& rhs); + + template + variant& operator=(T&& t); + + constexpr size_t index() const; + + constexpr bool valueless_by_exception() const; + + template + T& emplace(Args&&... args); + + template + T& emplace(initializer_list il, Args&&... args); + + template + variant_alternative_t& emplace(Args&&... args); + + template + variant_alternative_t& + emplace(initializer_list il, Args&&... args); + + void swap(variant& rhs); +}; + +template +constexpr bool operator==(const variant& v, const variant& w); + +template +constexpr bool operator!=(const variant& v, const variant& w); + +template +constexpr bool operator<(const variant& v, const variant& w); + +template +constexpr bool operator>(const variant& v, const variant& w); + +template +constexpr bool operator<=(const variant& v, const variant& w); + +template +constexpr bool operator>=(const variant& v, const variant& w); + +template +void swap(variant& lhs, variant& rhs); + +template +constexpr CPPREFERENCE_SIMPLIFIED_TYPE visit(Visitor&& vis, Variants&&... vars); + +template +constexpr R visit(Visitor&&, Variants&&...); + +template +constexpr bool holds_alternative(const variant& v); + +template +constexpr variant_alternative_t>& + get(variant& v); + +template +constexpr variant_alternative_t>&& + get(variant&& v); + +template +constexpr const variant_alternative_t>& + get(const variant& v); + +template +constexpr const variant_alternative_t>& + get(const variant&& v); + +template +constexpr T& get(variant& v); + +template +constexpr T&& get(variant&& v); + +template +constexpr const T& get(const variant& v); + +template +constexpr const T&& get(const variant&& v); + +template + +constexpr add_pointer_t>> + get_if(variant* pv); + +template +constexpr add_pointer_t>> + get_if(const variant* pv); + +template +constexpr add_pointer_t get_if(variant* pv); +template +constexpr add_pointer_t get_if(const variant* pv); + +template +struct variant_size; // undefined + +template +struct variant_size> : + integral_constant { +}; + +template +struct variant_size> : + integral_constant { +}; + +template +struct variant_size> : + integral_constant { +}; + +template +struct variant_size> : + integral_constant { +}; + + +template +struct hash> {}; + +} // namespace std + +#endif // CPPREFERENCE_STDVER >= 2017 +#endif // CPPREFERENCE_VARIANT_H diff --git a/headers/vector b/headers/vector index 5b2836e..4f5810b 100644 --- a/headers/vector +++ b/headers/vector @@ -18,7 +18,7 @@ #if CPPREFERENCE_STDVER >= 2011 #include -#endif` +#endif #include // for size_t, ptrdiff_t #include // for std::reverse_iterator diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 062917d..157a9e1 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -2089,6 +2089,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/index2autolinker.py b/index2autolinker.py index 7a51824..45ebc44 100755 --- a/index2autolinker.py +++ b/index2autolinker.py @@ -65,7 +65,7 @@ def main(): tr.transform_file(args.index) links = tr.links - json_groups = [v for v in groups.values()] + json_groups = list(groups.values()) json_groups = sorted(json_groups, key=lambda x: x['name']) links = sorted(links, key=lambda x: x['target']) diff --git a/index2ddg.py b/index2ddg.py index 0cfa557..f8c9e12 100755 --- a/index2ddg.py +++ b/index2ddg.py @@ -554,12 +554,12 @@ def main(): proc_ins = get_processing_instructions(ident_map, link_map) # sort proc_ins to produce ordered output.txt - proc_ins = [v for v in proc_ins.values()] + proc_ins = list(proc_ins.values()) proc_ins = sorted(proc_ins, key=lambda x: x['link']) for page in proc_ins: idents = page['idents'] - idents = [v for v in idents.values()] + idents = list(idents.values()) idents = sorted(idents, key=lambda x: x['ident']) page['idents'] = idents