From 824afb289f6484ab904058e7de3c583b34710a86 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 1 Oct 2018 20:29:29 -0700 Subject: [PATCH 001/114] Preprocess: Fix refactor error not caught by tests --- preprocess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocess.py b/preprocess.py index 3fe09e0e4..5747d246e 100755 --- a/preprocess.py +++ b/preprocess.py @@ -47,7 +47,7 @@ def main(): with concurrent.futures.ProcessPoolExecutor() as executor: futures = [executor.submit(preprocess.preprocess_html_file, root, fn, rename_map) - for fn in enumerate(file_list)] + for fn in file_list] for future in futures: output = future.result() From 6015685710ce19fdbf764f816f1cf77a61826bdd Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 1 Oct 2018 21:17:17 -0700 Subject: [PATCH 002/114] Preprocess: Cache style parsing results This leads to around 50% performance improvement of cssless processing. --- commands/preprocess_cssless.py | 47 +++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/commands/preprocess_cssless.py b/commands/preprocess_cssless.py index 960ffaf30..2f75d5ae0 100644 --- a/commands/preprocess_cssless.py +++ b/commands/preprocess_cssless.py @@ -21,10 +21,12 @@ from lxml import etree from io import StringIO from lxml.etree import strip_elements +import copy +import functools +import io import logging import os import warnings -import io def preprocess_html_merge_cssless(src_path, dst_path): with open(src_path, 'r') as a_file: @@ -86,28 +88,49 @@ def needs_td_wrapper(element): return False return True -def remove_css_property(element, property_name): - atrib = cssutils.parseStyle(element.get('style')) - atrib.removeProperty(property_name) - element.set('style', atrib.getCssText(separator='')) - if len(element.get('style')) == 0: - element.attrib.pop('style') +@functools.lru_cache(maxsize=None) +def cssutils_parse_style_cached_nocopy(style): + return cssutils.parseStyle(style) -def get_css_property_value(el, prop_name): - atrib = cssutils.parseStyle(el.get('style')) +def cssutils_parse_style_cached(style): + return copy.deepcopy(cssutils_parse_style_cached_nocopy(style)) + +@functools.lru_cache(maxsize=None) +def get_css_style_property_value(style, prop_name): + atrib = cssutils_parse_style_cached_nocopy(style) value = atrib.getPropertyCSSValue(prop_name) if value: return value.cssText return None -def has_css_property_value(el, prop_name, prop_value): - value = get_css_property_value(el, prop_name) +@functools.lru_cache(maxsize=None) +def has_css_style_property_value(style, prop_name, prop_value): + value = get_css_style_property_value(style, prop_name) if value and value == prop_value: return True return False +@functools.lru_cache(maxsize=None) +def remove_css_style_property(style, property_name): + atrib = cssutils_parse_style_cached(style) + atrib.removeProperty(property_name) + return atrib.getCssText(separator='') + +def remove_css_property(element, property_name): + new_style = remove_css_style_property(element.get('style'), property_name) + if len(new_style) > 0: + element.set('style', new_style) + elif 'style' in element.attrib: + element.attrib.pop('style') + +def get_css_property_value(el, prop_name): + return get_css_style_property_value(el.get('style'), prop_name) + +def has_css_property_value(el, prop_name, prop_value): + return has_css_style_property_value(el.get('style'), prop_name, prop_value) + def set_css_property_value(el, prop_name, prop_value): - atrib = cssutils.parseStyle(el.get('style')) + atrib = cssutils_parse_style_cached(el.get('style')) atrib.setProperty(prop_name, prop_value) el.set('style', atrib.getCssText(separator='')) From 084e449388f8c3b587478e2f6fbba893ead107d3 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 7 Oct 2018 16:56:58 +0200 Subject: [PATCH 003/114] Preprocess: fix removal of See Also links This fixes removal of See Also links between the C and C++ parts of the documentation. --- commands/preprocess.py | 22 ++++++---------------- tests/preprocess_data/fabs_seealso.html | 4 ---- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/commands/preprocess.py b/commands/preprocess.py index 2412aa631..17ef42f26 100644 --- a/commands/preprocess.py +++ b/commands/preprocess.py @@ -257,17 +257,17 @@ def remove_noprint(html): # remove see also links between C and C++ documentations def remove_see_also(html): for el in html.xpath('//tr[@class]'): - if not has_class(el, 't-dcl-list-item'): + if not has_class(el, 't-dcl-list-item', 't-dsc'): continue child_tds = el.xpath('.//td/div[@class]') - if not any(has_class(td, 't-dcl-list-see') for td in child_tds): + if not any(has_class(td, 't-dcl-list-see', 't-dsc-see') for td in child_tds): continue # remove preceding separator, if any prev = el.getprevious() if prev is not None: - child_tds = prev.xpath('.//td[@class') + child_tds = prev.xpath('.//td[@class]') if any(has_class(td, 't-dcl-list-sep') for td in child_tds): prev.getparent().remove(prev) @@ -280,19 +280,9 @@ def remove_see_also(html): next = el.getnext() if next is None: el.getparent().remove(el) - continue - - if next.tag != 'table': - continue - - if not has_class(next, 't-dcl-list-begin'): - continue - - if len(next.xpath('.//tr')) > 0: - continue - - el.getparent().remove(el) - next.getparent().remove(next) + elif next.tag == 'table' and has_class(next, 't-dcl-list-begin') and len(next.xpath('.//tr')) == 0: + el.getparent().remove(el) + next.getparent().remove(next) # remove Google Analytics scripts def remove_google_analytics(html): diff --git a/tests/preprocess_data/fabs_seealso.html b/tests/preprocess_data/fabs_seealso.html index 9e669b115..c9c0e44b0 100644 --- a/tests/preprocess_data/fabs_seealso.html +++ b/tests/preprocess_data/fabs_seealso.html @@ -590,10 +590,6 @@

[std::abs to each element of valarray
(function template)
[edit] - - - - -
< cpp‎ | numeric‎ | math
+
< cpp‎ | numeric‎ | math
- +
[edit]
 
- + - + - + @@ -475,22 +475,22 @@

-

+ - + - + - + @@ -526,6 +526,13 @@

[[edit] Return value

If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.

+
+
cpp/io/ios basecpp/io/basic ioscpp/io/basic istreamcpp/io/basic ifstreamcpp/io/basic istringstreamcpp/io/basic ostreamcpp/io/basic ofstreamcpp/io/basic ostringstreamcpp/io/basic fstreamcpp/io/basic stringstreamcpp/io/basic iostreamstd-io-complete-inheritance.svg
About this image
+
+

Inheritance diagram +

+
+

[edit] Error handling

This function is not subject to any of the error conditions specified in math_errhandling

If the implementation supports IEEE floating-point arithmetic (IEC 60559), @@ -541,15 +548,15 @@

[
#include <iostream>
 #include <cmath>
- 
-int main()
-{
-    std::cout << "abs(+3.0) = " << std::abs(+3.0) << '\n'
-              << "abs(-3.0) = " << std::abs(-3.0) << '\n';
+ 
+int main()
+{
+    std::cout << "abs(+3.0) = " << std::abs(+3.0) << '\n'
+              << "abs(-3.0) = " << std::abs(-3.0) << '\n';
     // special values
-    std::cout << "abs(-0.0) = " << std::abs(-0.0) << '\n'
-              << "abs(-Inf) = " << std::abs(-INFINITY) << '\n';
-}
+ std::cout << "abs(-0.0) = " << std::abs(-0.0) << '\n' + << "abs(-Inf) = " << std::abs(-INFINITY) << '\n'; +}

Possible output:

abs(+3.0) = 3
@@ -563,31 +570,31 @@ 

[

- - - - - @@ -613,7 +620,7 @@

[https://en.cppreference.com/mwiki/index.php?title=cpp/numeric/math/fabs&oldid=88521" - +
@@ -651,7 +658,7 @@

Toolbox
@@ -678,4 +685,4 @@
Toolbox
- + \ No newline at end of file diff --git a/tests/preprocess_data/fabs_ads.html b/tests/preprocess_data/fabs_ads.html index 3e7fbaac6..2d34bcd46 100644 --- a/tests/preprocess_data/fabs_ads.html +++ b/tests/preprocess_data/fabs_ads.html @@ -462,6 +462,13 @@

[[edit] Return value

If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.

+
+
cpp/io/ios basecpp/io/basic ioscpp/io/basic istreamcpp/io/basic ifstreamcpp/io/basic istringstreamcpp/io/basic ostreamcpp/io/basic ofstreamcpp/io/basic ostringstreamcpp/io/basic fstreamcpp/io/basic stringstreamcpp/io/basic iostreamstd-io-complete-inheritance.svg
About this image
+
+

Inheritance diagram +

+
+

[edit] Error handling

This function is not subject to any of the error conditions specified in math_errhandling

If the implementation supports IEEE floating-point arithmetic (IEC 60559), diff --git a/tests/preprocess_data/fabs_fileinfo.html b/tests/preprocess_data/fabs_fileinfo.html new file mode 100644 index 000000000..339da884c --- /dev/null +++ b/tests/preprocess_data/fabs_fileinfo.html @@ -0,0 +1,688 @@ + + + +std::abs(float), std::fabs - cppreference.com + + + + + + + + + + + + + + + + + + + +

+
+
+
+ cppreference.com
+ +
+ + + + + +
+ +
+
+
+
+
+ + +
+
Namespaces
+ +
+ + + + +
+
Variants
+ +
+ + +
+
+ + +
+
Views
+ +
+ + + + +
+
Actions
+ +
+ + +
+
+
+
+ + + +
+
+ + + + +

std::abs(float), std::fabs

+ + +
+ +
From cppreference.com
+ + +
< cpp‎ | numeric‎ | math
+ + +
Defined in header <cmath> @@ -454,17 +454,17 @@

(since C++17)

float       abs( float arg );
float       abs( float arg );
(1)
double      abs( double arg );
double      abs( double arg );
(2)
long double abs( long double arg );
long double abs( long double arg );
(3)
float       fabs( float arg );
float       fabs( float arg );
(4)
double      fabs( double arg );
double      fabs( double arg );
(5)
long double fabs( long double arg );
long double fabs( long double arg );
(6)
double      fabs( Integral arg );
double      fabs( Integral arg );
(7) (since C++11)
computes absolute value of an integral value (|x|)
(function) [edit] +
computes absolute value of an integral value (|x|)
(function) [edit]
(C++11)
copies the sign of a floating point value
(function) [edit] +
copies the sign of a floating point value
(function) [edit]
(C++11)
checks if the given number is negative
(function) [edit] +
checks if the given number is negative
(function) [edit]
returns the magnitude of a complex number
(function template) [edit] +
returns the magnitude of a complex number
(function template) [edit]
applies the function std::abs to each element of valarray
(function template) [edit] +
applies the function std::abs to each element of valarray
(function template) [edit]
+ + + + + + + + + + + + + + + + + + + +
Language
Headers
Named requirements
Language support library
Concepts library (C++20)
Diagnostics library
Utilities library
Strings library
Containers library
Algorithms library
Iterators library
Numerics library
Input/output library
Localizations library
Regular expressions library (C++11)
Atomic operations library (C++11)
Thread support library (C++11)
Filesystem library (C++17)
Technical Specifications
[edit]
 
 
Common mathematical functions
+
+ + + + + + + + + +
Functions
Basic operations
+ + + + +
abs(float)fabs
+ + + + + + + +
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Exponential functions
+ + + +
(C++11)
(C++11)
+ + + + +
(C++11)
(C++11)
Power functions
+ + +
(C++11)
+ + +
(C++11)
Trigonometric and hyperbolic functions
+ + + + + + +
(C++11)
(C++11)
(C++11)
+
+
+
+ + + + + + + + + + +
Error and gamma functions
+ + +
(C++11)
(C++11)
+ + +
(C++11)
(C++11)
Nearest integer floating point operations
+ + + +
(C++11)(C++11)(C++11)
+ + + +
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Floating point manipulation functions
+ + + + +
(C++11)(C++11)
(C++11)
(C++11)
+ + + + +
(C++11)(C++11)
(C++11)
Classification/Comparison
+ + + + + + +
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
+ + + + + + +
(C++11)
(C++11)
Macro constants
+ +
(C++11)(C++11)(C++11)(C++11)(C++11)
+
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Defined in header <cmath> +
Defined in header <cstdlib> +
(since C++17)
float       abs( float arg );
(1)
double      abs( double arg );
(2)
long double abs( long double arg );
(3)
Defined in header <cmath> +
float       fabs( float arg );
(4)
double      fabs( double arg );
(5)
long double fabs( long double arg );
(6)
double      fabs( Integral arg );
(7) (since C++11)
+
1-6) Computes the absolute value of a floating point value arg.
+
7) A set of overloads or a function template for all combinations of arguments of arithmetic type not covered by (4-6). If any argument has integral type, it is cast to double. If any other argument is long double, then the return type is long double, otherwise it is double.
+ + + +
For integral arguments, the integral overloads of std::abs are likely better matches. If std::abs is called with an argument of type X such that std::is_unsigned<X>::value is true and X cannot be converted to int by integral promotion, the program is ill-formed.(since C++17)
+

Contents

+ +
+

[edit] Parameters

+ + + + + + +
arg + - + Value of a floating-point or Integral type +
+

[edit] Return value

+

If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes. +

+
+
cpp/io/ios basecpp/io/basic ioscpp/io/basic istreamcpp/io/basic ifstreamcpp/io/basic istringstreamcpp/io/basic ostreamcpp/io/basic ofstreamcpp/io/basic ostringstreamcpp/io/basic fstreamcpp/io/basic stringstreamcpp/io/basic iostreamstd-io-complete-inheritance.svg
+
+

Inheritance diagram +

+
+
+

[edit] Error handling

+

This function is not subject to any of the error conditions specified in math_errhandling +

If the implementation supports IEEE floating-point arithmetic (IEC 60559), +

+
  • If the argument is ±0, +0 is returned +
  • If the argument is ±∞, +∞ is returned +
  • If the argument is NaN, NaN is returned +
+

[edit] Notes

+

Between C++11 and C++14, the standard erroneously required std::abs to have overloads for integer types returning double. This requirement was removed in C++17 by defect report 2735. +

+

[edit] Example

+
+
#include <iostream>
+#include <cmath>
+ 
+int main()
+{
+    std::cout << "abs(+3.0) = " << std::abs(+3.0) << '\n'
+              << "abs(-3.0) = " << std::abs(-3.0) << '\n';
+    // special values
+    std::cout << "abs(-0.0) = " << std::abs(-0.0) << '\n'
+              << "abs(-Inf) = " << std::abs(-INFINITY) << '\n';
+}
+

Possible output: +

+
abs(+3.0) = 3
+abs(-3.0) = 3
+abs(-0.0) = 0
+abs(-Inf) = inf
+
+

[edit] See also

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ computes absolute value of an integral value (|x|)
(function) [edit] +
(C++11)
+
copies the sign of a floating point value
(function) [edit] +
(C++11)
+
checks if the given number is negative
(function) [edit] +
+ returns the magnitude of a complex number
(function template) [edit] +
+ applies the function std::abs to each element of valarray
(function template) [edit] +
+
+ + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/preprocess_data/fabs_ga.html b/tests/preprocess_data/fabs_ga.html index 6996631b1..334e170a2 100644 --- a/tests/preprocess_data/fabs_ga.html +++ b/tests/preprocess_data/fabs_ga.html @@ -526,6 +526,13 @@

[[edit] Return value

If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.

+
+
cpp/io/ios basecpp/io/basic ioscpp/io/basic istreamcpp/io/basic ifstreamcpp/io/basic istringstreamcpp/io/basic ostreamcpp/io/basic ofstreamcpp/io/basic ostringstreamcpp/io/basic fstreamcpp/io/basic stringstreamcpp/io/basic iostreamstd-io-complete-inheritance.svg
About this image
+
+

Inheritance diagram +

+
+

[edit] Error handling

This function is not subject to any of the error conditions specified in math_errhandling

If the implementation supports IEEE floating-point arithmetic (IEC 60559), diff --git a/tests/preprocess_data/fabs_noprint.html b/tests/preprocess_data/fabs_noprint.html index 3f146bd5c..c83cd6eee 100644 --- a/tests/preprocess_data/fabs_noprint.html +++ b/tests/preprocess_data/fabs_noprint.html @@ -428,6 +428,13 @@

Parameters

Return value

If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.

+
+
cpp/io/ios basecpp/io/basic ioscpp/io/basic istreamcpp/io/basic ifstreamcpp/io/basic istringstreamcpp/io/basic ostreamcpp/io/basic ofstreamcpp/io/basic ostringstreamcpp/io/basic fstreamcpp/io/basic stringstreamcpp/io/basic iostreamstd-io-complete-inheritance.svg
About this image
+
+

Inheritance diagram +

+
+

Error handling

This function is not subject to any of the error conditions specified in math_errhandling

If the implementation supports IEEE floating-point arithmetic (IEC 60559), diff --git a/tests/preprocess_data/fabs_seealso.html b/tests/preprocess_data/fabs_seealso.html index 9e669b115..c247287ee 100644 --- a/tests/preprocess_data/fabs_seealso.html +++ b/tests/preprocess_data/fabs_seealso.html @@ -526,6 +526,13 @@

[[edit] Return value

If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes.

+
+
cpp/io/ios basecpp/io/basic ioscpp/io/basic istreamcpp/io/basic ifstreamcpp/io/basic istringstreamcpp/io/basic ostreamcpp/io/basic ofstreamcpp/io/basic ostringstreamcpp/io/basic fstreamcpp/io/basic stringstreamcpp/io/basic iostreamstd-io-complete-inheritance.svg
About this image
+
+

Inheritance diagram +

+
+

[edit] Error handling

This function is not subject to any of the error conditions specified in math_errhandling

If the implementation supports IEEE floating-point arithmetic (IEC 60559), diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index 0c6568c9b..f397bb7fb 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -226,6 +226,10 @@ def test_remove_ads(self): remove_ads(self.html) self.check_output("fabs_ads.html") + def test_remove_fileinfo(self): + remove_fileinfo(self.html) + self.check_output("fabs_fileinfo.html") + def remove_unused_external(self): # TODO split out and test pass From 59210a736f21c0cf5331476fe37328e6814e4b00 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Wed, 10 Oct 2018 13:53:15 +0200 Subject: [PATCH 009/114] Preprocess: add test for unused external link removal This splits out removal of unused external links into a separate function and adds a test. This also adds adjustment of the favicon path to the rearranged archive structure which was missing before. --- commands/preprocess.py | 15 +- tests/preprocess_data/fabs_external.html | 683 +++++++++++++++++++++++ tests/test_preprocess.py | 4 +- 3 files changed, 695 insertions(+), 7 deletions(-) create mode 100644 tests/preprocess_data/fabs_external.html diff --git a/commands/preprocess.py b/commands/preprocess.py index 1d7737f14..219d2d687 100644 --- a/commands/preprocess.py +++ b/commands/preprocess.py @@ -318,16 +318,21 @@ def remove_fileinfo(html): for el in info(html): el.getparent().remove(el) +# remove external links to unused resources +def remove_unused_external(html): + for el in html.xpath('/html/head/link'): + if el.get('rel') in ('alternate', 'search', 'edit', 'EditURI'): + el.getparent().remove(el) + elif el.get('rel') == 'shortcut icon': + (head, tail) = os.path.split(el.get('href')) + el.set('href', os.path.join(head, 'common', tail)) + def preprocess_html_file(root, fn, rename_map): parser = etree.HTMLParser() html = etree.parse(fn, parser) output = io.StringIO() - # remove external links to unused resources - for el in html.xpath('/html/head/link'): - if el.get('rel') in [ 'alternate', 'search', 'edit', 'EditURI' ]: - el.getparent().remove(el) - + remove_unused_external(html) remove_noprint(html) remove_see_also(html) remove_google_analytics(html) diff --git a/tests/preprocess_data/fabs_external.html b/tests/preprocess_data/fabs_external.html new file mode 100644 index 000000000..0c8a4f45d --- /dev/null +++ b/tests/preprocess_data/fabs_external.html @@ -0,0 +1,683 @@ + + + +std::abs(float), std::fabs - cppreference.com + + + + + + + + + + + + + + +

+
+
+
+ cppreference.com
+ +
+ + + + + +
+ +
+
+
+
+
+ + +
+
Namespaces
+ +
+ + + + +
+
Variants
+ +
+ + +
+
+ + +
+
Views
+ +
+ + + + +
+
Actions
+ +
+ + +
+
+
+
+ + + +
+
+ + + + +

std::abs(float), std::fabs

+ + +
+ +
From cppreference.com
+ + +
< cpp‎ | numeric‎ | math
+ + +
 
 
 
Common mathematical functions
+
+ + + + + + + + + +
Functions
Basic operations
+ + + + +
abs(float)fabs
+ + + + + + + +
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Exponential functions
+ + + +
(C++11)
(C++11)
+ + + + +
(C++11)
(C++11)
Power functions
+ + +
(C++11)
+ + +
(C++11)
Trigonometric and hyperbolic functions
+ + + + + + +
(C++11)
(C++11)
(C++11)
+
+
+
+ + + + + + + + + + +
Error and gamma functions
+ + +
(C++11)
(C++11)
+ + +
(C++11)
(C++11)
Nearest integer floating point operations
+ + + +
(C++11)(C++11)(C++11)
+ + + +
(C++11)
(C++11)
(C++11)(C++11)(C++11)
Floating point manipulation functions
+ + + + +
(C++11)(C++11)
(C++11)
(C++11)
+ + + + +
(C++11)(C++11)
(C++11)
Classification/Comparison
+ + + + + + +
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
+ + + + + + +
(C++11)
(C++11)
Macro constants
+ +
(C++11)(C++11)(C++11)(C++11)(C++11)
+
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Defined in header <cmath> +
Defined in header <cstdlib> +
(since C++17)
float       abs( float arg );
(1)
double      abs( double arg );
(2)
long double abs( long double arg );
(3)
Defined in header <cmath> +
float       fabs( float arg );
(4)
double      fabs( double arg );
(5)
long double fabs( long double arg );
(6)
double      fabs( Integral arg );
(7) (since C++11)
+
1-6) Computes the absolute value of a floating point value arg.
+
7) A set of overloads or a function template for all combinations of arguments of arithmetic type not covered by (4-6). If any argument has integral type, it is cast to double. If any other argument is long double, then the return type is long double, otherwise it is double.
+ + + +
For integral arguments, the integral overloads of std::abs are likely better matches. If std::abs is called with an argument of type X such that std::is_unsigned<X>::value is true and X cannot be converted to int by integral promotion, the program is ill-formed.(since C++17)
+

Contents

+ +
+

[edit] Parameters

+ + + + + + +
arg + - + Value of a floating-point or Integral type +
+

[edit] Return value

+

If successful, returns the absolute value of arg (|arg|). The value returned is exact and does not depend on any rounding modes. +

+
+
cpp/io/ios basecpp/io/basic ioscpp/io/basic istreamcpp/io/basic ifstreamcpp/io/basic istringstreamcpp/io/basic ostreamcpp/io/basic ofstreamcpp/io/basic ostringstreamcpp/io/basic fstreamcpp/io/basic stringstreamcpp/io/basic iostreamstd-io-complete-inheritance.svg
About this image
+
+

Inheritance diagram +

+
+
+

[edit] Error handling

+

This function is not subject to any of the error conditions specified in math_errhandling +

If the implementation supports IEEE floating-point arithmetic (IEC 60559), +

+
  • If the argument is ±0, +0 is returned +
  • If the argument is ±∞, +∞ is returned +
  • If the argument is NaN, NaN is returned +
+

[edit] Notes

+

Between C++11 and C++14, the standard erroneously required std::abs to have overloads for integer types returning double. This requirement was removed in C++17 by defect report 2735. +

+

[edit] Example

+
+
#include <iostream>
+#include <cmath>
+ 
+int main()
+{
+    std::cout << "abs(+3.0) = " << std::abs(+3.0) << '\n'
+              << "abs(-3.0) = " << std::abs(-3.0) << '\n';
+    // special values
+    std::cout << "abs(-0.0) = " << std::abs(-0.0) << '\n'
+              << "abs(-Inf) = " << std::abs(-INFINITY) << '\n';
+}
+

Possible output: +

+
abs(+3.0) = 3
+abs(-3.0) = 3
+abs(-0.0) = 0
+abs(-Inf) = inf
+
+

[edit] See also

+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ computes absolute value of an integral value (|x|)
(function) [edit] +
(C++11)
+
copies the sign of a floating point value
(function) [edit] +
(C++11)
+
checks if the given number is negative
(function) [edit] +
+ returns the magnitude of a complex number
(function template) [edit] +
+ applies the function std::abs to each element of valarray
(function template) [edit] +
+
+ + + + +
+ + + + + +
+ + +
+ +
+
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index f397bb7fb..6984c5765 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -231,5 +231,5 @@ def test_remove_fileinfo(self): self.check_output("fabs_fileinfo.html") def remove_unused_external(self): - # TODO split out and test - pass + remove_unused_external(self.html) + self.check_output("fabs_external.html") From dacac63bbea63b96f3ebfdeff5609f05a63e0b30 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Wed, 17 Oct 2018 16:49:31 +0200 Subject: [PATCH 010/114] Preprocess: simplify file renaming This simplifies file renaming by using a map from old to new name. The new rename map doesn't store file paths any more, so the directory tree needs to be walked twice (once for searching, once for renaming), but transforming relative links is a lot simpler because it can use a map lookup instead of trying every entry in the rename map. Transformation of relative links now uses urllib for parsing URLs, so matching and transformation should be more robust for exotic links. --- commands/preprocess.py | 123 +++++++++++++++------------------------ preprocess.py | 2 +- tests/test_preprocess.py | 27 +++++++-- 3 files changed, 70 insertions(+), 82 deletions(-) diff --git a/commands/preprocess.py b/commands/preprocess.py index 4ff914f97..1fbae13f4 100644 --- a/commands/preprocess.py +++ b/commands/preprocess.py @@ -81,15 +81,7 @@ def rearrange_archive(root): for fn in fnmatch.filter(os.listdir(root), 'cppreference-export*.xml'): os.remove(os.path.join(root, fn)) -def add_file_to_rename_map(rename_map, dir, fn, new_fn): - path = os.path.join(dir, fn) - if not os.path.isfile(path): - print("ERROR: Not renaming '{0}' because path does not exist".format(path)) - return - rename_map.append((dir, fn, new_fn)) - -# Converts complex URL to resources supplied by MediaWiki loader to a simplified -# name +# Converts complex URL to resources supplied by MediaWiki loader to a simplified name def convert_loader_name(fn): if "modules=site&only=scripts" in fn: return "site_scripts.js" @@ -105,55 +97,36 @@ def convert_loader_name(fn): raise Exception('Loader file {0} does not match any known files'.format(fn)) def find_files_to_be_renamed(root): - # Returns a rename map: array of tuples each of which contain three strings: - # the directory the file resides in, the source and destination filenames. - - # The rename map specifies files to be renamed in order to support them on - # windows filesystems which don't support certain characters in file names - rename_map = [] - - files_rename = [] # general files to be renamed - files_loader = [] # files served by load.php. These should map to - # consistent and short file names because we - # modify some of them later in the pipeline - - for dir, _, filenames in os.walk(root): - filenames_loader = set(fnmatch.filter(filenames, 'load.php[?]*')) - # match any filenames with '?"*' characters - filenames_rename = set(fnmatch.filter(filenames, '*[?"*]*')) - - # don't process load.php files in general rename handler - filenames_rename -= filenames_loader - - for fn in filenames_loader: - files_loader.append((dir, fn)) - for fn in filenames_rename: - files_rename.append((dir, fn)) - - for dir, orig_fn in files_rename: - fn = orig_fn - fn = re.sub(r'\?.*', '', fn) - fn = fn.replace('"', '_q_') - fn = fn.replace('*', '_star_') - add_file_to_rename_map(rename_map, dir, orig_fn, fn) - - # map loader names to more recognizable names - for dir, fn in files_loader: - new_fn = convert_loader_name(fn) - add_file_to_rename_map(rename_map, dir, fn, new_fn) - - # rename filenames that conflict on case-insensitive filesystems - # TODO: perform this automatically - add_file_to_rename_map(rename_map, os.path.join(root, 'en/cpp/numeric/math'), 'NAN.html', 'NAN.2.html') - add_file_to_rename_map(rename_map, os.path.join(root, 'en/c/numeric/math'), 'NAN.html', 'NAN.2.html') - return rename_map - -def rename_files(rename_map): - for dir, old_fn, new_fn in rename_map: - src_path = os.path.join(dir, old_fn) - dst_path = os.path.join(dir, new_fn) - print("Renaming '{0}' to \n '{1}'".format(src_path, dst_path)) - shutil.move(src_path, dst_path) + # Returns a rename map: a map from old to new file name + loader = re.compile(r'load\.php\?.*') + query = re.compile(r'\?.*') + result = dict() + + # find files with invalid names -> rename all occurrences + for fn in set(fn for _, _, filenames in os.walk(root) for fn in filenames): + if loader.match(fn): + result[fn] = convert_loader_name(fn) + + elif any((c in fn) for c in '?*"'): + new_fn = query.sub('', fn) + new_fn = new_fn.replace('"', '_q_') + new_fn = new_fn.replace('*', '_star_') + result[fn] = new_fn + + # rename files that conflict on case-insensitive filesystems + # TODO perform this automatically + result['NAN.html'] = 'NAN.2.html' + + return result + +def rename_files(root, rename_map): + for dir, old_fn in ((dir, fn) for dir, _, filenames in os.walk(root) for fn in filenames): + new_fn = rename_map.get(old_fn) + if new_fn is not None: + src_path = os.path.join(dir, old_fn) + dst_path = os.path.join(dir, new_fn) + print("Renaming '{0}' to \n '{1}'".format(src_path, dst_path)) + shutil.move(src_path, dst_path) def find_html_files(root): # find files that need to be preprocessed @@ -199,26 +172,24 @@ def transform_ranges_placeholder(target, file, root): return os.path.relpath(abstarget, os.path.dirname(file)) def is_external_link(target): - external_link_patterns = [ - 'http://', - 'https://', - 'ftp://' - ] - for pattern in external_link_patterns: - if target.startswith(pattern): - return True - return False + url = urllib.parse.urlparse(target) + return url.scheme != '' or url.netloc != '' def trasform_relative_link(rename_map, target): - target = urllib.parse.unquote(target) - for _, fn, new_fn in rename_map: - target = target.replace(fn, new_fn) - target = target.replace('../../upload.cppreference.com/mwiki/','../common/') - target = target.replace('../mwiki/','../common/') - target = re.sub(r'(\.php|\.css)\?.*', r'\1', target) - target = urllib.parse.quote(target) - target = target.replace('%23', '#') - return target + # urllib.parse tuple is (scheme, host, path, params, query, fragment) + _, _, path, params, _, fragment = urllib.parse.urlparse(target) + assert params == '' + + path = urllib.parse.unquote(path) + path = path.replace('../../upload.cppreference.com/mwiki/','../common/') + path = path.replace('../mwiki/','../common/') + + dir, fn = os.path.split(path) + fn = rename_map.get(fn, fn) + path = os.path.join(dir, fn) + + path = urllib.parse.quote(path) + return urllib.parse.urlunparse(('', '', path, params, '', fragment)) # Transforms a link in the given file according to rename map. # target is the link to transform. diff --git a/preprocess.py b/preprocess.py index 0f36bf991..c78945c19 100755 --- a/preprocess.py +++ b/preprocess.py @@ -39,7 +39,7 @@ def main(): preprocess.rearrange_archive(root) rename_map = preprocess.find_files_to_be_renamed(root) - preprocess.rename_files(rename_map) + preprocess.rename_files(root, rename_map) # clean the html files file_list = preprocess.find_html_files(root) diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index 6984c5765..b0e7ee8f0 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -90,11 +90,28 @@ def test_has_class(self): class TestIsExternalLink(unittest.TestCase): def test_is_external_link(self): - self.assertEqual(True, is_external_link('http://a')) - self.assertEqual(True, is_external_link('https://a')) - self.assertEqual(True, is_external_link('ftp://a')) - self.assertEqual(False, is_external_link('ahttp://a')) - self.assertEqual(False, is_external_link(' http://a')) + external = [ + 'http://example.com', + 'https://example.com', + 'ftp://example.com', + 'ftps://example.com', + 'slack://example.com', + 'https:///foo.html', # Not technically external, but we say so anyway + '//example.com' + ] + for link in external: + self.assertTrue(is_external_link(link), + msg="Should be external: {}".format(link)) + + relative = [ + '/example.com', + '../foo.html', + 'foo.html', + 'foo' + ] + for link in relative: + self.assertFalse(is_external_link(link), + msg="Should not be external: {}".format(link)) class TestPlaceholderLinks(unittest.TestCase): # Placeholder link replacement is implemented in the MediaWiki site JS at From 4a4bbc5bdfe09c587605c2b1305bd42e5f2c0539 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sat, 20 Oct 2018 22:31:14 +0200 Subject: [PATCH 011/114] Preprocess: automate renaming of case conflicts This automates renaming of files that conflict on case-insensitive file systems. The search for conflicts respects new names of files renamed because of unwanted characters. --- commands/preprocess.py | 49 +++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/commands/preprocess.py b/commands/preprocess.py index 1fbae13f4..44f2a8fbb 100644 --- a/commands/preprocess.py +++ b/commands/preprocess.py @@ -113,19 +113,35 @@ def find_files_to_be_renamed(root): new_fn = new_fn.replace('*', '_star_') result[fn] = new_fn - # rename files that conflict on case-insensitive filesystems - # TODO perform this automatically - result['NAN.html'] = 'NAN.2.html' + # find files that conflict on case-insensitive filesystems + for dir, _, filenames in os.walk(root): + seen = dict() + for fn in (result.get(s, s) for s in filenames): + low = fn.lower() + num = seen.setdefault(low, 0) + if num > 0: + name, ext = os.path.splitext(fn) + # add file with its path -> only rename that occurrence + result[os.path.join(dir, fn)] = "{}.{}{}".format(name, num + 1, ext) + seen[low] += 1 return result def rename_files(root, rename_map): for dir, old_fn in ((dir, fn) for dir, _, filenames in os.walk(root) for fn in filenames): + src_path = os.path.join(dir, old_fn) + new_fn = rename_map.get(old_fn) - if new_fn is not None: - src_path = os.path.join(dir, old_fn) + if new_fn: + # look for case conflict of the renamed file + new_path = os.path.join(dir, new_fn) + new_fn = rename_map.get(new_path, new_fn) + else: + # original filename unchanged, look for case conflict + new_fn = rename_map.get(src_path) + if new_fn: dst_path = os.path.join(dir, new_fn) - print("Renaming '{0}' to \n '{1}'".format(src_path, dst_path)) + print("Renaming {0}\n to {1}".format(src_path, dst_path)) shutil.move(src_path, dst_path) def find_html_files(root): @@ -143,7 +159,7 @@ def is_loader_link(target): def transform_loader_link(target, file, root): # Absolute loader.php links need to be made relative - abstarget = os.path.join(root, "common/" + convert_loader_name(target)) + abstarget = os.path.join(root, "common", convert_loader_name(target)) return os.path.relpath(abstarget, os.path.dirname(file)) def is_ranges_placeholder(target): @@ -175,8 +191,8 @@ def is_external_link(target): url = urllib.parse.urlparse(target) return url.scheme != '' or url.netloc != '' -def trasform_relative_link(rename_map, target): - # urllib.parse tuple is (scheme, host, path, params, query, fragment) +def trasform_relative_link(rename_map, target, file): + # urlparse returns (scheme, host, path, params, query, fragment) _, _, path, params, _, fragment = urllib.parse.urlparse(target) assert params == '' @@ -185,8 +201,17 @@ def trasform_relative_link(rename_map, target): path = path.replace('../mwiki/','../common/') dir, fn = os.path.split(path) - fn = rename_map.get(fn, fn) - path = os.path.join(dir, fn) + new_fn = rename_map.get(fn) + if new_fn: + # look for case conflict of the renamed file + abstarget = os.path.normpath(os.path.join(os.path.dirname(file), dir, new_fn)) + new_fn = rename_map.get(abstarget, new_fn) + else: + # original filename unchanged, look for case conflict + abstarget = os.path.normpath(os.path.join(os.path.dirname(file), path)) + new_fn = rename_map.get(abstarget) + if new_fn: + path = os.path.join(dir, new_fn) path = urllib.parse.quote(path) return urllib.parse.urlunparse(('', '', path, params, '', fragment)) @@ -205,7 +230,7 @@ def transform_link(rename_map, target, file, root): if is_external_link(target): return target - return trasform_relative_link(rename_map, target) + return trasform_relative_link(rename_map, target, file) def has_class(el, *classes_to_check): value = el.get('class') From 35a2c83b40e39feddde88ef60809623d9ac8d0cd Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sat, 20 Oct 2018 23:36:33 +0200 Subject: [PATCH 012/114] Preprocess: rename find_files_to_be_renamed This changes the name of find_files_to_be_renamed to build_rename_map. --- commands/preprocess.py | 2 +- preprocess.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/preprocess.py b/commands/preprocess.py index 44f2a8fbb..b38a0157b 100644 --- a/commands/preprocess.py +++ b/commands/preprocess.py @@ -96,7 +96,7 @@ def convert_loader_name(fn): else: raise Exception('Loader file {0} does not match any known files'.format(fn)) -def find_files_to_be_renamed(root): +def build_rename_map(root): # Returns a rename map: a map from old to new file name loader = re.compile(r'load\.php\?.*') query = re.compile(r'\?.*') diff --git a/preprocess.py b/preprocess.py index c78945c19..e033883a8 100755 --- a/preprocess.py +++ b/preprocess.py @@ -38,7 +38,7 @@ def main(): preprocess.rearrange_archive(root) - rename_map = preprocess.find_files_to_be_renamed(root) + rename_map = preprocess.build_rename_map(root) preprocess.rename_files(root, rename_map) # clean the html files From b77f6bfd27bb3733695a098028e3791f4e8998e3 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 21 Oct 2018 02:58:55 +0200 Subject: [PATCH 013/114] Preprocess: add unit tests for file renaming This adds unit tests for functions related to file renaming: build_rename_map, rename_files, and transform_relative_link. --- tests/test_preprocess.py | 173 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 172 insertions(+), 1 deletion(-) diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index b0e7ee8f0..ee40d11f1 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -21,9 +21,23 @@ from commands.preprocess import * #pylint: disable=unused-wildcard-import import io import os +import sys +import contextlib import unittest +import unittest.mock from lxml import etree +class DummyFile(object): + def write(self, x): pass + +# From https://stackoverflow.com/a/2829036/1849769 +@contextlib.contextmanager +def nostdout(): + save_stdout = sys.stdout + sys.stdout = DummyFile() + yield + sys.stdout = save_stdout + class TestConvertLoaderName(unittest.TestCase): def test_convert_loader_name(self): url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=site&only=scripts&skin=cppreference2&*' @@ -225,7 +239,6 @@ def check_output(self, expected_file): actual = buf.getvalue() self.assertEqual(expected, actual) - pass def test_remove_noprint(self): remove_noprint(self.html) @@ -250,3 +263,161 @@ def test_remove_fileinfo(self): def remove_unused_external(self): remove_unused_external(self.html) self.check_output("fabs_external.html") + +class TestFileRename(unittest.TestCase): + def make_rename_map(self, root): + def p(*dirs): + return os.path.join(root, 'dir1', *dirs) + return { + 'invalid*.txt': 'invalid_star_.txt', + 'confl"ict".html': 'confl_q_ict_q_.html', + 'Confl"ict".html': 'Confl_q_ict_q_.html', + 'load.php?modules=site&only=scripts': 'site_scripts.js', + 'load.php?modules=someext&only=styles': 'ext.css', + p('sub2', 'Conflict.html'): 'Conflict.2.html', + p('sub3', 'Confl_q_ict_q_.html'): 'Confl_q_ict_q_.2.html', + p('sub4', 'Conflict'): 'Conflict.2', + p('sub4', 'conFlict'): 'conFlict.3', + p('sub5', 'Conflict'): 'Conflict.2' + } + + def make_walk_result(self, root): + def p(*dirs): + return os.path.join(root, 'dir1', *dirs) + return [ + # Nothing to do + (p(), ('sub1', 'sub2', 'sub3', 'sub4', 'sub5', 'sub6'), ('f1', 'f2')), + # Unwanted characters + (p('sub1'), (), ('invalid*.txt', 'valid.txt')), + # Case conflict + (p('sub2'), (), ('conflict.html', 'Conflict.html')), + # Unwanted characters + case conflict + (p('sub3'), (), ('confl"ict".html', 'Confl"ict".html')), + # Multiple case conflicts, no extension + (p('sub4'), (), ('conflict', 'Conflict', 'conFlict')), + # Case conflict in second directory + (p('sub5'), (), ('conflict', 'Conflict')), + # Loader links + (p('sub6'), (), ('load.php?modules=site&only=scripts', 'load.php?modules=someext&only=styles')) + ] + + def test_build_rename_map(self): + with unittest.mock.patch('os.walk') as walk: + walk.return_value = self.make_walk_result('output') + + actual = build_rename_map('output') + + expected = self.make_rename_map('output') + self.assertEqual(expected, actual) + + def test_rename_files(self): + expected = [ + (('output/dir1/sub1/invalid*.txt', 'output/dir1/sub1/invalid_star_.txt'), {}), + (('output/dir1/sub2/Conflict.html', 'output/dir1/sub2/Conflict.2.html'), {}), + (('output/dir1/sub3/confl"ict".html', 'output/dir1/sub3/confl_q_ict_q_.html'), {}), + (('output/dir1/sub3/Confl"ict".html', 'output/dir1/sub3/Confl_q_ict_q_.2.html'), {}), + (('output/dir1/sub4/Conflict', 'output/dir1/sub4/Conflict.2'), {}), + (('output/dir1/sub4/conFlict', 'output/dir1/sub4/conFlict.3'), {}), + (('output/dir1/sub5/Conflict', 'output/dir1/sub5/Conflict.2'), {}), + (('output/dir1/sub6/load.php?modules=site&only=scripts', 'output/dir1/sub6/site_scripts.js'), {}), + (('output/dir1/sub6/load.php?modules=someext&only=styles', 'output/dir1/sub6/ext.css'), {}) + ] + + actual = [] + def record_call(*args, **kwargs): + actual.append((args, kwargs)) + + with unittest.mock.patch('os.walk') as walk, \ + unittest.mock.patch('shutil.move') as move: + walk.return_value = self.make_walk_result('output') + move.side_effect = record_call + + with nostdout(): + rename_files('output', self.make_rename_map('output')) + + self.assertEqual(expected, actual, + msg="Unexpected sequence of calls to shutil.move") + + def test_transform_relative_link(self): + entries = [ + # (file, target, expected) + ('output/dir1/sub2/conflict.html', + '../f1', + '../f1'), + + ('output/dir1/sub2/Conflict.html', + '../f1', + '../f1'), + + ('output/dir1/sub2/Conflict.html', + '../f1#p2', + '../f1#p2'), + + ('output/dir1/sub2/Conflict.html', + '../f1?some=param', + '../f1'), + + ('output/dir1/sub2/Conflict.html', + '../f1?some=param#p2', + '../f1#p2'), + + ('output/dir1/sub2/Conflict.html', + '../mwiki/site.css', + '../common/site.css'), + + ('output/dir1/sub2/Conflict.html', + '../../upload.cppreference.com/mwiki/site.css', + '../common/site.css'), + + ('output/dir1/f2', + 'sub1/invalid*.txt', + 'sub1/invalid_star_.txt'), + + ('output/dir1/sub0/other.html', + '../sub1/invalid*.txt', + '../sub1/invalid_star_.txt'), + + ('output/dir1/sub1/valid.txt', + '../sub2/conflict.html', + '../sub2/conflict.html'), + + ('output/dir1/sub1/valid.txt', + '../sub2/Conflict.html', + '../sub2/Conflict.2.html'), + + ('output/dir1/sub1/valid.txt', + '../sub3/confl"ict".html', + '../sub3/confl_q_ict_q_.html'), + + ('output/dir1/sub1/valid.txt', + '../sub3/Confl"ict".html', + '../sub3/Confl_q_ict_q_.2.html'), + + ('output/dir1/sub1/valid.txt', + '../sub4/conflict', + '../sub4/conflict'), + + ('output/dir1/sub1/valid.txt', + '../sub4/Conflict', + '../sub4/Conflict.2'), + + ('output/dir1/sub1/valid.txt', + '../sub4/conFlict', + '../sub4/conFlict.3'), + + ('output/dir1/sub1/valid.txt', + '../sub5/conflict', + '../sub5/conflict'), + + ('output/dir1/sub1/valid.txt', + '../sub5/Conflict', + '../sub5/Conflict.2'), + ] + + # trasform_relative_link(rename_map, target, file) + # target: the relative link to transform, if target is in rename map + # file: path of the file that contains the link + rename_map = self.make_rename_map('output') + for file, target, expected in entries: + self.assertEqual(expected, trasform_relative_link(rename_map, target, file), + msg="target='{}', file='{}'".format(target, file)) From 7a36e5a41cf286f8ba05fefad53511fb07ac6ee4 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Tue, 23 Oct 2018 17:26:45 +0200 Subject: [PATCH 014/114] Preprocess: remove dead loader link This removes a loader link that is added by the startup script. The link is for jquery and MediaWiki scripts, which the offline version doesn't use. --- commands/preprocess.py | 9 +++++++++ preprocess.py | 2 ++ 2 files changed, 11 insertions(+) diff --git a/commands/preprocess.py b/commands/preprocess.py index b38a0157b..3cf953756 100644 --- a/commands/preprocess.py +++ b/commands/preprocess.py @@ -355,3 +355,12 @@ def preprocess_css_file(fn): f = open(fn, "w", encoding='utf-8') f.write(text) f.close() + +def preprocess_startup_script(fn): + with open(fn, "r", encoding='utf-8') as f: + text = f.read() + + text = re.sub(r'document\.write\([^)]+\);', '', text) + + with open(fn, "w", encoding='utf-8') as f: + f.write(text) diff --git a/preprocess.py b/preprocess.py index e033883a8..fc9b126ca 100755 --- a/preprocess.py +++ b/preprocess.py @@ -65,5 +65,7 @@ def main(): os.path.join(root, 'common/ext.css') ]: preprocess.preprocess_css_file(fn) + preprocess.preprocess_startup_script(os.path.join(root, 'common/startup_scripts.js')) + if __name__ == "__main__": main() From ecb01674625cc6509df2042f0743922f1bd727dd Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Tue, 23 Oct 2018 17:38:50 +0200 Subject: [PATCH 015/114] Test: fix ignored test for remove_unused_external --- tests/test_preprocess.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index ee40d11f1..d4616aaec 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -260,7 +260,7 @@ def test_remove_fileinfo(self): remove_fileinfo(self.html) self.check_output("fabs_fileinfo.html") - def remove_unused_external(self): + def test_remove_unused_external(self): remove_unused_external(self.html) self.check_output("fabs_external.html") From 96fefd1e67c13a0d24e992b039580370b9506ba5 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 24 Oct 2018 22:18:26 +0300 Subject: [PATCH 016/114] Tests: Enable pylint and flake8 --- .travis.yml | 7 +- config/flake8rc | 6 + config/pylintrc | 389 ++++++++++++++++++++++++++++++++++++++++++++ requirements-ci.txt | 2 + test.sh | 2 + 5 files changed, 403 insertions(+), 3 deletions(-) create mode 100644 config/flake8rc create mode 100644 config/pylintrc create mode 100644 requirements-ci.txt diff --git a/.travis.yml b/.travis.yml index 9a80acd6e..45d61ce3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,10 +14,11 @@ python: install: - pip install -U pip - pip install -r requirements.txt + - pip install -r requirements-ci.txt -#before_script: -# - "if [[ $TRAVIS_PYTHON_VERSION != 2.6 ]]; then flake8 --config=config/flake8rc asm_collect.py asmtest tests; fi" -# - "if [[ $TRAVIS_PYTHON_VERSION != 2.6 ]]; then pylint --rcfile=config/pylintrc asm_collect.py asmtest tests; fi" +before_script: + - "flake8 --config=config/flake8rc *.py commands index_transform gadgets/standard_revisions_tests/*.py tests" + - "pylint --rcfile=config/pylintrc *.py commands index_transform gadgets/standard_revisions_tests/*.py tests" script: - "python -m unittest discover" diff --git a/config/flake8rc b/config/flake8rc new file mode 100644 index 000000000..d12aac637 --- /dev/null +++ b/config/flake8rc @@ -0,0 +1,6 @@ +[flake8] + +show-source = yes +statistics = yes +count = yes +max-line-length = 80 diff --git a/config/pylintrc b/config/pylintrc new file mode 100644 index 000000000..7ef5161c0 --- /dev/null +++ b/config/pylintrc @@ -0,0 +1,389 @@ +[MASTER] + +# Profiled execution. +profile=no + +# Add files or directories to the blacklist. They should be base names, not +# paths. +ignore= + +# Pickle collected data for later comparisons. +persistent=no + +# List of plugins (as comma separated values of python modules names) to load, +# usually to register additional checkers. +load-plugins= + + +[MESSAGES CONTROL] + +# For now disable bunch of checks that does not pass. Some of them should be +# re-enabled and reported issues fixed, while most are bugs in pylint and could +# be re-enabled when those are fixed. + +# Following are the checks we don't care about, and thus should remain disabled +# +# blacklisted-name +# missing-docstring +# too-many-lines +# no-self-use +# duplicate-code +# too-many-ancestors +# too-many-instance-attributes +# too-few-public-methods +# too-many-public-methods +# too-many-return-statements +# too-many-branches +# too-many-arguments +# too-many-locals +# too-many-statements +# abstract-class-not-used +# abstract-class-little-used +# exec-used +# star-args +# deprecated-module +# fixme +# global-variable-undefined +# unused-argument +# unpacking-non-sequence +# maybe-no-member + +# "bad-continuation" disabled due to conflict with flake8 (and PEP8) +# See +# flake8 wants: +# func("..." +# ) +# pylint wants: +# func("..." +# ) + +disable= + blacklisted-name, + invalid-name, + missing-docstring, + too-many-lines, + no-self-use, + duplicate-code, + too-many-ancestors, + too-many-instance-attributes, + too-few-public-methods, + too-many-public-methods, + too-many-return-statements, + too-many-branches, + too-many-arguments, + too-many-locals, + too-many-statements, + abstract-class-not-used, + abstract-class-little-used, + deprecated-module, + fixme, + global-variable-undefined, + unused-argument, + maybe-no-member, + locally-disabled, + bad-classmethod-argument, + line-too-long, + old-style-class, + method-hidden, + no-name-in-module, + no-member, + not-callable, + too-many-function-args, + unexpected-keyword-arg, + redundant-keyword-arg, + import-error, + cyclic-import, + exec-used, + star-args, + unreachable, + dangerous-default-value, + pointless-statement, + pointless-string-statement, + expression-not-assigned, + unnecessary-pass, + unnecessary-lambda, + deprecated-lambda, + useless-else-on-loop, + bad-builtin, + attribute-defined-outside-init, + protected-access, + arguments-differ, + signature-differs, + abstract-method, + super-init-not-called, + no-init, + non-parent-init-called, + bad-indentation, + relative-import, + global-statement, + unused-variable, + redefined-outer-name, + redefined-builtin, + redefined-variable-type, + unidiomatic-typecheck, + undefined-loop-variable, + unbalanced-tuple-unpacking, + unpacking-non-sequence, + raising-string, + broad-except, + nonstandard-exception, + anomalous-unicode-escape-in-string, + bad-open-mode, + superfluous-parens, + no-self-argument, + no-value-for-parameter, + interface-not-implemented, + bad-continuation, + keyword-arg-before-vararg, + unsubscriptable-object, + inconsistent-return-statements, # (implicit return None) + len-as-condition, + too-many-boolean-expressions, + useless-object-inheritance + +[REPORTS] + +# Set the output format. Available formats are text, parseable, colorized, msvs +# (visual studio) and html. You can also give a reporter class, eg +# mypackage.mymodule.MyReporterClass. +output-format=text + +# Change the default error message template. +msg-template={path}:{line}:{column}: error: {msg} [{symbol}] + +# Include message's id in output +include-ids=yes + +# Include symbolic ids of messages in output +symbols=yes + +# Put messages in a separate file for each module / package specified on the +# command line instead of printing them on stdout. Reports (if any) will be +# written in a file name "pylint_global.[txt|html]". +files-output=no + +# Tells whether to display a full report or only the messages +reports=no + +# Python expression which should return a note less than 10 (10 is the highest +# note). You have access to the variables errors warning, statement which +# respectively contain the number of errors / warnings messages and the total +# number of statements analyzed. This is used by the global evaluation report +# (RP0004). +evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) + +# Add a comment according to your evaluation note. This is used by the global +# evaluation report (RP0004). +comment=no + + +[SPELLING] + +# Spelling dictionary name. +# If this value will be non-empty (e.g. 'en_US') and pyenchant will not be +# installed, pylint will fail. +# If this will be left empty pylint will ignore all spelling errors. +spelling-dict= + +# List of comma separated words that should not be checked. +spelling-ignore-words= + +# A path to a file that contains private dictionary; one word per line. +# Path relative to current working directory. +spelling-private-dict-file=../common/code_spelling_ignore_words.txt + +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no + + +[MISCELLANEOUS] + +# List of note tags to take in consideration, separated by a comma. +notes=FIXME,XXX,TODO + + +[SIMILARITIES] + +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + + +[FORMAT] + +# Maximum number of characters on a single line. +max-line-length=80 + +# Maximum number of lines in a module +max-module-lines=1000 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + + +[TYPECHECK] + +# Tells whether missing members accessed in mixin class should be ignored. A +# mixin class is detected if its name ends with "mixin" (case insensitive). +ignore-mixin-members=yes + +# List of classes names for which member attributes should not be checked +# (useful for classes with attributes dynamically set). +ignored-classes=SQLObject + +# When zope mode is activated, add a predefined set of Zope acquired attributes +# to generated-members. +zope=no + +# List of members which are set dynamically and missed by pylint inference +# system, and so shouldn't trigger E0201 when accessed. Python regular +# expressions are accepted. +generated-members=REQUEST,acl_users,aq_parent + + +[BASIC] + +# Will be removed in PyLint 2.0 +# Required attributes for module, separated by a comma +#required-attributes= + +# List of builtins function names that should not be used, separated by a comma +bad-functions=map,filter,apply,input + +# Regular expression which should only match correct module names +module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$ + +# Regular expression which should only match correct module level names +const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$ + +# Regular expression which should only match correct class names +class-rgx=[A-Z_][a-zA-Z0-9_]+$ + +# Regular expression which should only match correct function names +function-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct method names +method-rgx=[_]{0,2}[a-z_][a-z0-9_]{2,30}[_]{0,2}$ + +# Regular expression which should only match correct instance attribute names +attr-rgx=[a-z_][a-z0-9]{2,30}$ + +# Regular expression which should only match correct argument names +argument-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct variable names +variable-rgx=[a-z_][a-z0-9_]{2,30}$ + +# Regular expression which should only match correct list comprehension / +# generator expression variable names +inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ + +# Good variable names which should always be accepted, separated by a comma +good-names=i,j,k,ex,_ + +# Bad variable names which should always be refused, separated by a comma +bad-names= + +# Regular expression which should only match functions or classes name which do +# not require a docstring +no-docstring-rgx=__.*__ + + +[VARIABLES] + +# Tells whether we should check for unused import in __init__ files. +init-import=no + +# A regular expression matching the beginning of the name of dummy variables +# (i.e. not used). +dummy-variables-rgx=_|dummy + +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= + + +[CLASSES] + +# This option will be removed in PyLint 2.0. +# List of interface methods to ignore, separated by a comma. This is used for +# instance to not check methods defines in Zope's Interface base class. +# ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + + +[IMPORTS] + +# Deprecated modules which should not be used, separated by a comma +deprecated-modules= + +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= + +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= + +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= + + +[DESIGN] + +# Maximum number of arguments for function / method +max-args=5 + +# Argument names that match this expression will be ignored. Default to name +# with leading underscore +ignored-argument-names=_.* + +# Maximum number of locals for function / method body +max-locals=15 + +# Maximum number of return / yield for function / method body +max-returns=6 + +# Maximum number of branch for function / method body +max-branchs=12 + +# Maximum number of statements in function / method body +max-statements=50 + +# Maximum number of parents for a class (see R0901). +max-parents=7 + +# Maximum number of attributes for a class (see R0902). +max-attributes=7 + +# Minimum number of public methods for a class (see R0903). +min-public-methods=2 + +# Maximum number of public methods for a class (see R0904). +max-public-methods=20 + + +[EXCEPTIONS] + +# Exceptions that will emit a warning when being caught. Defaults to +# "Exception" +overgeneral-exceptions=Exception diff --git a/requirements-ci.txt b/requirements-ci.txt new file mode 100644 index 000000000..37635354d --- /dev/null +++ b/requirements-ci.txt @@ -0,0 +1,2 @@ +pylint +flake8 diff --git a/test.sh b/test.sh index a8a93073f..e305304dd 100755 --- a/test.sh +++ b/test.sh @@ -1,3 +1,5 @@ #!/bin/sh +flake8 --config=config/flake8rc *.py commands index_transform gadgets/standard_revisions_tests/*.py tests +pylint --rcfile=config/pylintrc *.py commands index_transform gadgets/standard_revisions_tests/*.py tests python3 -m unittest discover "$@" From d9bd30fb21d10f8d6b171b81582b295b73329a0f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 24 Oct 2018 22:19:00 +0300 Subject: [PATCH 017/114] Fix flake8 and pylint warnings --- build_link_map.py | 13 +- commands/preprocess.py | 102 ++++-- commands/preprocess_cssless.py | 57 +++- config/pylintrc | 2 + ddg_parse_html.py | 116 ++++--- devhelp2qch.py | 23 +- export.py | 40 ++- fix_devhelp-links.py | 6 +- gadgets/standard_revisions-tests/base.py | 16 +- gadgets/standard_revisions-tests/test_dcl.py | 3 +- gadgets/standard_revisions-tests/test_dsc.py | 4 +- gadgets/standard_revisions-tests/test_rev.py | 5 +- .../test_section_hierarchy.py | 57 ++-- index2autolinker.py | 61 ++-- index2browser.py | 13 +- index2ddg.py | 312 ++++++++++-------- index2devhelp.py | 25 +- index2doxygen-tag.py | 45 ++- index2highlight.py | 15 +- index2search.py | 15 +- index_transform/autolinker.py | 37 ++- index_transform/browser.py | 39 ++- index_transform/common.py | 74 +++-- index_transform/devhelp.py | 37 ++- index_transform/devhelp_qch.py | 5 + index_transform/doxygen_tag.py | 109 +++--- index_transform/highlight.py | 31 +- index_transform/search.py | 2 +- link_map.py | 1 + preprocess.py | 18 +- preprocess_qch.py | 32 +- tests/test_devhelp.py | 12 +- tests/test_devhelp_qch.py | 5 +- tests/test_preprocess.py | 170 +++++++--- tests/test_preprocess_cssless.py | 53 ++- xml_utils.py | 4 +- 36 files changed, 949 insertions(+), 610 deletions(-) diff --git a/build_link_map.py b/build_link_map.py index 851c8ee1e..a0de21cb3 100755 --- a/build_link_map.py +++ b/build_link_map.py @@ -25,6 +25,7 @@ import os from link_map import LinkMap + # returns a dict { title -> filename }. # directory - either 'output/reference' or 'reference' def build_link_map(directory): @@ -41,26 +42,30 @@ def build_link_map(directory): text = f.read() f.close() - m = re.search('', text) + m = re.search(r'', text) # noqa if not m: continue text = m.group(1) - text = re.sub('\s*', '', text) + text = re.sub(r'\s*', '', text) m = re.search('"wgPageName":"([^"]*)"', text) if not m: continue title = m.group(1) - target = os.path.relpath(os.path.abspath(fn), os.path.abspath(directory)) + target = os.path.relpath(os.path.abspath(fn), + os.path.abspath(directory)) link_map.add_link(title, target) return link_map + def main(): link_map = build_link_map('output/reference') - # create an xml file containing mapping between page title and actual location + # create an xml file containing mapping between page title and actual + # location link_map.write('output/link-map.xml') + if __name__ == "__main__": main() diff --git a/commands/preprocess.py b/commands/preprocess.py index 3cf953756..dadf36462 100644 --- a/commands/preprocess.py +++ b/commands/preprocess.py @@ -19,23 +19,24 @@ import fnmatch import io -from lxml import etree import re import os -import sys import shutil import urllib.parse -from xml_utils import xml_escape, xml_unescape +from lxml import etree + def rmtree_if_exists(dir): if os.path.isdir(dir): shutil.rmtree(dir) + def move_dir_contents_to_dir(srcdir, dstdir): for fn in os.listdir(srcdir): shutil.move(os.path.join(srcdir, fn), os.path.join(dstdir, fn)) + def rearrange_archive(root): # rearrange the archive. {root} here is output/reference @@ -71,8 +72,10 @@ def rearrange_archive(root): move_dir_contents_to_dir(src_data_path, data_path) # also copy the custom fonts - shutil.copy(os.path.join(path, 'DejaVuSansMonoCondensed60.ttf'), data_path) - shutil.copy(os.path.join(path, 'DejaVuSansMonoCondensed75.ttf'), data_path) + shutil.copy(os.path.join(path, 'DejaVuSansMonoCondensed60.ttf'), + data_path) + shutil.copy(os.path.join(path, 'DejaVuSansMonoCondensed75.ttf'), + data_path) # remove what's left shutil.rmtree(path) @@ -81,20 +84,23 @@ def rearrange_archive(root): for fn in fnmatch.filter(os.listdir(root), 'cppreference-export*.xml'): os.remove(os.path.join(root, fn)) -# Converts complex URL to resources supplied by MediaWiki loader to a simplified name + def convert_loader_name(fn): + # Converts complex URL to resources supplied by MediaWiki loader to a + # simplified name if "modules=site&only=scripts" in fn: return "site_scripts.js" - elif "modules=site&only=styles" in fn: + if "modules=site&only=styles" in fn: return "site_modules.css" - elif "modules=startup&only=scripts" in fn: + if "modules=startup&only=scripts" in fn: return "startup_scripts.js" - elif re.search("modules=skins.*&only=scripts", fn): + if re.search("modules=skins.*&only=scripts", fn): return "skin_scripts.js" - elif re.search("modules=.*ext.*&only=styles", fn): + if re.search("modules=.*ext.*&only=styles", fn): return "ext.css" - else: - raise Exception('Loader file {0} does not match any known files'.format(fn)) + msg = 'Loader file {0} does not match any known files'.format(fn) + raise Exception(msg) + def build_rename_map(root): # Returns a rename map: a map from old to new file name @@ -122,13 +128,17 @@ def build_rename_map(root): if num > 0: name, ext = os.path.splitext(fn) # add file with its path -> only rename that occurrence - result[os.path.join(dir, fn)] = "{}.{}{}".format(name, num + 1, ext) + result[os.path.join(dir, fn)] = "{}.{}{}".format(name, num + 1, + ext) seen[low] += 1 return result + def rename_files(root, rename_map): - for dir, old_fn in ((dir, fn) for dir, _, filenames in os.walk(root) for fn in filenames): + for dir, old_fn in ((dir, fn) + for dir, _, filenames in os.walk(root) + for fn in filenames): src_path = os.path.join(dir, old_fn) new_fn = rename_map.get(old_fn) @@ -144,6 +154,7 @@ def rename_files(root, rename_map): print("Renaming {0}\n to {1}".format(src_path, dst_path)) shutil.move(src_path, dst_path) + def find_html_files(root): # find files that need to be preprocessed html_files = [] @@ -152,21 +163,25 @@ def find_html_files(root): html_files.append(os.path.join(dir, filename)) return html_files + def is_loader_link(target): if re.match(r'https?://[a-z]+\.cppreference\.com/mwiki/load\.php', target): return True return False + def transform_loader_link(target, file, root): # Absolute loader.php links need to be made relative abstarget = os.path.join(root, "common", convert_loader_name(target)) return os.path.relpath(abstarget, os.path.dirname(file)) + def is_ranges_placeholder(target): - if re.match(r'https?://[a-z]+\.cppreference\.com/w/cpp/ranges(-[a-z]+)?-placeholder/.+', target): + if re.match(r'https?://[a-z]+\.cppreference\.com/w/cpp/ranges(-[a-z]+)?-placeholder/.+', target): # noqa return True return False + def transform_ranges_placeholder(target, file, root): # Placeholder link replacement is implemented in the MediaWiki site JS at # https://en.cppreference.com/w/MediaWiki:Common.js @@ -175,9 +190,9 @@ def transform_ranges_placeholder(target, file, root): repl = (r'\1/cpp/experimental/ranges/\2' if ranges else r'\1/cpp/\2') if 'ranges-placeholder' in target: - match = r'https?://([a-z]+)\.cppreference\.com/w/cpp/ranges-placeholder/(.+)' + match = r'https?://([a-z]+)\.cppreference\.com/w/cpp/ranges-placeholder/(.+)' # noqa else: - match = r'https?://([a-z]+)\.cppreference\.com/w/cpp/ranges-([a-z]+)-placeholder/(.+)' + match = r'https?://([a-z]+)\.cppreference\.com/w/cpp/ranges-([a-z]+)-placeholder/(.+)' # noqa repl += (r'/\3' if ranges else r'/ranges/\3') # Turn absolute placeholder link into site-relative link @@ -187,24 +202,27 @@ def transform_ranges_placeholder(target, file, root): abstarget = os.path.join(root, reltarget) return os.path.relpath(abstarget, os.path.dirname(file)) + def is_external_link(target): url = urllib.parse.urlparse(target) return url.scheme != '' or url.netloc != '' + def trasform_relative_link(rename_map, target, file): # urlparse returns (scheme, host, path, params, query, fragment) _, _, path, params, _, fragment = urllib.parse.urlparse(target) assert params == '' path = urllib.parse.unquote(path) - path = path.replace('../../upload.cppreference.com/mwiki/','../common/') - path = path.replace('../mwiki/','../common/') + path = path.replace('../../upload.cppreference.com/mwiki/', '../common/') + path = path.replace('../mwiki/', '../common/') dir, fn = os.path.split(path) new_fn = rename_map.get(fn) if new_fn: # look for case conflict of the renamed file - abstarget = os.path.normpath(os.path.join(os.path.dirname(file), dir, new_fn)) + abstarget = os.path.normpath(os.path.join(os.path.dirname(file), + dir, new_fn)) new_fn = rename_map.get(abstarget, new_fn) else: # original filename unchanged, look for case conflict @@ -216,11 +234,13 @@ def trasform_relative_link(rename_map, target, file): path = urllib.parse.quote(path) return urllib.parse.urlunparse(('', '', path, params, '', fragment)) + # Transforms a link in the given file according to rename map. # target is the link to transform. # file is the path of the file the link came from. # root is the path to the root of the archive. def transform_link(rename_map, target, file, root): + if is_loader_link(target): return transform_loader_link(target, file, root) @@ -232,6 +252,7 @@ def transform_link(rename_map, target, file, root): return trasform_relative_link(rename_map, target, file) + def has_class(el, *classes_to_check): value = el.get('class') if value is None: @@ -242,6 +263,7 @@ def has_class(el, *classes_to_check): return True return False + # remove non-printable elements def remove_noprint(html): for el in html.xpath('//*'): @@ -250,6 +272,7 @@ def remove_noprint(html): elif el.get('id') in ['toc', 'catlinks']: el.getparent().remove(el) + # remove see also links between C and C++ documentations def remove_see_also(html): for el in html.xpath('//tr[@class]'): @@ -257,7 +280,8 @@ def remove_see_also(html): continue child_tds = el.xpath('.//td/div[@class]') - if not any(has_class(td, 't-dcl-list-see', 't-dsc-see') for td in child_tds): + if not any(has_class(td, 't-dcl-list-see', 't-dsc-see') + for td in child_tds): continue # remove preceding separator, if any @@ -276,17 +300,23 @@ def remove_see_also(html): next = el.getnext() if next is None: el.getparent().remove(el) - elif next.tag == 'table' and has_class(next, 't-dcl-list-begin') and len(next.xpath('.//tr')) == 0: + elif next.tag == 'table' and has_class(next, 't-dcl-list-begin') and \ + len(next.xpath('.//tr')) == 0: el.getparent().remove(el) next.getparent().remove(next) + # remove Google Analytics scripts def remove_google_analytics(html): for el in html.xpath('/html/body/script'): - if el.get('src') is not None and 'google-analytics.com/ga.js' in el.get('src'): - el.getparent().remove(el) - elif el.text is not None and ('google-analytics.com/ga.js' in el.text or 'pageTracker' in el.text): - el.getparent().remove(el) + if el.get('src') is not None: + if 'google-analytics.com/ga.js' in el.get('src'): + el.getparent().remove(el) + elif el.text is not None: + if 'google-analytics.com/ga.js' in el.text or \ + 'pageTracker' in el.text: + el.getparent().remove(el) + # remove Carbon ads def remove_ads(html): @@ -297,13 +327,15 @@ def remove_ads(html): if el.text is not None and '#carbonads' in el.text: el.getparent().remove(el) + # remove links to file info pages (e.g. on images) def remove_fileinfo(html): - info = etree.XPath(r"//a[re:test(@href, 'https?://[a-z]+\.cppreference\.com/w/File:')]/..", - namespaces={'re':'http://exslt.org/regular-expressions'}) + info = etree.XPath(r"//a[re:test(@href, 'https?://[a-z]+\.cppreference\.com/w/File:')]/..", # noqa + namespaces={'re':'http://exslt.org/regular-expressions'}) # noqa for el in info(html): el.getparent().remove(el) + # remove external links to unused resources def remove_unused_external(html): for el in html.xpath('/html/head/link'): @@ -313,6 +345,7 @@ def remove_unused_external(html): (head, tail) = os.path.split(el.get('href')) el.set('href', os.path.join(head, 'common', tail)) + def preprocess_html_file(root, fn, rename_map): parser = etree.HTMLParser() html = etree.parse(fn, parser) @@ -331,12 +364,13 @@ def preprocess_html_file(root, fn, rename_map): for el in html.xpath('//*[@href]'): el.set('href', transform_link(rename_map, el.get('href'), fn, root)) - for err in parser.error_log: + for err in list(parser.error_log): print("HTML WARN: {0}".format(err), file=output) html.write(fn, encoding='utf-8', method='html') return output.getvalue() + def preprocess_css_file(fn): f = open(fn, "r", encoding='utf-8') text = f.read() @@ -344,10 +378,13 @@ def preprocess_css_file(fn): # note that query string is not used in css files - text = text.replace('../DejaVuSansMonoCondensed60.ttf', 'DejaVuSansMonoCondensed60.ttf') - text = text.replace('../DejaVuSansMonoCondensed75.ttf', 'DejaVuSansMonoCondensed75.ttf') + text = text.replace('../DejaVuSansMonoCondensed60.ttf', + 'DejaVuSansMonoCondensed60.ttf') + text = text.replace('../DejaVuSansMonoCondensed75.ttf', + 'DejaVuSansMonoCondensed75.ttf') - text = text.replace('../../upload.cppreference.com/mwiki/images/', 'images/') + text = text.replace('../../upload.cppreference.com/mwiki/images/', + 'images/') # QT Help viewer doesn't understand nth-child text = text.replace('nth-child(1)', 'first-child') @@ -356,6 +393,7 @@ def preprocess_css_file(fn): f.write(text) f.close() + def preprocess_startup_script(fn): with open(fn, "r", encoding='utf-8') as f: text = f.read() diff --git a/commands/preprocess_cssless.py b/commands/preprocess_cssless.py index 2f75d5ae0..0bd1847f5 100644 --- a/commands/preprocess_cssless.py +++ b/commands/preprocess_cssless.py @@ -15,18 +15,17 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. -from premailer import Premailer -import cssutils -from lxml import html -from lxml import etree -from io import StringIO -from lxml.etree import strip_elements import copy import functools import io import logging import os import warnings +from premailer import Premailer +import cssutils +from lxml import etree +from lxml.etree import strip_elements + def preprocess_html_merge_cssless(src_path, dst_path): with open(src_path, 'r') as a_file: @@ -48,9 +47,11 @@ def preprocess_html_merge_cssless(src_path, dst_path): os.makedirs(head, exist_ok=True) with open(dst_path, 'wb') as a_file: - root.getroottree().write(a_file, pretty_print=True, method="html", encoding='utf-8') + root.getroottree().write(a_file, pretty_print=True, method="html", + encoding='utf-8') return output + def silence_cssutils_warnings(): log = logging.Logger('ignore') output = io.StringIO() @@ -62,6 +63,7 @@ def silence_cssutils_warnings(): return output + def preprocess_html_merge_css(root, src_path): # cssutils_logging_handler of Premailer.__init__ is insufficient to silence # warnings to stderr in non-verbose mode @@ -75,9 +77,11 @@ def preprocess_html_merge_css(root, src_path): return output.getvalue() + def strip_style_tags(root): strip_elements(root, 'style') + def needs_td_wrapper(element): # element has table:row if len(element.getchildren()) == 0: @@ -88,13 +92,16 @@ def needs_td_wrapper(element): return False return True + @functools.lru_cache(maxsize=None) def cssutils_parse_style_cached_nocopy(style): return cssutils.parseStyle(style) + def cssutils_parse_style_cached(style): return copy.deepcopy(cssutils_parse_style_cached_nocopy(style)) + @functools.lru_cache(maxsize=None) def get_css_style_property_value(style, prop_name): atrib = cssutils_parse_style_cached_nocopy(style) @@ -103,6 +110,7 @@ def get_css_style_property_value(style, prop_name): return value.cssText return None + @functools.lru_cache(maxsize=None) def has_css_style_property_value(style, prop_name, prop_value): value = get_css_style_property_value(style, prop_name) @@ -110,12 +118,14 @@ def has_css_style_property_value(style, prop_name, prop_value): return True return False + @functools.lru_cache(maxsize=None) def remove_css_style_property(style, property_name): atrib = cssutils_parse_style_cached(style) atrib.removeProperty(property_name) return atrib.getCssText(separator='') + def remove_css_property(element, property_name): new_style = remove_css_style_property(element.get('style'), property_name) if len(new_style) > 0: @@ -123,17 +133,21 @@ def remove_css_property(element, property_name): elif 'style' in element.attrib: element.attrib.pop('style') + def get_css_property_value(el, prop_name): return get_css_style_property_value(el.get('style'), prop_name) + def has_css_property_value(el, prop_name, prop_value): return has_css_style_property_value(el.get('style'), prop_name, prop_value) + def set_css_property_value(el, prop_name, prop_value): atrib = cssutils_parse_style_cached(el.get('style')) atrib.setProperty(prop_name, prop_value) el.set('style', atrib.getCssText(separator='')) + def convert_display_property_to_html_tag(element, element_tag, display_value): str_attrib_value = element.get('style') if str_attrib_value is None: @@ -143,12 +157,14 @@ def convert_display_property_to_html_tag(element, element_tag, display_value): remove_css_property(element, 'display') return True + def convert_span_table_to_tr_td(table_el): table_el.tag = 'table' remove_css_property(table_el, 'display') for element in table_el.getchildren(): - tag_renamed = convert_display_property_to_html_tag(element, 'tr', 'table-row') + tag_renamed = convert_display_property_to_html_tag(element, 'tr', + 'table-row') if tag_renamed: if needs_td_wrapper(element): td = etree.Element('td') @@ -160,7 +176,9 @@ def convert_span_table_to_tr_td(table_el): element.text = None else: for child in element: - convert_display_property_to_html_tag(child, 'td', 'table-cell') + convert_display_property_to_html_tag(child, 'td', + 'table-cell') + def wrap_element(el, tag_name, style): new_el = etree.Element(tag_name) @@ -168,11 +186,13 @@ def wrap_element(el, tag_name, style): el.addprevious(new_el) new_el.insert(0, el) + def remove_display_none(root_el): for el in root_el.xpath('//*[contains(@style, "display")]'): if has_css_property_value(el, 'display', 'none'): el.getparent().remove(el) + def convert_span_tables_to_tr_td(root_el): # note that the following xpath expressions match only the prefix of the # CSS property value @@ -181,11 +201,12 @@ def convert_span_tables_to_tr_td(root_el): for table_el in table_els: if has_css_property_value(table_el, 'display', 'table'): convert_span_table_to_tr_td(table_el) - #wrap_element(table_el, 'div', 'display:inline') - #convert_span_table_to_tr_td(table_el) + # wrap_element(table_el, 'div', 'display:inline') + # convert_span_table_to_tr_td(table_el) return root_el + def convert_inline_block_elements_to_table(root_el): for el in root_el.xpath('//*[contains(@style, "display")]'): if not has_css_property_value(el, 'display', 'inline-block') and \ @@ -221,6 +242,7 @@ def convert_inline_block_elements_to_table(root_el): el.getparent().remove(el) td.append(el) + def get_table_rows(table_el): for el in table_el.iterchildren(['th', 'tr']): yield el @@ -228,28 +250,33 @@ def get_table_rows(table_el): for el2 in el.iterchildren(['th', 'tr']): yield el2 + def get_max_number_of_columns(table_el): max_tds = 0 for row_el in get_table_rows(table_el): max_tds = max(max_tds, len(list(row_el.iterchildren('td')))) return max_tds + def clear_tr_border_top(tr_el): for td_el in tr_el.iterchildren('td'): remove_css_property(td_el, 'border-top') + def has_tr_border_top(tr_el): for td_el in tr_el.iterchildren('td'): if get_css_property_value(td_el, 'border-top') is not None: return True return False + def has_table_border_top(table_el): for tr_el in get_table_rows(table_el): if has_tr_border_top(tr_el): return True return False + def convert_table_border_top_to_tr_background(root_el): for table_el in root_el.iter('table'): if not has_table_border_top(table_el): @@ -267,6 +294,7 @@ def convert_table_border_top_to_tr_background(root_el): 'background-color: #ccc;') tr_el.addprevious(border_tr) + def convert_zero_td_width_to_nonzero(root_el): for el in root_el.xpath('//*[contains(@style, "width")]'): if has_css_property_value(el, 'width', '0%'): @@ -276,6 +304,7 @@ def convert_zero_td_width_to_nonzero(root_el): for el in root_el.xpath('//*[contains(@width, "0%")]'): el.attrib['width'] = "1px" + def apply_font_size(size, parent_size_pt): size = size.strip() @@ -292,8 +321,9 @@ def apply_font_size(size, parent_size_pt): return parent_size_pt + def convert_font_size_property_to_pt_recurse(el, parent_size_pt): - size_value = get_css_property_value(el,"font-size") + size_value = get_css_property_value(el, "font-size") if size_value: el_size_pt = apply_font_size(size_value, parent_size_pt) @@ -304,5 +334,6 @@ def convert_font_size_property_to_pt_recurse(el, parent_size_pt): for child in el.getchildren(): convert_font_size_property_to_pt_recurse(child, el_size_pt) + def convert_font_size_property_to_pt(root_el, default_size): - convert_font_size_property_to_pt_recurse(root_el, default_size) + convert_font_size_property_to_pt_recurse(root_el, default_size) diff --git a/config/pylintrc b/config/pylintrc index 7ef5161c0..9fbfd511c 100644 --- a/config/pylintrc +++ b/config/pylintrc @@ -387,3 +387,5 @@ max-public-methods=20 # Exceptions that will emit a warning when being caught. Defaults to # "Exception" overgeneral-exceptions=Exception + +extension-pkg-whitelist=lxml diff --git a/ddg_parse_html.py b/ddg_parse_html.py index 12d8ab79e..4ee52b89d 100644 --- a/ddg_parse_html.py +++ b/ddg_parse_html.py @@ -1,4 +1,4 @@ - #!/usr/bin/env python3 +#!/usr/bin/env python3 ''' Copyright (C) 2013 Povilas Kanapickas @@ -18,24 +18,26 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -import lxml.etree as e import re from copy import deepcopy +import lxml.etree as e + class DdgException(Exception): pass -''' Returns the element in which the content is stored. -''' + def get_content_el(root_el): + # Returns the element in which the content is stored. try: return root_el.xpath('''/html/body/div[@id="cpp-content-base"] /div[@id="content"] /div[@id="bodyContent"] /div[@class="mw-content-ltr"]''')[0] - except: + except Exception: raise DdgException("Could not find content element") + VERSION_C89 = 0 VERSION_C99 = 1 VERSION_C11 = 2 @@ -44,18 +46,20 @@ def get_content_el(root_el): VERSION_CXX11 = 102 VERSION_CXX14 = 103 -''' Returns the declaration of the feature with name 'name'. - If several declarations with the same name are present, and entries - superseded in the later standards (as determined by the presence of until - XXX marker) are ignored. The rest of declarations are returned as a list of - tuples, each of which the two elements: - 1) the code of the declaration - 2) the version as defined by the 'num' dcl template parameter, or None - if no version was specified. - If no declaration is found, an exception of type DdgException is raised -''' def get_declarations(root_el, name): + ''' Returns the declaration of the feature with name 'name'. + If several declarations with the same name are present, and entries + superseded in the later standards (as determined by the presence of + until XXX marker) are ignored. The rest of declarations are returned + as a list of tuples, each of which the two elements: + 1) the code of the declaration + 2) the version as defined by the 'num' dcl template parameter, or + None if no version was specified. + + If no declaration is found, an exception of type DdgException is raised + ''' + content_el = get_content_el(root_el) dcl_tables = content_el.xpath('table[contains(@class, "t-dcl-begin")]') @@ -77,12 +81,12 @@ def get_declarations(root_el, name): # skip entries that don't contain name if re.search('[^a-zA-Z0-9_]' + re.escape(name) + '[^a-zA-Z0-9_]', - code) == None: + code) is None: ignored = True continue # skip deleted functions - if re.search('=\s*delete\s*;', code) != None: + if re.search(r'=\s*delete\s*;', code) is not None: ignored = True continue @@ -97,9 +101,9 @@ def get_declarations(root_el, name): version = None try: version_str = dcl.xpath('td[2]')[0].text_content() - version_str = re.search('\((\d*)\)', version_str).group(1) + version_str = re.search(r'\((\d*)\)', version_str).group(1) version = int(version_str) - except: + except Exception: pass dcls.append((code, version)) @@ -112,10 +116,12 @@ def get_declarations(root_el, name): return dcls + def del_all_attrs(el): for key in el.attrib: del el.attrib[key] + def iterate_top_text(text, on_text=None): last_close = 0 open_count = 0 @@ -134,6 +140,7 @@ def iterate_top_text(text, on_text=None): if open_count == 0: on_text(last_close, text[last_close:]) + def remove_parentheses(desc, max_paren_text_size): open_paren_count = 0 @@ -143,7 +150,7 @@ def remove_parentheses(desc, max_paren_text_size): def on_text(pos, text): nonlocal open_paren_count, last_paren_open, del_ranges - for match in re.finditer('(\(|\))', text): + for match in re.finditer(r'(\(|\))', text): gr = match.group(1) if gr == '(': if open_paren_count == 0: @@ -162,10 +169,11 @@ def on_text(pos, text): del_ranges.append((last_paren_open, end)) for r in reversed(del_ranges): - begin,end = r + begin, end = r desc = desc[:begin] + desc[end:] return desc + def split_sentences(desc): sentences = [] @@ -187,9 +195,11 @@ def on_text(pos, text): return sentences + def remove_punctuation_at_end(sentence): return sentence.rstrip(' .,:;') + def trim_single_sentence_at_word(sentence, max_chars): last_valid_chunk = None @@ -217,6 +227,7 @@ def on_text(pos, text): return sentence[:last_valid_chunk_pos] + last_valid_chunk + def trim_single_sentence(text, max_chars): if len(text) <= max_chars: return text @@ -225,7 +236,7 @@ def trim_single_sentence(text, max_chars): # if present. Otherwise, cut desc in the middle of the sentence, preferably # at the end of a word - #find the first match + # find the first match ie_pos = None def on_ie_text(pos, match_text): @@ -250,21 +261,23 @@ def on_ie_text(pos, match_text): text = trim_single_sentence_at_word(text, max_chars) return remove_punctuation_at_end(text) + '...' -''' Processes description text. Drops all tags except and . Replaces - with . Replaces span.mw-geshi with . Returns the processed - description as str. - - The description is limited to max_sentences number of sentences and - max_chars number of characters (each delimited by a dot). - If a single sentence is longer than max_chars characters, '...' is appended. - Setting max_paren_text_size to controls the maximum number of characters in - parenthesized text. If the size of parenthesized block exceeds that, it is - removed. Such blocks within , or tag are ignored. -''' def process_description(el, max_sentences, max_chars, max_paren_text_size, debug=False): - + ''' Processes description text. Drops all tags except and . + Replaces with . Replaces span.mw-geshi with . Returns the + processed description as str. + + The description is limited to max_sentences number of sentences and + max_chars number of characters (each delimited by a dot). + If a single sentence is longer than max_chars characters, '...' is + appended. + + Setting max_paren_text_size to controls the maximum number of + characters in parenthesized text. If the size of parenthesized block + exceeds that, it is removed. Such blocks within , or tag + are ignored. + ''' el = deepcopy(el) # we'll modify the tree el.tag = 'root' del_all_attrs(el) @@ -278,12 +291,12 @@ def process_description(el, max_sentences, max_chars, else: t.drop_tag() desc = e.tostring(el, method='html', encoding=str, with_tail=False) - desc = desc.replace('','').replace('','') + desc = desc.replace('', '').replace('', '') if debug: print("ROOT: " + desc) # description must never contain newlines - desc = desc.replace('\n',' ') + desc = desc.replace('\n', ' ') # Handle 'i.e.' and 'that is' as a special case desc = desc.replace('i.e.', 'ᚃ') @@ -293,9 +306,6 @@ def process_description(el, max_sentences, max_chars, # remove text in parentheses (except when it's within some tag) # get the position of the cut of the description - open_count = 0 - open_paren_count = 0 - desc = remove_parentheses(desc, max_paren_text_size) sentences = split_sentences(desc) @@ -326,38 +336,38 @@ def process_description(el, max_sentences, max_chars, return desc -''' Returns a short description of a feature. This is the first sentence after - the declaration (dcl template). If a list follows immediately, then the - description is picked from a list item identified by num - Raises DdgException on error -''' def get_short_description(root_el, num, max_sentences=1, max_chars=200, max_paren_text_size=40, debug=False): + ''' Returns a short description of a feature. This is the first sentence + after the declaration (dcl template). If a list follows immediately, + then the description is picked from a list item identified by num + Raises DdgException on error + ''' content_el = get_content_el(root_el) dcl_tables = content_el.xpath('table[@class="t-dcl-begin"]') if len(dcl_tables) == 0: raise DdgException("No dcl table found") - #todo debug + # todo debug dcl_table = dcl_tables[0] desc_el = dcl_table.getnext() - if desc_el == None: + if desc_el is None: raise DdgException("No elements after dcl table") if desc_el.tag == 'p': return process_description(desc_el, max_sentences, max_chars, max_paren_text_size, debug=debug) - elif desc_el.tag == 'div' and desc_el.get('class') == 't-li1': - if num == None: + if desc_el.tag == 'div' and desc_el.get('class') == 't-li1': + if num is None: raise DdgException("Versioned summary with no version supplied") - while (desc_el != None and desc_el.tag == 'div' and - desc_el.get('class') == 't-li1'): + while (desc_el is not None and desc_el.tag == 'div' and + desc_el.get('class') == 't-li1'): index_els = desc_el.xpath('span[@class="t-li"]') if len(index_els) == 0: desc_el = desc_el.getnext() @@ -366,19 +376,19 @@ def get_short_description(root_el, num, max_sentences=1, max_chars=200, index = e.tostring(index_el, encoding=str, method='text', with_tail=False) - m = re.match('^\s*(\d+)\)\s*$', index) + m = re.match(r'^\s*(\d+)\)\s*$', index) if m and int(m.group(1)) == num: index_el.drop_tree() return process_description(desc_el, max_sentences, max_chars, max_paren_text_size, debug=debug) - m = re.match('^\s*(\d+)-(\d+)\)\s*$', index) + m = re.match(r'^\s*(\d+)-(\d+)\)\s*$', index) if m and int(m.group(1)) <= num and int(m.group(2)) >= num: index_el.drop_tree() return process_description(desc_el, max_sentences, max_chars, max_paren_text_size, debug=debug) - m = re.match('^\s*(\d+),(\d+)\)\s*$', index) + m = re.match(r'^\s*(\d+),(\d+)\)\s*$', index) if m and num in [int(m.group(1)), int(m.group(2))]: index_el.drop_tree() return process_description(desc_el, max_sentences, max_chars, diff --git a/devhelp2qch.py b/devhelp2qch.py index d6b8da475..bf57ed528 100755 --- a/devhelp2qch.py +++ b/devhelp2qch.py @@ -17,21 +17,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. -# devhelp2qch.py script converts 'in_root' xml source file to 'out_root' xml output -# including files list from library 'files_root' at the end. -from lxml import etree -from copy import deepcopy -import sys import argparse +from lxml import etree from index_transform.devhelp_qch import convert_devhelp_to_qch + def main(): parser = argparse.ArgumentParser(prog='devhelp2qch.py') - parser.add_argument('--src', type=str, help='The path to the XML input file') - parser.add_argument('--dst', type=str, help='The path to the destination XML file') - parser.add_argument('--virtual_folder', type=str, help='Virtual folder name') - parser.add_argument('--file_list', type=str, help='The path to the file list in XML file') + parser.add_argument('--src', type=str, + help='The path to the XML input file') + parser.add_argument('--dst', type=str, + help='The path to the destination XML file') + parser.add_argument('--virtual_folder', type=str, + help='Virtual folder name') + parser.add_argument('--file_list', type=str, + help='The path to the file list in XML file') args = parser.parse_args() src_path = args.src @@ -44,8 +45,10 @@ def main(): file_tree = etree.parse(file_path, parser) out_f = open(dst_path, 'wb') - out_f.write(convert_devhelp_to_qch(in_tree.getroot(), file_tree.getroot(), v_folder)) + out_f.write(convert_devhelp_to_qch(in_tree.getroot(), file_tree.getroot(), + v_folder)) out_f.close() + if __name__ == "__main__": main() diff --git a/export.py b/export.py index bc449bce7..a7a8d2cfc 100755 --- a/export.py +++ b/export.py @@ -23,6 +23,7 @@ import urllib.request import json + def retrieve_page_names(root, ns_index): begin = None @@ -30,11 +31,11 @@ def retrieve_page_names(root, ns_index): while True: params = { - 'action' : 'query', - 'list' : 'allpages', - 'apnamespace' : ns_index, - 'aplimit' : 500, - 'format' : 'json' + 'action': 'query', + 'list': 'allpages', + 'apnamespace': ns_index, + 'aplimit': 500, + 'format': 'json' } if begin is not None: params['apcontinue'] = begin @@ -43,19 +44,21 @@ def retrieve_page_names(root, ns_index): with urllib.request.urlopen(url) as f: data = json.loads(f.read().decode('utf-8')) - pages += [ p['title'] for p in data['query']['allpages'] ] + pages += [p['title'] for p in data['query']['allpages']] - if ('query-continue' in data and 'allpages' in data['query-continue'] and - 'apcontinue' in data['query-continue']['allpages']): + if ('query-continue' in data and + 'allpages' in data['query-continue'] and + 'apcontinue' in data['query-continue']['allpages']): begin = data['query-continue']['allpages']['apcontinue'] else: return pages + def export_pages(root, pages, output_path): params = { - 'wpDownload' : '', - 'curonly' : 1, - 'pages' : '\n'.join(pages) + 'wpDownload': '', + 'curonly': 1, + 'pages': '\n'.join(pages) } data = urllib.parse.urlencode(params) @@ -64,21 +67,28 @@ def export_pages(root, pages, output_path): urllib.request.urlretrieve(url, output_path, data=data) + def main(): parser = argparse.ArgumentParser(prog='export.py') - parser.add_argument('--url', type=str, help='The URL to the root of the MediaWiki installation') - parser.add_argument('output_path', type=str, help='The path to the XML file to save output to') - parser.add_argument('ns_index', type=str, nargs='+', help='The indices of the namespaces to retrieve') + parser.add_argument('--url', type=str, + help='The URL to the root of the MediaWiki ' + 'installation') + parser.add_argument('output_path', type=str, + help='The path to the XML file to save output to') + parser.add_argument('ns_index', type=str, nargs='+', + help='The indices of the namespaces to retrieve') args = parser.parse_args() pages = [] for ns_index in args.ns_index: new_pages = retrieve_page_names(args.url, ns_index) - print("Retrieved {0} pages for namespace {1}".format(len(new_pages), ns_index)) + print("Retrieved {0} pages for namespace {1}".format(len(new_pages), + ns_index)) pages += new_pages pages = sorted(pages) export_pages(args.url, pages, args.output_path) + if __name__ == "__main__": main() diff --git a/fix_devhelp-links.py b/fix_devhelp-links.py index 10c555f19..84860626d 100755 --- a/fix_devhelp-links.py +++ b/fix_devhelp-links.py @@ -18,9 +18,10 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' +import sys import lxml.etree as e from link_map import LinkMap -import sys + if len(sys.argv) != 3: print('''Please provide the following 2 argument: @@ -40,7 +41,7 @@ for el in el_mod: link = el.get('link') target = mapping.get_dest(link) - if target == None: + if target is None: print('Could not find ' + link + ' in mapping') target = '404' el.set('link', target) @@ -49,4 +50,3 @@ out_f.write(e.tostring(root, encoding='utf-8', pretty_print=True, xml_declaration=True)) out_f.close() - diff --git a/gadgets/standard_revisions-tests/base.py b/gadgets/standard_revisions-tests/base.py index 848d43188..b780e8d18 100644 --- a/gadgets/standard_revisions-tests/base.py +++ b/gadgets/standard_revisions-tests/base.py @@ -17,13 +17,10 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' +import unittest from selenium import webdriver -from selenium.webdriver.common.by import By -from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select -from selenium.common.exceptions import NoSuchElementException -from selenium.common.exceptions import NoAlertPresentException -import unittest, time, re + class Driver: def __init__(self): @@ -31,8 +28,8 @@ def __init__(self): driver = webdriver.Firefox() driver.implicitly_wait(30) try: - driver.get(base_url + "/mwiki/index.php?title=Special:UserLogout&returnto=Main+Page") - driver.get(base_url + "/mwiki/index.php?title=Special:UserLogin&returnto=Main+Page") + driver.get(base_url + "/mwiki/index.php?title=Special:UserLogout&returnto=Main+Page") # noqa + driver.get(base_url + "/mwiki/index.php?title=Special:UserLogin&returnto=Main+Page") # noqa driver.find_element_by_id("wpName1").clear() driver.find_element_by_id("wpName1").send_keys("test5") driver.find_element_by_id("wpPassword1").clear() @@ -40,18 +37,19 @@ def __init__(self): driver.find_element_by_id("wpLoginAttempt").click() if driver.find_element_by_link_text("Test5").text != "Test5": raise Exception("Could not login") - except: + except Exception: driver.quit() raise self.driver = driver self.base_url = base_url - def __del__(self): self.driver.quit() + driver_instance = Driver() + class CppTestCase(unittest.TestCase): @classmethod def setUpClass(self): diff --git a/gadgets/standard_revisions-tests/test_dcl.py b/gadgets/standard_revisions-tests/test_dcl.py index effeedd9c..aa7f9c7f3 100644 --- a/gadgets/standard_revisions-tests/test_dcl.py +++ b/gadgets/standard_revisions-tests/test_dcl.py @@ -17,7 +17,8 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -from base import * +from base import CppTestCase + class TestDcl(CppTestCase): def test_hides_dcl_items_in_dcl_rev(self): diff --git a/gadgets/standard_revisions-tests/test_dsc.py b/gadgets/standard_revisions-tests/test_dsc.py index 314182ba3..8ca30d99c 100644 --- a/gadgets/standard_revisions-tests/test_dsc.py +++ b/gadgets/standard_revisions-tests/test_dsc.py @@ -17,7 +17,8 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -from base import * +from base import CppTestCase + class TestDsc(CppTestCase): def test_hides_dsc_items_with_explicit_mark(self): @@ -32,4 +33,3 @@ def test_hides_dsc_items_with_explicit_mark(self): self.select_cxx11() self.assert_text_in_body("std::not_visible_in_cxx98") self.assert_text_not_in_body("std::not_visible_in_cxx11") - diff --git a/gadgets/standard_revisions-tests/test_rev.py b/gadgets/standard_revisions-tests/test_rev.py index 8287b51be..e522571a5 100644 --- a/gadgets/standard_revisions-tests/test_rev.py +++ b/gadgets/standard_revisions-tests/test_rev.py @@ -17,8 +17,8 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -import unittest, time, re -from base import * +from base import CppTestCase + class TestRev(CppTestCase): def test_revlist_works_in_dsc_item(self): @@ -48,7 +48,6 @@ def test_rev_inl_works_in_text(self): self.assert_text_not_in_body("not_visible_in_cxx11") def test_rev_works_with_fully_closed_ranges(self): - driver = self.driver self.get_page("test-gadget-stdrev/rev-works-with-fully-closed-ranges") self.assert_text_in_body("since-cxx03-until-none") self.assert_text_in_body("since-cxx11-until-none") diff --git a/gadgets/standard_revisions-tests/test_section_hierarchy.py b/gadgets/standard_revisions-tests/test_section_hierarchy.py index ae246c314..a88ee01cf 100644 --- a/gadgets/standard_revisions-tests/test_section_hierarchy.py +++ b/gadgets/standard_revisions-tests/test_section_hierarchy.py @@ -16,69 +16,70 @@ You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. ''' +# noqa + +from base import CppTestCase -import unittest, time, re -from base import * class TestSectionHierarchy(CppTestCase): def test_hides_h3_when_section_contains_dsc_with_removed_elems(self): driver = self.driver - self.get_page("test-gadget-stdrev/hides-h3-when-section-contains-dsc-with-removed-elems") - self.assertTrue(driver.find_element_by_id("Should_be_removed_when_c.2B.2B98").is_displayed()) + self.get_page("test-gadget-stdrev/hides-h3-when-section-contains-dsc-with-removed-elems") # noqa + self.assertTrue(driver.find_element_by_id("Should_be_removed_when_c.2B.2B98").is_displayed()) # noqa self.select_cxx98() - self.assertFalse(driver.find_element_by_id("Should_be_removed_when_c.2B.2B98").is_displayed()) + self.assertFalse(driver.find_element_by_id("Should_be_removed_when_c.2B.2B98").is_displayed()) # noqa self.select_cxx11() - self.assertTrue(driver.find_element_by_id("Should_be_removed_when_c.2B.2B98").is_displayed()) + self.assertTrue(driver.find_element_by_id("Should_be_removed_when_c.2B.2B98").is_displayed()) # noqa def test_hides_h3_when_section_contains_dsc_with_removed_until(self): driver = self.driver - self.get_page("test-gadget-stdrev/hides-h3-when-section-contains-dsc-with-removed-until") - self.assertTrue(driver.find_element_by_id("Should_be_removed_when_c.2B.2B11").is_displayed()) + self.get_page("test-gadget-stdrev/hides-h3-when-section-contains-dsc-with-removed-until") # noqa + self.assertTrue(driver.find_element_by_id("Should_be_removed_when_c.2B.2B11").is_displayed()) # noqa self.select_cxx98() - self.assertTrue(driver.find_element_by_id("Should_be_removed_when_c.2B.2B11").is_displayed()) + self.assertTrue(driver.find_element_by_id("Should_be_removed_when_c.2B.2B11").is_displayed()) # noqa self.select_cxx11() - self.assertFalse(driver.find_element_by_id("Should_be_removed_when_c.2B.2B11").is_displayed()) + self.assertFalse(driver.find_element_by_id("Should_be_removed_when_c.2B.2B11").is_displayed()) # noqa def test_hides_h3_when_section_contains_only_stdrev(self): driver = self.driver - self.get_page("test-gadget-stdrev/hides-h3-when-section-contains-only-stdrev") - self.assertTrue(driver.find_element_by_id("Should_be_removed_in_cxx98").is_displayed()) + self.get_page("test-gadget-stdrev/hides-h3-when-section-contains-only-stdrev") # noqa + self.assertTrue(driver.find_element_by_id("Should_be_removed_in_cxx98").is_displayed()) # noqa self.select_cxx98() - self.assertFalse(driver.find_element_by_id("Should_be_removed_in_cxx98").is_displayed()) + self.assertFalse(driver.find_element_by_id("Should_be_removed_in_cxx98").is_displayed()) # noqa self.select_cxx11() - self.assertTrue(driver.find_element_by_id("Should_be_removed_in_cxx98").is_displayed()) + self.assertTrue(driver.find_element_by_id("Should_be_removed_in_cxx98").is_displayed()) # noqa def test_preserves_h3_when_section_visible(self): driver = self.driver - self.get_page("test-gadget-stdrev/preserves-h3-when-section-with-h5-visible") - self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) + self.get_page("test-gadget-stdrev/preserves-h3-when-section-with-h5-visible") # noqa + self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) # noqa self.select_cxx98() - self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) + self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) # noqa self.select_cxx11() - self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) + self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) # noqa def test_preserves_h3_when_section_with_h5_visible(self): driver = self.driver - self.get_page("test-gadget-stdrev/preserves-h3-when-section-with-h5-visible") - self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) - self.assertTrue(driver.find_element_by_id("Should_always_be_visible2").is_displayed()) - self.assertTrue(driver.find_element_by_id("Should_not_be_visible_in_cxx98").is_displayed()) + self.get_page("test-gadget-stdrev/preserves-h3-when-section-with-h5-visible") # noqa + self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) # noqa + self.assertTrue(driver.find_element_by_id("Should_always_be_visible2").is_displayed()) # noqa + self.assertTrue(driver.find_element_by_id("Should_not_be_visible_in_cxx98").is_displayed()) # noqa self.select_cxx98() - self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) - self.assertTrue(driver.find_element_by_id("Should_always_be_visible2").is_displayed()) - self.assertFalse(driver.find_element_by_id("Should_not_be_visible_in_cxx98").is_displayed()) + self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) # noqa + self.assertTrue(driver.find_element_by_id("Should_always_be_visible2").is_displayed()) # noqa + self.assertFalse(driver.find_element_by_id("Should_not_be_visible_in_cxx98").is_displayed()) # noqa self.select_cxx11() - self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) - self.assertTrue(driver.find_element_by_id("Should_always_be_visible2").is_displayed()) - self.assertTrue(driver.find_element_by_id("Should_not_be_visible_in_cxx98").is_displayed()) + self.assertTrue(driver.find_element_by_id("Should_always_be_visible").is_displayed()) # noqa + self.assertTrue(driver.find_element_by_id("Should_always_be_visible2").is_displayed()) # noqa + self.assertTrue(driver.find_element_by_id("Should_not_be_visible_in_cxx98").is_displayed()) # noqa diff --git a/index2autolinker.py b/index2autolinker.py index 863ad363e..7a5182497 100755 --- a/index2autolinker.py +++ b/index2autolinker.py @@ -18,40 +18,41 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -''' This script produces a definition file for AutoLinker extension - - The definitions are written in JSON in the following format: - - { - "groups" : [ - { - name : "string", - OPTIONAL base_url : "string", END - urls : [ "url", "url", ... ], - }, - ... - ], - "links" : [ - { - string : "string", - EITHER on_group : "name" OR on_page : "url" END - target : "url", - }, - ... - ], - } -''' - import argparse import json -from index_transform.autolinker import * +from index_transform.autolinker import Index2AutolinkerGroups +from index_transform.autolinker import Index2AutolinkerLinks + def main(): + ''' This script produces a definition file for AutoLinker extension + + The definitions are written in JSON in the following format: + + { + "groups" : [ + { + name : "string", + OPTIONAL base_url : "string", END + urls : [ "url", "url", ... ], + }, + ... + ], + "links" : [ + { + string : "string", + EITHER on_group : "name" OR on_page : "url" END + target : "url", + }, + ... + ], + } + ''' parser = argparse.ArgumentParser(prog='index2autolinker') parser.add_argument('index', type=str, - help='Path to index file to process') + help='Path to index file to process') parser.add_argument('destination', type=str, - help='Path to destination file to store results to') + help='Path to destination file to store results to') args = parser.parse_args() out_f = open(args.destination, 'w', encoding='utf-8') @@ -64,14 +65,16 @@ def main(): tr.transform_file(args.index) links = tr.links - json_groups = [ v for v in groups.values() ] + json_groups = [v for v in groups.values()] json_groups = sorted(json_groups, key=lambda x: x['name']) links = sorted(links, key=lambda x: x['target']) - out_f.write(json.dumps({ 'groups' : json_groups, 'links' : links}, indent=None, + out_f.write(json.dumps({'groups': json_groups, 'links': links}, + indent=None, separators=(',\n', ': '), sort_keys=True)) out_f.close() + if __name__ == '__main__': main() diff --git a/index2browser.py b/index2browser.py index 734c2a017..99b36225f 100755 --- a/index2browser.py +++ b/index2browser.py @@ -18,15 +18,16 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -from index_transform.browser import * import argparse +from index_transform.browser import Index2Browser + def main(): parser = argparse.ArgumentParser(prog='index2browser') parser.add_argument('index', type=str, - help='Path to index file to process') + help='Path to index file to process') parser.add_argument('destination', type=str, - help='Path to destination file to store results to') + help='Path to destination file to store results to') args = parser.parse_args() out_f = open(args.destination, 'w', encoding='utf-8') @@ -62,10 +63,6 @@ def main(): ''') + if __name__ == '__main__': main() - - - - - diff --git a/index2ddg.py b/index2ddg.py index 9789e562f..9e03566ed 100755 --- a/index2ddg.py +++ b/index2ddg.py @@ -20,16 +20,14 @@ import argparse import fnmatch -import json import os import sys import re import lxml.etree as e -import lxml.html as html +from lxml import html from index_transform.common import IndexTransform -from xml_utils import xml_escape from build_link_map import build_link_map from ddg_parse_html import get_declarations, get_short_description, DdgException @@ -67,45 +65,46 @@ # a member variable that is described in the same page as the containing class ITEM_TYPE_VARIABLE_INLINEMEM = 11 + def get_item_type(el): if (el.tag == 'const' and el.getparent().tag == 'enum' and - el.get('link') == '.'): + el.get('link') == '.'): return ITEM_TYPE_ENUM_CONST if el.tag == 'function': if el.get('link') == '.': return ITEM_TYPE_FUNCTION_INLINEMEM - else: - return ITEM_TYPE_FUNCTION + return ITEM_TYPE_FUNCTION + if el.tag == 'variable': if el.get('link') == '.': return ITEM_TYPE_VARIABLE_INLINEMEM - else: - return ITEM_TYPE_VARIABLE + return ITEM_TYPE_VARIABLE if el.tag == 'constructor': if el.get('link') == '.': return ITEM_TYPE_CONSTRUCTOR_INLINEMEM - else: - return ITEM_TYPE_CONSTRUCTOR + return ITEM_TYPE_CONSTRUCTOR if el.tag == 'destructor': if el.get('link') == '.': return ITEM_TYPE_DESTRUCTOR_INLINEMEM - else: - return ITEM_TYPE_DESTRUCTOR + return ITEM_TYPE_DESTRUCTOR if el.tag == 'class': return ITEM_TYPE_CLASS if el.tag == 'enum': return ITEM_TYPE_ENUM - return None # not recognized + return None # not recognized + class DDGDebug: - def __init__(self, enabled=False, ident_match=None, debug_abstracts_path=None): + def __init__(self, enabled=False, ident_match=None, + debug_abstracts_path=None): self.enabled = enabled self.ident_match = ident_match self.stat_line_nums = [] self.debug_abstracts_file = sys.stdout if debug_abstracts_path is not None: - self.debug_abstracts_file = open(debug_abstracts_path, 'w', encoding='utf-8') + self.debug_abstracts_file = \ + open(debug_abstracts_path, 'w', encoding='utf-8') # track the statistics of number of lines used by the entries def submit_line_num(self, line_num): @@ -126,6 +125,7 @@ def should_skip_ident(self, ident): return False return True + class Index2DuckDuckGoList(IndexTransform): def __init__(self, ident_map): @@ -139,9 +139,10 @@ def process_item_hook(self, el, full_name, full_link): if full_link in self.ident_map: self.ident_map[full_link][full_name] = item_type else: - self.ident_map[full_link] = { full_name : item_type } + self.ident_map[full_link] = {full_name: item_type} IndexTransform.process_item_hook(self, el, full_name, full_link) + def get_html_files(root): files = [] for dir, dirnames, filenames in os.walk(root): @@ -149,6 +150,7 @@ def get_html_files(root): files.append(os.path.join(dir, filename)) return files + def get_processing_instructions(ident_map, link_map): proc_ins = {} @@ -156,44 +158,48 @@ def get_processing_instructions(ident_map, link_map): if link in link_map.mapping: fn = link_map.mapping[link] if fn not in proc_ins: - proc_ins[fn] = { 'fn': fn, 'link': link, 'idents': {}} + proc_ins[fn] = {'fn': fn, 'link': link, 'idents': {}} for ident in ident_map[link]: - proc_ins[fn]['idents'][ident] = { 'ident' : ident, - 'type' : ident_map[link][ident] } + proc_ins[fn]['idents'][ident] = {'ident': ident, + 'type': ident_map[link][ident]} return proc_ins + # process the files # returns the unqualified name of an identifier def get_unqualified_name(ident): if ident.find('(') != -1: - ident = re.sub('\(.*?\)', '', ident) + ident = re.sub(r'\(.*?\)', '', ident) if ident.find('<') != -1: - ident = re.sub('\<.*?\>', '', ident) + ident = re.sub(r'\<.*?\>', '', ident) qpos = ident.rfind('::') if qpos != -1: ident = ident[qpos+2:] return ident + # returns the version number common to all declarations. Returns none if two # declarations have different version numbers or if no version number is # provided def get_version(decls): rv = None - for code,v in decls: + for code, v in decls: if v: - if rv == None: + if rv is None: rv = v elif v != rv: return None return rv -def build_abstract(decls, desc, max_code_lines, split_code_lines, debug=DDGDebug()): + +def build_abstract(decls, desc, max_code_lines, split_code_lines, + debug=DDGDebug()): limited = False code_snippets = [] - for i,(code,ver) in enumerate(decls): + for i, (code, ver) in enumerate(decls): code = code.strip() code = code.replace('<', '<').replace('>', '>') code_num_lines = code.count('\n') + 1 @@ -201,8 +207,8 @@ def build_abstract(decls, desc, max_code_lines, split_code_lines, debug=DDGDebug # limit the number of code snippets to be included so that total number # of lines is less than max_code_lines. The limit becomes active only # for the second and subsequent snippets. - first = True if i == 0 else False; - last = True if i == len(decls)-1 else False; + first = True if i == 0 else False + last = True if i == len(decls)-1 else False if not first: if last: @@ -220,16 +226,18 @@ def build_abstract(decls, desc, max_code_lines, split_code_lines, debug=DDGDebug max_code_lines -= code_num_lines if split_code_lines: - code_snippets = ['
' + s + '
' for s in code_snippets] + code_snippets = ['
' + s + '
' + for s in code_snippets] code_text = ''.join(code_snippets) else: code_text = '
' + '\n\n'.join(code_snippets) + '
' if limited: - code_text += '\n

Additional declarations have been omitted

' + code_text += \ + '\n

Additional declarations have been omitted

' # count the number of lines used - num_lines = code_text.count('\n') + 1 # last line has no newline after it + num_lines = code_text.count('\n') + 1 # last line has no newline after it if len(desc) > 110: num_lines += 2 else: @@ -252,37 +260,37 @@ def build_abstract(decls, desc, max_code_lines, split_code_lines, debug=DDGDebug print("# END ========") return result_text -''' Outputs additional redirects for an identifier. - - Firstly, we replace '::' with spaces. Then we add two redirects: one with - unchanged text and another with '_' replaced with spaces. We strip one - level of namespace/class qualification and repeat the process with the - remaining text. - - For constructors and destructors, we strip the function name and apply the - abovementioned algorithm, the only difference being that we append - (or prepend) 'constructor' or 'destructor' to the title of the redirect - respectively. - - Each redirect has a 'priority', which is defined by the number of stripped - namespace/class qualifications from the entry that produced the redirect. - This is used to remove duplicate redirects. For each group of duplicate - redirects, we find the redirect with the highest priority (i.e. lowest - number of qualifications stripped) and remove all other redirects. If the - number of highest-priority redirects is more than one, then we remove all - redirects from the group altogether. - - We don't add any redirects to specializations, overloads or operators. -''' -''' array of dict { 'title' -> redirect title, - 'target' -> redirect target, - 'priority' -> redirect priority as int - } -''' def build_redirects(redirects, item_ident, item_type): - - for ch in [ '(', ')', '<', '>', 'operator' ]: + ''' Outputs additional redirects for an identifier. + + Firstly, we replace '::' with spaces. Then we add two redirects: one + with unchanged text and another with '_' replaced with spaces. We strip + one level of namespace/class qualification and repeat the process with + the remaining text. + + For constructors and destructors, we strip the function name and apply + the abovementioned algorithm, the only difference being that we append + (or prepend) 'constructor' or 'destructor' to the title of the redirect + respectively. + + Each redirect has a 'priority', which is defined by the number of + stripped namespace/class qualifications from the entry that produced + the redirect. This is used to remove duplicate redirects. For each + group of duplicate redirects, we find the redirect with the highest + priority (i.e. lowest number of qualifications stripped) and remove all + other redirects. If the number of highest-priority redirects is more + than one, then we remove all redirects from the group altogether. + + We don't add any redirects to specializations, overloads or operators. + ''' + ''' array of dict { 'title' -> redirect title, + 'target' -> redirect target, + 'priority' -> redirect priority as int + } + ''' + + for ch in ['(', ')', '<', '>', 'operator']: if ch in item_ident: return @@ -299,41 +307,43 @@ def do_parts(redirects, parts, prepend='', append=''): p = 0 while p < len(parts): redir1 = prepend + ' '.join(parts[p:]) + append - redir2 = prepend + ' '.join(x.replace('_',' ') for x in parts[p:]) + append + redir2 = prepend + \ + ' '.join(x.replace('_', ' ') for x in parts[p:]) + append redir1 = redir1.replace(' ', ' ').replace(' ', ' ') redir2 = redir2.replace(' ', ' ').replace(' ', ' ') - redirects.append({'title' : redir1, 'target' : target, - 'priority' : p}) + redirects.append({'title': redir1, 'target': target, + 'priority': p}) if redir1 != redir2: - redirects.append({'title' : redir2, 'target' : target, - 'priority' : p}) + redirects.append({'title': redir2, 'target': target, + 'priority': p}) p += 1 # ----- - if item_type in [ ITEM_TYPE_CLASS, - ITEM_TYPE_FUNCTION, - ITEM_TYPE_FUNCTION_INLINEMEM, - ITEM_TYPE_VARIABLE, - ITEM_TYPE_VARIABLE_INLINEMEM, - ITEM_TYPE_ENUM, - ITEM_TYPE_ENUM_CONST ]: + if item_type in [ITEM_TYPE_CLASS, + ITEM_TYPE_FUNCTION, + ITEM_TYPE_FUNCTION_INLINEMEM, + ITEM_TYPE_VARIABLE, + ITEM_TYPE_VARIABLE_INLINEMEM, + ITEM_TYPE_ENUM, + ITEM_TYPE_ENUM_CONST]: do_parts(redirects, parts) - elif item_type in [ ITEM_TYPE_CONSTRUCTOR, - ITEM_TYPE_CONSTRUCTOR_INLINEMEM ]: + elif item_type in [ITEM_TYPE_CONSTRUCTOR, + ITEM_TYPE_CONSTRUCTOR_INLINEMEM]: parts.pop() do_parts(redirects, parts, prepend='constructor') do_parts(redirects, parts, append='constructor') - elif item_type in [ ITEM_TYPE_DESTRUCTOR, - ITEM_TYPE_DESTRUCTOR_INLINEMEM ]: + elif item_type in [ITEM_TYPE_DESTRUCTOR, + ITEM_TYPE_DESTRUCTOR_INLINEMEM]: parts.pop() do_parts(redirects, parts, prepend='destructor') do_parts(redirects, parts, append='destructor') else: pass # should not be here + def output_redirects(out, redirects): # convert to a convenient data structure @@ -353,7 +363,7 @@ def output_redirects(out, redirects): redir_map[title][priority].append(target) # get non-duplicate redirects - ok_redirects = [] # list ( dict { 'title' : title, 'target' : target }) + ok_redirects = [] # list ( dict { 'title' : title, 'target' : target }) for title in redir_map: # priority decreases with increasing values @@ -361,7 +371,7 @@ def output_redirects(out, redirects): if len(redir_map[title][highest_prio]) == 1: # not duplicate target = redir_map[title][highest_prio][0] - ok_redirects.append({ 'title' : title, 'target' : target }) + ok_redirects.append({'title': title, 'target': target}) # sort the redirects ok_redirects = sorted(ok_redirects, key=lambda x: x['title']) @@ -379,33 +389,42 @@ def output_redirects(out, redirects): line += '\t\t\t\t\t\t\t\t\t\t\n' out.write(line) + def process_identifier(out, redirects, root, link, item_ident, item_type, opts, debug=DDGDebug()): # get the name by extracting the unqualified identifier name = get_unqualified_name(item_ident) - debug_verbose = True if debug.enabled and debug.ident_match is not None else False + debug_verbose = False + if debug.enabled and debug.ident_match is not None: + debug_verbose = True try: if item_type == ITEM_TYPE_CLASS: decls = get_declarations(root, name) - desc = get_short_description(root, get_version(decls), opts.max_sentences, opts.max_characters, - opts.max_paren_chars, debug=debug_verbose) + desc = get_short_description(root, get_version(decls), + opts.max_sentences, + opts.max_characters, + opts.max_paren_chars, + debug=debug_verbose) abstract = build_abstract(decls, desc, opts.max_code_lines, opts.split_code_snippets, debug=debug) - elif item_type in [ ITEM_TYPE_FUNCTION, - ITEM_TYPE_CONSTRUCTOR, - ITEM_TYPE_DESTRUCTOR ]: + elif item_type in [ITEM_TYPE_FUNCTION, + ITEM_TYPE_CONSTRUCTOR, + ITEM_TYPE_DESTRUCTOR]: decls = get_declarations(root, name) - desc = get_short_description(root, get_version(decls), opts.max_sentences, opts.max_characters, - opts.max_paren_chars, debug=debug_verbose) + desc = get_short_description(root, get_version(decls), + opts.max_sentences, + opts.max_characters, + opts.max_paren_chars, + debug=debug_verbose) abstract = build_abstract(decls, desc, opts.max_code_lines, opts.split_code_snippets, debug=debug) - elif item_type in [ ITEM_TYPE_FUNCTION_INLINEMEM, - ITEM_TYPE_CONSTRUCTOR_INLINEMEM, - ITEM_TYPE_DESTRUCTOR_INLINEMEM ]: - raise DdgException("INLINEMEM") # not implemented + elif item_type in [ITEM_TYPE_FUNCTION_INLINEMEM, + ITEM_TYPE_CONSTRUCTOR_INLINEMEM, + ITEM_TYPE_DESTRUCTOR_INLINEMEM]: + raise DdgException("INLINEMEM") # not implemented ''' Implementation notes: * the declarations are possibly versioned * declaration is selected from the member table @@ -413,9 +432,9 @@ def process_identifier(out, redirects, root, link, item_ident, item_type, (last part after :: is enough, hopefully) ''' - elif item_type in [ ITEM_TYPE_VARIABLE, - ITEM_TYPE_VARIABLE_INLINEMEM, - ITEM_TYPE_ENUM ]: + elif item_type in [ITEM_TYPE_VARIABLE, + ITEM_TYPE_VARIABLE_INLINEMEM, + ITEM_TYPE_ENUM]: raise DdgException("ENUM") # not implemented ''' Implementation notes: * the declarations are possibly versioned @@ -444,7 +463,7 @@ def process_identifier(out, redirects, root, link, item_ident, item_type, # further_reading, external links, disambiguation, images line += '\t\t\t\t\t\t\t\t\t' # abstract - abstract = abstract.replace('\n','\\n') + abstract = abstract.replace('\n', '\\n') line += abstract + '\t' # source url line += 'http://en.cppreference.com/w/' + link + '\n' @@ -454,41 +473,65 @@ def process_identifier(out, redirects, root, link, item_ident, item_type, except DdgException as err: if debug.enabled: - line = '# error (' + str(err) + "): " + link + ": " + item_ident + "\n" + line = '# error ({0}): {1}: {2}\n'.format(str(err), link, + item_ident) out.write(line) + def main(): parser = argparse.ArgumentParser(prog='index2ddg.py') - parser.add_argument('index', type=str, - help='The path to the XML index containing identifier data') - parser.add_argument('reference', type=str, - help=('The path to the downloaded reference (reference ' - 'directory in the downloaded archive)')) - parser.add_argument('output', type=str, - help='The path to destination output.txt file') - parser.add_argument('--split_code_snippets', action='store_true', default=False, - help='Puts each declaration into a separate code snippet.') - parser.add_argument('--max_code_lines', type=int, default=6, - help='Maximum number of lines of code to show in abstract') - parser.add_argument('--max_sentences', type=int, default=1, - help='Maximum number of sentences to use for the description') - parser.add_argument('--max_characters', type=int, default=200, - help='Maximum number of characters to use for the description') - parser.add_argument('--max_paren_chars', type=int, default=40, - help='Maximum size of parenthesized text in the description. '+ - 'Parenthesized chunks longer than that is removed, unless '+ - 'they are within , or tags') - parser.add_argument('--debug', action='store_true', default=False, - help='Enables debug mode.') - parser.add_argument('--debug_ident', type=str, default=None, - help='Processes only the identifiers that match debug_ident') - parser.add_argument('--debug_abstracts_path', type=str, default=None, - help='Path to print the abstracts before newline stripping occurs') + + parser.add_argument( + 'index', type=str, + help='The path to the XML index containing identifier data') + + parser.add_argument( + 'reference', type=str, + help='The path to the downloaded reference (reference directory in ' + 'the downloaded archive)') + + parser.add_argument( + 'output', type=str, + help='The path to destination output.txt file') + + parser.add_argument( + '--split_code_snippets', action='store_true', default=False, + help='Puts each declaration into a separate code snippet.') + + parser.add_argument( + '--max_code_lines', type=int, default=6, + help='Maximum number of lines of code to show in abstract') + + parser.add_argument( + '--max_sentences', type=int, default=1, + help='Maximum number of sentences to use for the description') + + parser.add_argument( + '--max_characters', type=int, default=200, + help='Maximum number of characters to use for the description') + + parser.add_argument( + '--max_paren_chars', type=int, default=40, + help='Maximum size of parenthesized text in the description. ' + 'Parenthesized chunks longer than that is removed, unless they ' + 'are within , or tags') + + parser.add_argument( + '--debug', action='store_true', default=False, + help='Enables debug mode.') + + parser.add_argument( + '--debug_ident', type=str, default=None, + help='Processes only the identifiers that match debug_ident') + + parser.add_argument( + '--debug_abstracts_path', type=str, default=None, + help='Path to print the abstracts before newline stripping occurs') args = parser.parse_args() - # If a the second argument is 'debug', the program switches to debug mode and - # prints everything to stdout. If the third argument is provided, the program - # processes only the identifiers that match the provided string + # If a the second argument is 'debug', the program switches to debug mode + # and prints everything to stdout. If the third argument is provided, the + # program processes only the identifiers that match the provided string debug = DDGDebug(args.debug, args.debug_ident, args.debug_abstracts_path) @@ -504,9 +547,6 @@ def main(): tr = Index2DuckDuckGoList(ident_map) tr.transform_file(index_file) - # get a list of existing pages - html_files = get_html_files(args.reference) - # get a mapping between titles and pages # linkmap = dict { title -> filename } link_map = build_link_map(args.reference) @@ -515,12 +555,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 = [v for v in 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 = [v for v in idents.values()] idents = sorted(idents, key=lambda x: x['ident']) page['idents'] = idents @@ -528,35 +568,37 @@ def main(): out = open(output_file, 'w', encoding='utf-8') - #i=1 + # i=1 for page in proc_ins: idents = page['idents'] link = page['link'] fn = page['fn'] - if debug.should_skip_ident([ i['ident'] for i in idents ]): + if debug.should_skip_ident([i['ident'] for i in idents]): continue - #print(str(i) + '/' + str(len(proc_ins)) + ': ' + link) - #i+=1 + # print(str(i) + '/' + str(len(proc_ins)) + ': ' + link) + # i+=1 - root = e.parse(os.path.join(args.reference, fn), parser=html.HTMLParser()) + root = e.parse(os.path.join(args.reference, fn), + parser=html.HTMLParser()) for ident in idents: item_ident = ident['ident'] item_type = ident['type'] - process_identifier(out, redirects, root, link, item_ident, item_type, - args, debug=debug) + process_identifier(out, redirects, root, link, item_ident, + item_type, args, debug=debug) output_redirects(out, redirects) if debug.enabled: print('=============================') print('Numbers of lines used:') - for i,l in enumerate(debug.stat_line_nums): + for i, l in enumerate(debug.stat_line_nums): print(str(i) + ': ' + str(l) + ' result(s)') + if __name__ == "__main__": main() diff --git a/index2devhelp.py b/index2devhelp.py index ea4f4ca56..e69633ba7 100755 --- a/index2devhelp.py +++ b/index2devhelp.py @@ -18,34 +18,35 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -from index_transform.devhelp import * import argparse -from xml_utils import xml_escape -import io +from index_transform.devhelp import transform_devhelp + def main(): parser = argparse.ArgumentParser(prog='index2devhelp') parser.add_argument('book_base', type=str, - help='url to the location of the book') + help='url to the location of the book') parser.add_argument('chapters_path', type=str, - help='path to the chapters file to include') + help='path to the chapters file to include') parser.add_argument('book_title', type=str, - help='the title of the book') + help='the title of the book') parser.add_argument('book_name', type=str, - help='the name of the package') + help='the name of the package') parser.add_argument('rel_link', type=str, - help='the link relative to the root of the documentation') + help='the link relative to the root of the ' + 'documentation') parser.add_argument('in_fn', type=str, - help='the path of the source file') + help='the path of the source file') parser.add_argument('dest_fn', type=str, - help='the path of the destination file') + help='the path of the destination file') args = parser.parse_args() with open(args.dest_fn, 'wb') as out_f: output = transform_devhelp(args.book_title, args.book_name, - args.book_base, args.rel_link, - args.chapters_path, args.in_fn) + args.book_base, args.rel_link, + args.chapters_path, args.in_fn) out_f.write(output) + if __name__ == '__main__': main() diff --git a/index2doxygen-tag.py b/index2doxygen-tag.py index adecfaaf1..dc979fd6c 100755 --- a/index2doxygen-tag.py +++ b/index2doxygen-tag.py @@ -18,22 +18,33 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -from index_transform.doxygen_tag import * import argparse -from link_map import LinkMap from lxml import etree +from link_map import LinkMap +from index_transform.doxygen_tag import Index2DoxygenTag +from index_transform.doxygen_tag import Item +from index_transform.doxygen_tag import print_map + def main(): parser = argparse.ArgumentParser(prog='index2doxygen-tag') - parser.add_argument('link_map_fn', type=str, - help='Path to index file to process') - parser.add_argument('in_fn', type=str, - help='the file name of the link map or \'web\' if no link remap ' + - 'should be done') - parser.add_argument('chapters_fn', type=str, - help='the file name of the source file') - parser.add_argument('dest_fn', type=str, - help='the file name of the destination file') + parser.add_argument( + 'link_map_fn', type=str, + help='Path to index file to process') + + parser.add_argument( + 'in_fn', type=str, + help='the file name of the link map or \'web\' if no link remap ' + 'should be done') + + parser.add_argument( + 'chapters_fn', type=str, + help='the file name of the source file') + + parser.add_argument( + 'dest_fn', type=str, + help='the file name of the destination file') + args = parser.parse_args() link_map_fn = args.link_map_fn @@ -41,8 +52,6 @@ def main(): chapters_fn = args.chapters_fn dest_fn = args.dest_fn - indent_level_inc = 2 - out_f = open(dest_fn, 'w', encoding='utf-8') link_map = None @@ -57,10 +66,13 @@ def main(): with open(chapters_fn, encoding='utf-8') as chapters_f: chapters_tree = etree.parse(chapters_f) - for header_chapter in chapters_tree.getroot().findall(".//*[@name='Headers']/*"): + for header_chapter in \ + chapters_tree.getroot().findall(".//*[@name='Headers']/*"): out_f.write(' \n') - out_f.write(' %s\n' % header_chapter.attrib['name']) - out_f.write(' %s\n' % header_chapter.attrib['link']) + out_f.write(' {0}\n'.format( + header_chapter.attrib['name'])) + out_f.write(' {0}\n'.format( + header_chapter.attrib['link'])) out_f.write(' std\n') out_f.write(' \n') @@ -70,5 +82,6 @@ def main(): out_f.write(''' ''') + if __name__ == '__main__': main() diff --git a/index2highlight.py b/index2highlight.py index 1d3be6557..210cd335c 100755 --- a/index2highlight.py +++ b/index2highlight.py @@ -18,15 +18,19 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -from index_transform.highlight import * import argparse +from index_transform.highlight import Index2Highlight + def main(): parser = argparse.ArgumentParser(prog='index2highlight') - parser.add_argument('index', type=str, - help='Path to index file to process') - parser.add_argument('destination', type=str, - help='Path to destination file to store results to') + parser.add_argument( + 'index', type=str, + help='Path to index file to process') + + parser.add_argument( + 'destination', type=str, + help='Path to destination file to store results to') args = parser.parse_args() out_f = open(args.destination, 'w', encoding='utf-8') @@ -34,5 +38,6 @@ def main(): tr = Index2Highlight(out_f) tr.transform_file(args.index) + if __name__ == '__main__': main() diff --git a/index2search.py b/index2search.py index ec75c2abd..d4d6105f8 100755 --- a/index2search.py +++ b/index2search.py @@ -18,15 +18,19 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -from index_transform.search import * import argparse +from index_transform.search import Index2Search + def main(): parser = argparse.ArgumentParser(prog='index2highlight') - parser.add_argument('index', type=str, - help='Path to index file to process') - parser.add_argument('destination', type=str, - help='Path to destination file to store results to') + parser.add_argument( + 'index', type=str, + help='Path to index file to process') + + parser.add_argument( + 'destination', type=str, + help='Path to destination file to store results to') args = parser.parse_args() out_f = open(args.destination, 'w', encoding='utf-8') @@ -34,5 +38,6 @@ def main(): tr = Index2Search(out_f) tr.transform_file(args.index) + if __name__ == '__main__': main() diff --git a/index_transform/autolinker.py b/index_transform/autolinker.py index 6f9a07a75..ad68c0953 100644 --- a/index_transform/autolinker.py +++ b/index_transform/autolinker.py @@ -20,10 +20,12 @@ from index_transform.common import IndexTransform + def get_rel_name(full_name): pos = full_name.rfind("::") return full_name[pos+2:] + def is_group(el): curr_el = el while True: @@ -33,18 +35,16 @@ def is_group(el): if curr_el.tag == 'index': return True + def needs_entry_in_group(el): - if el.tag == 'const': return True - if el.tag == 'function': return True - if el.tag == 'class': return True - if el.tag == 'enum': return True - if el.tag == 'variable': return True - return False + tags = ['const', 'function', 'class', 'enum', 'variable'] + return el.tag in tags + class Index2AutolinkerGroups(IndexTransform): def __init__(self): - super(Index2AutolinkerGroups, self).__init__(ignore_typedefs = True) + super().__init__(ignore_typedefs=True) self.groups = {} self.curr_group = None @@ -53,9 +53,9 @@ def process_item_hook(self, el, full_name, full_link): saved_group = self.curr_group self.groups[full_name] = { - 'name' : full_name, - 'base_url' : full_link, - 'urls' : [''] + 'name': full_name, + 'base_url': full_link, + 'urls': [''] } self.curr_group = full_name IndexTransform.process_item_hook(self, el, full_name, full_link) @@ -67,10 +67,11 @@ def process_item_hook(self, el, full_name, full_link): base_url = self.groups[self.curr_group]['base_url'] if full_link.find(base_url) == 0: rel_link = full_link[len(base_url):] - if not rel_link in self.groups[self.curr_group]['urls']: + if rel_link not in self.groups[self.curr_group]['urls']: self.groups[self.curr_group]['urls'].append(rel_link) # else: an error has occurred somewhere - ignore + class Index2AutolinkerLinks(IndexTransform): def __init__(self): @@ -79,7 +80,7 @@ def __init__(self): self.curr_group = None def process_item_hook(self, el, full_name, full_link): - self.links.append({ 'string' : full_name, 'target' : full_link }) + self.links.append({'string': full_name, 'target': full_link}) if is_group(el): saved_group = self.curr_group @@ -89,9 +90,11 @@ def process_item_hook(self, el, full_name, full_link): else: IndexTransform.process_item_hook(self, el, full_name, full_link) - if is_group(el.getparent()) and self.curr_group and needs_entry_in_group(el): + if is_group(el.getparent()) and self.curr_group and \ + needs_entry_in_group(el): - self.links.append({ 'string' : get_rel_name(full_name), - 'target' : full_link, - 'on_group' : self.curr_group - }) + self.links.append({ + 'string': get_rel_name(full_name), + 'target': full_link, + 'on_group': self.curr_group + }) diff --git a/index_transform/browser.py b/index_transform/browser.py index d2e625cb1..fb8b976c0 100644 --- a/index_transform/browser.py +++ b/index_transform/browser.py @@ -21,6 +21,7 @@ from index_transform.common import IndexTransform from xml_utils import xml_escape + class Index2Browser(IndexTransform): def __init__(self, out_file): @@ -28,25 +29,35 @@ def __init__(self, out_file): self.out_file = out_file def output_item(self, el, full_name, full_link): + tag_to_mark = { + 'const': '(const)', + 'function': '(function)', + 'constructor': '(function)', + 'destructor': '(function)', + 'class': '(class)', + 'enum': '(enum)', + 'variable': '(variable)', + 'typedef': '(typedef)', + 'specialization': '(class)', + 'overload': '(function)', + } mark = '' - if el.tag == 'const': mark = '(const)' - elif el.tag == 'function': mark = '(function)' - elif el.tag == 'constructor': mark = '(function)' - elif el.tag == 'destructor': mark = '(function)' - elif el.tag == 'class': mark = '(class)' - elif el.tag == 'enum': mark = '(enum)' - elif el.tag == 'variable': mark = '(variable)' - elif el.tag == 'typedef': mark = '(typedef)' - elif el.tag == 'specialization': mark = '(class)' - elif el.tag == 'overload': mark = '(function)' + if el.tag in tag_to_mark: + mark = tag_to_mark[el.tag] res = u'' - res += '' + xml_escape(full_name) + ' [' - res += '' - res += full_link + '] ' + mark + '\n' + res += '{0} ['.format( + xml_escape(full_name)) + res += ''.format( + xml_escape(full_link)) + res += '{0}] {1}\n'.format( + full_link, mark) + return res def process_item_hook(self, el, full_name, full_link): - self.out_file.write('
  • ' + self.output_item(el, full_name, full_link) + '
      ') + self.out_file.write('
    • ' + + self.output_item(el, full_name, full_link) + + '
        ') IndexTransform.process_item_hook(self, el, full_name, full_link) self.out_file.write('
    • \n') diff --git a/index_transform/common.py b/index_transform/common.py index 127434c36..2d163ce28 100755 --- a/index_transform/common.py +++ b/index_transform/common.py @@ -18,6 +18,9 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' +import lxml.etree as e + + ''' This is a python script for various transformations of the index. @@ -30,8 +33,6 @@ children. By default just processes the children. ''' -import lxml.etree as e -import re class IndexTransform: @@ -49,18 +50,18 @@ def get_attr(self, el, attr): nm_str = '( name: ' + nm + ' )' else: nm_str = '' - raise Exception('Element \'' + el.tag + '\' does not have attribute \'' + - attr + '\' ' + nm_str) + msg = 'Element \'{0}\' does not have attribute \'{1}\' {2}'.format( + el.tag, attr, nm_str) + raise Exception(msg) return str(a) - """ Returns the relative link of 'el' to its parent, if any - """ - def get_link(self, el, default = None): + # Returns the relative link of 'el' to its parent, if any + def get_link(self, el, default=None): if not default: default = self.get_name(el) link = el.get('link') - if link == None: + if link is None: return default if link == '.': return '' @@ -81,19 +82,19 @@ def get_full_link(self, el, parent_link): alias_name = el.get('alias') if alias_name: return self.get_link(self.get_alias(el, alias_name)) - else: - return self.link_append(el, self.get_link(el), parent_link) + return self.link_append(el, self.get_link(el), parent_link) - elif el.tag == 'constructor': + if el.tag == 'constructor': d_link = parent_link.split('/')[-1] - return self.link_append(el, self.get_link(el, default=d_link), parent_link) + return self.link_append(el, self.get_link(el, default=d_link), + parent_link) - elif el.tag == 'destructor': + if el.tag == 'destructor': d_link = '~' + parent_link.split('/')[-1] - return self.link_append(el, self.get_link(el, default=d_link), parent_link) + return self.link_append(el, self.get_link(el, default=d_link), + parent_link) - else: - return self.link_append(el, self.get_link(el), parent_link) + return self.link_append(el, self.get_link(el), parent_link) """ Returns the name of el """ def get_name(self, el): @@ -109,23 +110,23 @@ def get_full_name(self, el, parent_name): return parent_name + '::' + parent_name.split('::')[-1] if el.tag == 'destructor': return parent_name + '::~' + parent_name.split('::')[-1] - elif el.tag == 'specialization': + if el.tag == 'specialization': return self.get_name(el) + '<' + parent_name + '>' - elif el.tag == 'overload': + if el.tag == 'overload': return self.get_name(el) + '(' + parent_name + ')' - else: - name = '' - if parent_name: - name += parent_name + '::' - name += self.get_name(el) - return name + + name = '' + if parent_name: + name += parent_name + '::' + name += self.get_name(el) + return name """ Returns the element within the document that has a name that matches 'name' """ def get_alias(self, el, name): aliases = el.xpath('/index/class[@name = \'' + name + '\'] |' + - '/index/enum[@name = \'' + name + '\']') + '/index/enum[@name = \'' + name + '\']') if len(aliases) == 0: raise Exception('No aliases found for \'' + name + '\'') if len(aliases) > 1: @@ -134,15 +135,18 @@ def get_alias(self, el, name): """ Processes one item """ def process_item(self, el, parent_name, parent_link): - if el.tag in ['const','function','class','enum','variable','typedef', - 'constructor','destructor','specialization','overload']: + if el.tag in ['const', 'function', 'class', 'enum', 'variable', + 'typedef', 'constructor', 'destructor', 'specialization', + 'overload']: full_name = self.get_full_name(el, parent_name) full_link = self.get_full_link(el, parent_link) self.process_item_hook(el, full_name, full_link) - elif el.tag == 'inherits' and el.getparent().xpath('child::inherits')[0] == el: + elif el.tag == 'inherits' and \ + el.getparent().xpath('child::inherits')[0] == el: + if self.ignore_inherits: return pending = el.getparent().xpath('child::inherits') @@ -179,19 +183,23 @@ def inherits_worker(self, parent_name, pending, finished): # find the source class/enum source = self.get_alias(current, self.get_attr(current, 'name')) - if not source in finished: + if source not in finished: finished.append(source) parent_link = self.get_attr(source, 'link') for source_ch in source: - ignore_tags = ['constructor', 'destructor', 'inherits', 'specialization', 'overload'] - if source_ch.tag in ignore_tags: pass - elif source_ch.tag == 'function' and source_ch.get('name') == 'operator=': pass + ignore_tags = ['constructor', 'destructor', 'inherits', + 'specialization', 'overload'] + if source_ch.tag in ignore_tags: + pass + elif source_ch.tag == 'function' and \ + source_ch.get('name') == 'operator=': + pass else: self.process_item(source_ch, parent_name, parent_link) # append new elements more_pending = source.xpath('child::inherits') - more_pending = [p for p in more_pending if not p is current] + more_pending = [p for p in more_pending if p is not current] pending.extend(more_pending) self.inherits_worker(parent_name, pending, finished) diff --git a/index_transform/devhelp.py b/index_transform/devhelp.py index 61d7b878f..ad1546fbd 100644 --- a/index_transform/devhelp.py +++ b/index_transform/devhelp.py @@ -18,11 +18,9 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -from index_transform.common import IndexTransform -from xml_utils import xml_escape -from index_transform import * from lxml import etree -import io +from index_transform.common import IndexTransform + class Index2Devhelp(IndexTransform): @@ -31,17 +29,23 @@ def __init__(self, functions_el): self.functions_el = functions_el def get_mark(self, el): - if el.tag == 'const': return 'macro' - elif el.tag == 'function': return 'function' - elif el.tag == 'constructor': return 'function' - elif el.tag == 'destructor': return 'function' - elif el.tag == 'class': return 'class' - elif el.tag == 'enum': return 'enum' - elif el.tag == 'typedef': return 'typedef' - elif el.tag == 'specialization': return 'class' - elif el.tag == 'overload': return 'function' - # devhelp does not support variables in its format - elif el.tag == 'variable': return '' + tag_to_mark = { + 'const': 'macro', + 'function': 'function', + 'constructor': 'function', + 'destructor': 'function', + 'class': 'class', + 'enum': 'enum', + 'typedef': 'typedef', + 'specialization': 'class', + 'overload': 'function', + # devhelp does not support variables in its format + 'variable': '' + } + + if el.tag in tag_to_mark: + return tag_to_mark[el.tag] + return '' def process_item_hook(self, el, full_name, full_link): @@ -52,8 +56,9 @@ def process_item_hook(self, el, full_name, full_link): IndexTransform.process_item_hook(self, el, full_name, full_link) + def transform_devhelp(book_title, book_name, book_base, rel_link, chapters_fn, - in_fn): + in_fn): root_el = etree.Element('book') root_el.set('xmlns', 'http://www.devhelp.net/book') root_el.set('title', book_title) diff --git a/index_transform/devhelp_qch.py b/index_transform/devhelp_qch.py index 2aa654702..76653721c 100644 --- a/index_transform/devhelp_qch.py +++ b/index_transform/devhelp_qch.py @@ -20,6 +20,7 @@ from lxml import etree + def convert_toc_lines(source_line, in_section): for el_sub in source_line.getchildren(): el_section_1 = etree.SubElement(in_section, 'section') @@ -31,6 +32,7 @@ def convert_toc_lines(source_line, in_section): return in_section + def convert_toc(in_root): el_toc = etree.Element('toc') el_section = etree.SubElement(el_toc, 'section') @@ -44,6 +46,7 @@ def convert_toc(in_root): convert_toc_lines(chapters_el, el_section) return el_toc + def convert_keywords(in_root_k): el_keywords = etree.Element('keywords') @@ -75,6 +78,7 @@ def convert_keywords(in_root_k): return el_keywords + # Adds files list from external library def add_files_list(files_root_f): el_files = etree.Element('files') @@ -83,6 +87,7 @@ def add_files_list(files_root_f): el_file.text = file_item.text return el_files + def convert_devhelp_to_qch(in_root, files_root, virtual_folder): out_root = etree.Element('QtHelpProject') out_root.set('version', "1.0") diff --git a/index_transform/doxygen_tag.py b/index_transform/doxygen_tag.py index 0a5a237a7..963f55112 100644 --- a/index_transform/doxygen_tag.py +++ b/index_transform/doxygen_tag.py @@ -18,17 +18,19 @@ along with this program. If not, see http://www.gnu.org/licenses/. ''' -from index_transform.common import IndexTransform from functools import total_ordering +from index_transform.common import IndexTransform from xml_utils import xml_escape + class ItemKind: - VARIABLE = 0, - FUNCTION = 1, - CLASS = 2, - TYPEDEF = 3, + VARIABLE = 0 + FUNCTION = 1 + CLASS = 2 + TYPEDEF = 3 NAMESPACE = 4 + @total_ordering class Item: @@ -45,17 +47,18 @@ def __eq__(self, other): def __lt__(self, other): return self.full_name < other.full_name + def add_to_map(ns_map, full_name, full_link, item_kind): names = full_name.split('::') parsed_names = [] - last_name = names.pop() # i.e. unqualified name + last_name = names.pop() # i.e. unqualified name curr_item = ns_map for name in names: parsed_names.append(name) if name in curr_item.members: curr_item = curr_item.members[name] - if curr_item.kind not in [ ItemKind.CLASS, ItemKind.NAMESPACE ]: + if curr_item.kind not in [ItemKind.CLASS, ItemKind.NAMESPACE]: print("ERROR: " + name + " in " + full_name + " is not a class or namespace") return @@ -73,8 +76,10 @@ def add_to_map(ns_map, full_name, full_link, item_kind): if last_name in curr_item.members: curr_item = curr_item.members[last_name] if (item_kind == ItemKind.CLASS and - curr_item.kind in [ ItemKind.CLASS, ItemKind.NAMESPACE ]): - curr_item.kind = item_kind # fix namespaces that are actually classes + curr_item.kind in [ItemKind.CLASS, ItemKind.NAMESPACE]): + + # fix namespaces that are actually classes + curr_item.kind = item_kind curr_item.link = full_link else: print("ERROR: Duplicate element: " + full_name) @@ -88,81 +93,97 @@ def add_to_map(ns_map, full_name, full_link, item_kind): curr_item = new_item return + def print_members(out_f, link_map, curr_item): for item in sorted(curr_item.members.values()): if link_map: link = link_map.get_dest(item.link) - if link == None and item.kind != ItemKind.NAMESPACE: + if link is None and item.kind != ItemKind.NAMESPACE: print("WARN: " + item.full_name + " contains invalid link") link = '404' else: link = item.link if item.kind == ItemKind.VARIABLE: - out_f.write(' \n' + - ' T\n' + - ' ' + xml_escape(item.name) + '\n' + - ' ' + xml_escape(link) + '\n' + - ' \n' + - ' \n' + - ' \n') + out_f.write( + ' \n' + + ' T\n' + + ' ' + xml_escape(item.name) + '\n' + + ' ' + xml_escape(link) + '\n' + + ' \n' + + ' \n' + + ' \n') elif item.kind == ItemKind.FUNCTION: - out_f.write(' \n' + - ' T\n' + - ' ' + xml_escape(item.name) + '\n' + - ' ' + xml_escape(link) + '\n' + - ' \n' + - ' (T... args)\n' + - ' \n') + out_f.write( + ' \n' + + ' T\n' + + ' ' + xml_escape(item.name) + '\n' + + ' ' + xml_escape(link) + '\n' + + ' \n' + + ' (T... args)\n' + + ' \n') elif item.kind == ItemKind.CLASS: - out_f.write(' ' + xml_escape(item.full_name) + '\n') + out_f.write( + ' ' + xml_escape(item.full_name) + + '\n') elif item.kind == ItemKind.NAMESPACE: - out_f.write(' ' + xml_escape(item.full_name) + '\n') + out_f.write( + ' ' + xml_escape(item.full_name) + + '\n') + def print_map_item(out_f, link_map, curr_item): - item_kind_to_attr = { ItemKind.NAMESPACE : 'namespace', - ItemKind.CLASS : 'class' } + item_kind_to_attr = {ItemKind.NAMESPACE: 'namespace', + ItemKind.CLASS: 'class'} if curr_item.kind not in item_kind_to_attr: print('ERROR: only namespaces and classes can have members') return - out_f.write(' \n' + - ' ' + xml_escape(curr_item.full_name) + '\n' + - ' ' + xml_escape(curr_item.link) + '\n') + out_f.write( + ' \n' + + ' ' + xml_escape(curr_item.full_name) + '\n' + + ' ' + xml_escape(curr_item.link) + '\n') print_members(out_f, link_map, curr_item) out_f.write(' \n') for item in sorted(curr_item.members.values()): - if item.kind in [ ItemKind.NAMESPACE, ItemKind.CLASS ]: + if item.kind in [ItemKind.NAMESPACE, ItemKind.CLASS]: print_map_item(out_f, link_map, item) + def print_map(out_f, link_map, ns_map): for item in sorted(ns_map.members.values()): - if item.kind in [ ItemKind.NAMESPACE, ItemKind.CLASS ]: + if item.kind in [ItemKind.NAMESPACE, ItemKind.CLASS]: print_map_item(out_f, link_map, item) else: print("WARN: " + item.full_name + " ignored") + class Index2DoxygenTag(IndexTransform): def __init__(self, ns_map): super().__init__() self.ns_map = ns_map def get_item_kind(self, el): - if el.tag == 'const': return None - elif el.tag == 'function': return ItemKind.FUNCTION - elif el.tag == 'constructor': return ItemKind.FUNCTION - elif el.tag == 'destructor': return ItemKind.FUNCTION - elif el.tag == 'class': return ItemKind.CLASS - elif el.tag == 'enum': return 'enum' - elif el.tag == 'typedef': return ItemKind.CLASS - elif el.tag == 'specialization': return None - elif el.tag == 'overload': return None - elif el.tag == 'variable': return ItemKind.VARIABLE + tag_to_kind = { + 'const': None, + 'function': ItemKind.FUNCTION, + 'constructor': ItemKind.FUNCTION, + 'destructor': ItemKind.FUNCTION, + 'class': ItemKind.CLASS, + 'enum': 'enum', + 'typedef': ItemKind.CLASS, + 'specialization': None, + 'overload': None, + 'variable': ItemKind.VARIABLE, + } + + if el.tag in tag_to_kind: + return tag_to_kind[el.tag] return None def process_item_hook(self, el, full_name, full_link): item_kind = self.get_item_kind(el) - if item_kind != None: + if item_kind is not None: add_to_map(self.ns_map, full_name, full_link, item_kind) IndexTransform.process_item_hook(self, el, full_name, full_link) diff --git a/index_transform/highlight.py b/index_transform/highlight.py index 5c8176b6f..289f8e6ce 100644 --- a/index_transform/highlight.py +++ b/index_transform/highlight.py @@ -20,6 +20,7 @@ from index_transform.common import IndexTransform + class Index2Highlight(IndexTransform): def __init__(self, out_file): super().__init__() @@ -28,23 +29,31 @@ def __init__(self, out_file): def check_is_member(self, el): if el.getparent().tag == 'index': return False - if el.tag == 'function': return True - elif el.tag == 'variable': return True - elif el.tag == 'constructor': return True - elif el.tag == 'destructor': return True + if el.tag == 'function': + return True + if el.tag == 'variable': + return True + if el.tag == 'constructor': + return True + if el.tag == 'destructor': + return True return False def process_item_hook(self, el, full_name, full_link): - is_member = False - if self.check_is_member(el): pass - elif '<' in full_name: pass - elif '>' in full_name: pass - elif '(' in full_name: pass - elif ')' in full_name: pass + if self.check_is_member(el): + pass + elif '<' in full_name: + pass + elif '>' in full_name: + pass + elif '(' in full_name: + pass + elif ')' in full_name: + pass else: self.out_file.write(full_name + ' => ' + full_link + '\n') IndexTransform.process_item_hook(self, el, full_name, full_link) def inherits_worker(self, parent_name, pending, finished=list()): - pass # do not walk the inheritance hierarchy + pass # do not walk the inheritance hierarchy diff --git a/index_transform/search.py b/index_transform/search.py index 9be63fc33..a629c2ca6 100644 --- a/index_transform/search.py +++ b/index_transform/search.py @@ -20,6 +20,7 @@ from index_transform.common import IndexTransform + class Index2Search(IndexTransform): def __init__(self, out_file): super().__init__() @@ -29,4 +30,3 @@ def process_item_hook(self, el, full_name, full_link): self.out_file.write(full_name + ' => ' + full_link + '\n') IndexTransform.process_item_hook(self, el, full_name, full_link) - diff --git a/link_map.py b/link_map.py index 156ffbafb..64f2631aa 100644 --- a/link_map.py +++ b/link_map.py @@ -20,6 +20,7 @@ import lxml.etree as e + class LinkMap: def __init__(self): self.mapping = dict() diff --git a/preprocess.py b/preprocess.py index fc9b126ca..851785b71 100755 --- a/preprocess.py +++ b/preprocess.py @@ -23,10 +23,16 @@ import os import shutil + def main(): parser = argparse.ArgumentParser(prog='preprocess.py') - parser.add_argument('--src', type=str, help='Source directory where raw website copy resides') - parser.add_argument('--dst', type=str, help='Destination folder to put preprocessed archive to') + parser.add_argument( + '--src', type=str, + help='Source directory where raw website copy resides') + + parser.add_argument( + '--dst', type=str, + help='Destination folder to put preprocessed archive to') args = parser.parse_args() root = args.dst @@ -61,11 +67,13 @@ def main(): # clean the css files - for fn in [ os.path.join(root, 'common/site_modules.css'), - os.path.join(root, 'common/ext.css') ]: + for fn in [os.path.join(root, 'common/site_modules.css'), + os.path.join(root, 'common/ext.css')]: preprocess.preprocess_css_file(fn) - preprocess.preprocess_startup_script(os.path.join(root, 'common/startup_scripts.js')) + preprocess.preprocess_startup_script( + os.path.join(root, 'common/startup_scripts.js')) + if __name__ == "__main__": main() diff --git a/preprocess_qch.py b/preprocess_qch.py index 606c330f3..6b7302550 100755 --- a/preprocess_qch.py +++ b/preprocess_qch.py @@ -17,20 +17,26 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. -from commands import preprocess_cssless import argparse import concurrent.futures import os import shutil +from commands import preprocess_cssless + def main(): parser = argparse.ArgumentParser(prog='preprocess_qch.py') - parser.add_argument('--src', required=True, type=str, - help='Source directory where raw website copy resides') - parser.add_argument('--dst', required=True, type=str, - help='Destination folder to put preprocessed archive to') - parser.add_argument('--verbose', action='store_true', default=False, - help='If set, verbose output is produced') + parser.add_argument( + '--src', required=True, type=str, + help='Source directory where raw website copy resides') + + parser.add_argument( + '--dst', required=True, type=str, + help='Destination folder to put preprocessed archive to') + + parser.add_argument( + '--verbose', action='store_true', default=False, + help='If set, verbose output is produced') args = parser.parse_args() source_root = args.src @@ -51,14 +57,20 @@ def main(): paths_list.append(tuple) with concurrent.futures.ProcessPoolExecutor() as executor: - futures = [ (executor.submit(preprocess_cssless.preprocess_html_merge_cssless, src_path, dst_path), i) - for i, (src_path, dst_path) in enumerate(paths_list) ] + futures = [ + (executor.submit(preprocess_cssless.preprocess_html_merge_cssless, + src_path, dst_path), + i) + for i, (src_path, dst_path) in enumerate(paths_list) + ] for future, i in futures: - print('Processing file: {}/{}: {}'.format(i, len(paths_list), paths_list[i][1])) + print('Processing file: {}/{}: {}'.format(i, len(paths_list), + paths_list[i][1])) output = future.result() if verbose: print(output) + if __name__ == "__main__": main() diff --git a/tests/test_devhelp.py b/tests/test_devhelp.py index 56392e373..365d626a0 100644 --- a/tests/test_devhelp.py +++ b/tests/test_devhelp.py @@ -16,15 +16,19 @@ # along with this program. If not, see http://www.gnu.org/licenses/. import os -from index_transform.devhelp import * #pylint: disable=unused-wildcard-import import unittest +from index_transform.devhelp import transform_devhelp + class TestTransformDevhelp(unittest.TestCase): def test_transform_devhelp(self): dir_path = os.path.dirname(__file__) - chapters_fn = os.path.join(dir_path, 'transform_data/index-chapters-cpp.xml') - functions_fn = os.path.join(dir_path, 'transform_data/index-functions-cpp.xml') - expected_path = os.path.join(dir_path, 'devhelp_data/expected.xml') + chapters_fn = os.path.join( + dir_path, 'transform_data/index-chapters-cpp.xml') + functions_fn = os.path.join( + dir_path, 'transform_data/index-functions-cpp.xml') + expected_path = os.path.join( + dir_path, 'devhelp_data/expected.xml') dest_path = os.path.join(dir_path, 'devhelp_data/result.xml') with open(expected_path, 'rb') as expected_f: diff --git a/tests/test_devhelp_qch.py b/tests/test_devhelp_qch.py index 98aea423d..4416f12cd 100644 --- a/tests/test_devhelp_qch.py +++ b/tests/test_devhelp_qch.py @@ -15,10 +15,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. -from lxml import etree import os import unittest -from index_transform.devhelp_qch import * #pylint: disable=unused-wildcard-import +from lxml import etree +from index_transform.devhelp_qch import convert_devhelp_to_qch + class TestConvertDevhelpToQch(unittest.TestCase): def test_convert_devhelp_to_qch(self): diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index d4616aaec..c9d02e8ef 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -18,17 +18,33 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. -from commands.preprocess import * #pylint: disable=unused-wildcard-import import io import os import sys import contextlib import unittest import unittest.mock +from commands.preprocess import build_rename_map +from commands.preprocess import convert_loader_name +from commands.preprocess import has_class +from commands.preprocess import is_external_link +from commands.preprocess import is_ranges_placeholder +from commands.preprocess import remove_noprint +from commands.preprocess import remove_see_also +from commands.preprocess import remove_google_analytics +from commands.preprocess import remove_ads +from commands.preprocess import remove_fileinfo +from commands.preprocess import remove_unused_external +from commands.preprocess import transform_ranges_placeholder +from commands.preprocess import trasform_relative_link +from commands.preprocess import rename_files from lxml import etree + class DummyFile(object): - def write(self, x): pass + def write(self, x): + pass + # From https://stackoverflow.com/a/2829036/1849769 @contextlib.contextmanager @@ -38,26 +54,28 @@ def nostdout(): yield sys.stdout = save_stdout + class TestConvertLoaderName(unittest.TestCase): def test_convert_loader_name(self): - url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=site&only=scripts&skin=cppreference2&*' + url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=site&only=scripts&skin=cppreference2&*' # noqa self.assertEqual('site_scripts.js', convert_loader_name(url)) - url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=site&only=styles&skin=cppreference2&*' + url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=site&only=styles&skin=cppreference2&*' # noqa self.assertEqual('site_modules.css', convert_loader_name(url)) - url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=skins.cppreference2&only=scripts&skin=cppreference2&*' + url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=skins.cppreference2&only=scripts&skin=cppreference2&*' # noqa self.assertEqual('skin_scripts.js', convert_loader_name(url)) - url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=startup&only=scripts&skin=cppreference2&*' + url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=startup&only=scripts&skin=cppreference2&*' # noqa self.assertEqual('startup_scripts.js', convert_loader_name(url)) - url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=ext.gadget.ColiruCompiler%2CMathJax%7Cext.rtlcite%7Cmediawiki.legacy.commonPrint%2Cshared%7Cskins.cppreference2&only=styles&skin=cppreference2&*' + url = 'http://en.cppreference.com/mwiki/load.php?debug=false&lang=en&modules=ext.gadget.ColiruCompiler%2CMathJax%7Cext.rtlcite%7Cmediawiki.legacy.commonPrint%2Cshared%7Cskins.cppreference2&only=styles&skin=cppreference2&*' # noqa self.assertEqual('ext.css', convert_loader_name(url)) with self.assertRaises(Exception): convert_loader_name('') + class TestHasClass(unittest.TestCase): def test_has_class(self): el = etree.Element('tag') @@ -102,6 +120,7 @@ def test_has_class(self): self.assertEqual(True, has_class(el, 'b', 'a')) self.assertEqual(True, has_class(el, 'b', 'c')) + class TestIsExternalLink(unittest.TestCase): def test_is_external_link(self): external = [ @@ -110,12 +129,13 @@ def test_is_external_link(self): 'ftp://example.com', 'ftps://example.com', 'slack://example.com', - 'https:///foo.html', # Not technically external, but we say so anyway + 'https:///foo.html', # Not technically external, + # but we say so anyway '//example.com' ] for link in external: self.assertTrue(is_external_link(link), - msg="Should be external: {}".format(link)) + msg="Should be external: {}".format(link)) relative = [ '/example.com', @@ -125,7 +145,8 @@ def test_is_external_link(self): ] for link in relative: self.assertFalse(is_external_link(link), - msg="Should not be external: {}".format(link)) + msg="Should not be external: {}".format(link)) + class TestPlaceholderLinks(unittest.TestCase): # Placeholder link replacement is implemented in the MediaWiki site JS at @@ -133,19 +154,19 @@ class TestPlaceholderLinks(unittest.TestCase): def test_is_ranges_placeholder(self): match = [ - 'http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', - 'http://en.cppreference.com/w/cpp/ranges-placeholder/iterator/Incrementable', - 'http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/all_any_none_of', - 'http://en.cppreference.com/w/cpp/ranges-iterator-placeholder/dangling', - 'http://en.cppreference.com/w/cpp/ranges-utility-placeholder/swap', + 'http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', # noqa + 'http://en.cppreference.com/w/cpp/ranges-placeholder/iterator/Incrementable', # noqa + 'http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/all_any_none_of', # noqa + 'http://en.cppreference.com/w/cpp/ranges-iterator-placeholder/dangling', # noqa + 'http://en.cppreference.com/w/cpp/ranges-utility-placeholder/swap', # noqa ] for target in match: self.assertTrue(is_ranges_placeholder(target), - msg="Should match '{}'".format(target)) + msg="Should match '{}'".format(target)) target = target.replace("http://", "https://") self.assertTrue(is_ranges_placeholder(target), - msg="Should match '{}'".format(target)) + msg="Should match '{}'".format(target)) nomatch = [ 'http://en.cppreference.com/w/cpp/ranges--placeholder/swap', @@ -164,48 +185,48 @@ def test_is_ranges_placeholder(self): ] for target in nomatch: self.assertFalse(is_ranges_placeholder(target), - msg="Should not match '{}'".format(target)) + msg="Should not match '{}'".format(target)) def test_transform_ranges_placeholder(self): entries = [ # (target, file, expected) - ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', + ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', # noqa 'output/reference/en/cpp/concepts/ConvertibleTo.html', 'Assignable.html'), - ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', + ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', # noqa 'output/reference/en/cpp/concepts/long/path/ConvertibleTo.html', '../../Assignable.html'), - ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', + ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', # noqa 'output/reference/en/cpp/other/path/ConvertibleTo.html', '../../concepts/Assignable.html'), - ('http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/all_any_none_of', + ('http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/all_any_none_of', # noqa 'output/reference/en/cpp/concepts/ConvertibleTo.html', '../algorithm/ranges/all_any_none_of.html'), - ('http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/all_any_none_of', + ('http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/all_any_none_of', # noqa 'output/reference/en/cpp/algorithm/ConvertibleTo.html', 'ranges/all_any_none_of.html'), - ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', + ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', # noqa 'output/reference/en/cpp/experimental/ranges/concepts/View.html', 'Assignable.html'), - ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', + ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', # noqa 'output/reference/en/cpp/experimental/ranges/View.html', 'concepts/Assignable.html'), - ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', + ('http://en.cppreference.com/w/cpp/ranges-placeholder/concepts/Assignable', # noqa 'output/reference/en/cpp/experimental/ranges/range/View.html', '../concepts/Assignable.html'), - ('http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/all_any_none_of', + ('http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/all_any_none_of', # noqa 'output/reference/en/cpp/experimental/ranges/View.html', 'algorithm/all_any_none_of.html'), - ('http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/all_any_none_of', + ('http://en.cppreference.com/w/cpp/ranges-algorithm-placeholder/all_any_none_of', # noqa 'output/reference/en/cpp/experimental/ranges/range/View.html', '../algorithm/all_any_none_of.html'), ] @@ -216,21 +237,28 @@ def test_transform_ranges_placeholder(self): # root: path to the site root (where '/' should link to) root = "output/reference" for target, file, expected in entries: - self.assertEqual(expected, transform_ranges_placeholder(target, file, root), - msg="target='{}', file='{}', root='{}'".format(target, file, root)) + res = transform_ranges_placeholder(target, file, root) + self.assertEqual(expected, res, + msg="target='{}', file='{}', root='{}'".format( + target, file, root)) target = target.replace('http://', 'https://') - self.assertEqual(expected, transform_ranges_placeholder(target, file, root), - msg="target='{}', file='{}', root='{}'".format(target, file, root)) + res = transform_ranges_placeholder(target, file, root) + self.assertEqual(expected, res, + msg="target='{}', file='{}', root='{}'".format( + target, file, root)) + class TestPreprocessHtml(unittest.TestCase): def setUp(self): - self.testdata = os.path.join(os.path.dirname(__file__), 'preprocess_data') + self.testdata = os.path.join(os.path.dirname(__file__), + 'preprocess_data') infile = os.path.join(self.testdata, "fabs.html") self.parser = etree.HTMLParser() self.html = etree.parse(infile, self.parser) - # Check whether the HTML matches the contents of the specified test data file + # Check whether the HTML matches the contents of the specified test data + # file def check_output(self, expected_file): with open(os.path.join(self.testdata, expected_file), 'rb') as f: expected = f.read() @@ -264,6 +292,7 @@ def test_remove_unused_external(self): remove_unused_external(self.html) self.check_output("fabs_external.html") + class TestFileRename(unittest.TestCase): def make_rename_map(self, root): def p(*dirs): @@ -284,21 +313,43 @@ def p(*dirs): def make_walk_result(self, root): def p(*dirs): return os.path.join(root, 'dir1', *dirs) + return [ # Nothing to do - (p(), ('sub1', 'sub2', 'sub3', 'sub4', 'sub5', 'sub6'), ('f1', 'f2')), + (p(), + ('sub1', 'sub2', 'sub3', 'sub4', 'sub5', 'sub6'), + ('f1', 'f2')), + # Unwanted characters - (p('sub1'), (), ('invalid*.txt', 'valid.txt')), + (p('sub1'), + (), + ('invalid*.txt', 'valid.txt')), + # Case conflict - (p('sub2'), (), ('conflict.html', 'Conflict.html')), + (p('sub2'), + (), + ('conflict.html', 'Conflict.html')), + # Unwanted characters + case conflict - (p('sub3'), (), ('confl"ict".html', 'Confl"ict".html')), + (p('sub3'), + (), + ('confl"ict".html', 'Confl"ict".html')), + # Multiple case conflicts, no extension - (p('sub4'), (), ('conflict', 'Conflict', 'conFlict')), + (p('sub4'), + (), + ('conflict', 'Conflict', 'conFlict')), + # Case conflict in second directory - (p('sub5'), (), ('conflict', 'Conflict')), + (p('sub5'), + (), + ('conflict', 'Conflict')), + # Loader links - (p('sub6'), (), ('load.php?modules=site&only=scripts', 'load.php?modules=someext&only=styles')) + (p('sub6'), + (), + ('load.php?modules=site&only=scripts', + 'load.php?modules=someext&only=styles')) ] def test_build_rename_map(self): @@ -312,23 +363,33 @@ def test_build_rename_map(self): def test_rename_files(self): expected = [ - (('output/dir1/sub1/invalid*.txt', 'output/dir1/sub1/invalid_star_.txt'), {}), - (('output/dir1/sub2/Conflict.html', 'output/dir1/sub2/Conflict.2.html'), {}), - (('output/dir1/sub3/confl"ict".html', 'output/dir1/sub3/confl_q_ict_q_.html'), {}), - (('output/dir1/sub3/Confl"ict".html', 'output/dir1/sub3/Confl_q_ict_q_.2.html'), {}), - (('output/dir1/sub4/Conflict', 'output/dir1/sub4/Conflict.2'), {}), - (('output/dir1/sub4/conFlict', 'output/dir1/sub4/conFlict.3'), {}), - (('output/dir1/sub5/Conflict', 'output/dir1/sub5/Conflict.2'), {}), - (('output/dir1/sub6/load.php?modules=site&only=scripts', 'output/dir1/sub6/site_scripts.js'), {}), - (('output/dir1/sub6/load.php?modules=someext&only=styles', 'output/dir1/sub6/ext.css'), {}) + (('output/dir1/sub1/invalid*.txt', + 'output/dir1/sub1/invalid_star_.txt'), {}), + (('output/dir1/sub2/Conflict.html', + 'output/dir1/sub2/Conflict.2.html'), {}), + (('output/dir1/sub3/confl"ict".html', + 'output/dir1/sub3/confl_q_ict_q_.html'), {}), + (('output/dir1/sub3/Confl"ict".html', + 'output/dir1/sub3/Confl_q_ict_q_.2.html'), {}), + (('output/dir1/sub4/Conflict', + 'output/dir1/sub4/Conflict.2'), {}), + (('output/dir1/sub4/conFlict', + 'output/dir1/sub4/conFlict.3'), {}), + (('output/dir1/sub5/Conflict', + 'output/dir1/sub5/Conflict.2'), {}), + (('output/dir1/sub6/load.php?modules=site&only=scripts', + 'output/dir1/sub6/site_scripts.js'), {}), + (('output/dir1/sub6/load.php?modules=someext&only=styles', + 'output/dir1/sub6/ext.css'), {}) ] actual = [] + def record_call(*args, **kwargs): actual.append((args, kwargs)) with unittest.mock.patch('os.walk') as walk, \ - unittest.mock.patch('shutil.move') as move: + unittest.mock.patch('shutil.move') as move: walk.return_value = self.make_walk_result('output') move.side_effect = record_call @@ -336,7 +397,7 @@ def record_call(*args, **kwargs): rename_files('output', self.make_rename_map('output')) self.assertEqual(expected, actual, - msg="Unexpected sequence of calls to shutil.move") + msg="Unexpected sequence of calls to shutil.move") def test_transform_relative_link(self): entries = [ @@ -419,5 +480,6 @@ def test_transform_relative_link(self): # file: path of the file that contains the link rename_map = self.make_rename_map('output') for file, target, expected in entries: - self.assertEqual(expected, trasform_relative_link(rename_map, target, file), - msg="target='{}', file='{}'".format(target, file)) + self.assertEqual(expected, + trasform_relative_link(rename_map, target, file), + msg="target='{}', file='{}'".format(target, file)) diff --git a/tests/test_preprocess_cssless.py b/tests/test_preprocess_cssless.py index fc93019ff..0b9f58078 100644 --- a/tests/test_preprocess_cssless.py +++ b/tests/test_preprocess_cssless.py @@ -17,14 +17,27 @@ import os import unittest -from commands.preprocess_cssless import * #pylint: disable=unused-wildcard-import +from commands.preprocess_cssless import preprocess_html_merge_cssless +from commands.preprocess_cssless import silence_cssutils_warnings +from commands.preprocess_cssless import convert_span_tables_to_tr_td +from commands.preprocess_cssless import convert_inline_block_elements_to_table +from commands.preprocess_cssless import convert_zero_td_width_to_nonzero +from commands.preprocess_cssless import apply_font_size +from commands.preprocess_cssless import convert_font_size_property_to_pt +from commands.preprocess_cssless \ + import convert_table_border_top_to_tr_background +from lxml import etree + class TestPreprocessHtmlMergeCss(unittest.TestCase): def test_preprocess_html_merge_cssless(self): dir_path = os.path.dirname(__file__) - src_path = os.path.join(dir_path, 'preprocess_cssless_data/multiset.html') - dst_path = os.path.join(dir_path, 'preprocess_cssless_data/multiset_out.html') - expected_path = os.path.join(dir_path, 'preprocess_cssless_data/multiset_expected.html') + src_path = os.path.join( + dir_path, 'preprocess_cssless_data/multiset.html') + dst_path = os.path.join( + dir_path, 'preprocess_cssless_data/multiset_out.html') + expected_path = os.path.join( + dir_path, 'preprocess_cssless_data/multiset_expected.html') preprocess_html_merge_cssless(src_path, dst_path) @@ -39,9 +52,12 @@ def test_preprocess_html_merge_cssless(self): def test_preprocess_html_merge_cssless2(self): dir_path = os.path.dirname(__file__) - src_path = os.path.join(dir_path, 'preprocess_cssless_data/basic_string.html') - dst_path = os.path.join(dir_path, 'preprocess_cssless_data/basic_string_out.html') - expected_path = os.path.join(dir_path, 'preprocess_cssless_data/basic_string_expected.html') + src_path = os.path.join( + dir_path, 'preprocess_cssless_data/basic_string.html') + dst_path = os.path.join( + dir_path, 'preprocess_cssless_data/basic_string_out.html') + expected_path = os.path.join( + dir_path, 'preprocess_cssless_data/basic_string_expected.html') preprocess_html_merge_cssless(src_path, dst_path) @@ -54,6 +70,7 @@ def test_preprocess_html_merge_cssless2(self): self.assertEqual(test, expected) os.remove(dst_path) + class HTMLTestBase(unittest.TestCase): def setUp(self): self.maxDiff = None @@ -61,7 +78,8 @@ def setUp(self): def assert_converts_html(self, input, expected_output, function): input = '{0}'.format(input) - expected_output = '{0}'.format(expected_output) + expected_output = \ + '{0}'.format(expected_output) parser = etree.HTMLParser() root = etree.fromstring(input, parser) @@ -72,6 +90,7 @@ def assert_converts_html(self, input, expected_output, function): self.assertEqual(expected_output, output) + class TestConvertSpanTablesToTrTd(HTMLTestBase): def assert_processes_table(self, input, expected_output): def test_fun(root): @@ -92,7 +111,8 @@ def test_normal_table(self): -''' +''' # noqa + expected = '''\
      @@ -107,7 +127,6 @@ def test_normal_table(self): ''' self.assert_processes_table(input, expected) - def test_wraps_table_row_text(self): input = '''\
      @@ -322,6 +341,7 @@ def test_does_not_convert_td_when_parent_is_not_tr(self): ''' self.assert_processes_table(input, expected) + class TestConvertInlineBlockElementsToTable(HTMLTestBase): def perform_test(self, input, expected_output): def test_fun(root): @@ -350,9 +370,10 @@ def test_converts_multiple(self):
      -''' +''' # noqa self.perform_test(input, expected) + class TestConvertZeroTdWidthToNonzero(HTMLTestBase): def test_css_property(self): def test_fun(root): @@ -392,6 +413,7 @@ def test_fun(root): ''' self.assert_converts_html(input, expected, test_fun) + class TestApplyFontSize(unittest.TestCase): def test_em(self): self.assertEqual(10, apply_font_size('1em', 10)) @@ -421,6 +443,7 @@ def test_ptc(self): self.assertEqual(15, apply_font_size(' 150% ', 10)) self.assertEqual(15, apply_font_size('150% ', 10)) + class TestConvertFontSizePropertyToPt(HTMLTestBase): def test_simple(self): def test_fun(root): @@ -475,7 +498,6 @@ def test_fun(root): ''' self.assert_converts_html(input, expected, test_fun) - def test_simple_pt(self): def test_fun(root): convert_font_size_property_to_pt(root, 10) @@ -537,6 +559,7 @@ def test_fun(root):
      ''' self.assert_converts_html(input, expected, test_fun) + class TestConvertTableBorderTopToTrBackground(HTMLTestBase): def test_no_border(self): def test_fun(root): @@ -570,7 +593,7 @@ def test_fun(root): -''' +''' # noqa self.assert_converts_html(input, expected, test_fun) def test_multiple_td(self): @@ -595,7 +618,7 @@ def test_fun(root): -''' +''' # noqa self.assert_converts_html(input, expected, test_fun) def test_subtable_does_not_affect_parent_table(self): @@ -628,5 +651,5 @@ def test_fun(root): -''' +''' # noqa self.assert_converts_html(input, expected, test_fun) diff --git a/xml_utils.py b/xml_utils.py index 9af75fabd..51689fd8a 100644 --- a/xml_utils.py +++ b/xml_utils.py @@ -26,8 +26,10 @@ "<": "<", } + def xml_escape(text): - return "".join(xml_escape_table.get(c,c) for c in text) + return "".join(xml_escape_table.get(c, c) for c in text) + def xml_unescape(text): text = text.replace(""", '"') From ee6e929290a6ddd55aa0141ea5c6c426124310e3 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 24 Oct 2018 22:20:26 +0300 Subject: [PATCH 018/114] Gadgets/Stdrev: Move tests to a path that can be python module --- .../{standard_revisions-tests => standard_revisions_tests}/README | 0 .../base.py | 0 .../test.sh | 0 .../test_dcl.py | 0 .../test_dsc.py | 0 .../test_rev.py | 0 .../test_section_hierarchy.py | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename gadgets/{standard_revisions-tests => standard_revisions_tests}/README (100%) rename gadgets/{standard_revisions-tests => standard_revisions_tests}/base.py (100%) rename gadgets/{standard_revisions-tests => standard_revisions_tests}/test.sh (100%) rename gadgets/{standard_revisions-tests => standard_revisions_tests}/test_dcl.py (100%) rename gadgets/{standard_revisions-tests => standard_revisions_tests}/test_dsc.py (100%) rename gadgets/{standard_revisions-tests => standard_revisions_tests}/test_rev.py (100%) rename gadgets/{standard_revisions-tests => standard_revisions_tests}/test_section_hierarchy.py (100%) diff --git a/gadgets/standard_revisions-tests/README b/gadgets/standard_revisions_tests/README similarity index 100% rename from gadgets/standard_revisions-tests/README rename to gadgets/standard_revisions_tests/README diff --git a/gadgets/standard_revisions-tests/base.py b/gadgets/standard_revisions_tests/base.py similarity index 100% rename from gadgets/standard_revisions-tests/base.py rename to gadgets/standard_revisions_tests/base.py diff --git a/gadgets/standard_revisions-tests/test.sh b/gadgets/standard_revisions_tests/test.sh similarity index 100% rename from gadgets/standard_revisions-tests/test.sh rename to gadgets/standard_revisions_tests/test.sh diff --git a/gadgets/standard_revisions-tests/test_dcl.py b/gadgets/standard_revisions_tests/test_dcl.py similarity index 100% rename from gadgets/standard_revisions-tests/test_dcl.py rename to gadgets/standard_revisions_tests/test_dcl.py diff --git a/gadgets/standard_revisions-tests/test_dsc.py b/gadgets/standard_revisions_tests/test_dsc.py similarity index 100% rename from gadgets/standard_revisions-tests/test_dsc.py rename to gadgets/standard_revisions_tests/test_dsc.py diff --git a/gadgets/standard_revisions-tests/test_rev.py b/gadgets/standard_revisions_tests/test_rev.py similarity index 100% rename from gadgets/standard_revisions-tests/test_rev.py rename to gadgets/standard_revisions_tests/test_rev.py diff --git a/gadgets/standard_revisions-tests/test_section_hierarchy.py b/gadgets/standard_revisions_tests/test_section_hierarchy.py similarity index 100% rename from gadgets/standard_revisions-tests/test_section_hierarchy.py rename to gadgets/standard_revisions_tests/test_section_hierarchy.py From 066625810b8fea5788878192d0b60a17dc89d3b6 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 2 Nov 2018 12:35:44 +0200 Subject: [PATCH 019/114] Release 20181028 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fe8ab3310..7af6e0cae 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ qhelpgenerator = qhelpgenerator #Version -VERSION=20180311 +VERSION=20181028 #STANDARD RULES From 22a16481c9fecaf3b5aace1c779dd8cbe656c098 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Fri, 9 Nov 2018 15:31:12 +0100 Subject: [PATCH 020/114] Preprocess: improve formatting --- commands/preprocess.py | 9 ++++----- commands/preprocess_cssless.py | 8 ++++---- preprocess.py | 8 +++++--- preprocess_qch.py | 16 +++++++--------- tests/test_preprocess.py | 10 ++++++---- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/commands/preprocess.py b/commands/preprocess.py index dadf36462..f61f79aab 100644 --- a/commands/preprocess.py +++ b/commands/preprocess.py @@ -128,8 +128,8 @@ def build_rename_map(root): if num > 0: name, ext = os.path.splitext(fn) # add file with its path -> only rename that occurrence - result[os.path.join(dir, fn)] = "{}.{}{}".format(name, num + 1, - ext) + result[os.path.join(dir, fn)] = \ + "{}.{}{}".format(name, num + 1, ext) seen[low] += 1 return result @@ -221,8 +221,8 @@ def trasform_relative_link(rename_map, target, file): new_fn = rename_map.get(fn) if new_fn: # look for case conflict of the renamed file - abstarget = os.path.normpath(os.path.join(os.path.dirname(file), - dir, new_fn)) + abstarget = os.path.normpath( + os.path.join(os.path.dirname(file), dir, new_fn)) new_fn = rename_map.get(abstarget, new_fn) else: # original filename unchanged, look for case conflict @@ -240,7 +240,6 @@ def trasform_relative_link(rename_map, target, file): # file is the path of the file the link came from. # root is the path to the root of the archive. def transform_link(rename_map, target, file, root): - if is_loader_link(target): return transform_loader_link(target, file, root) diff --git a/commands/preprocess_cssless.py b/commands/preprocess_cssless.py index 0bd1847f5..8bf9142f4 100644 --- a/commands/preprocess_cssless.py +++ b/commands/preprocess_cssless.py @@ -163,8 +163,8 @@ def convert_span_table_to_tr_td(table_el): remove_css_property(table_el, 'display') for element in table_el.getchildren(): - tag_renamed = convert_display_property_to_html_tag(element, 'tr', - 'table-row') + tag_renamed = convert_display_property_to_html_tag( + element, 'tr', 'table-row') if tag_renamed: if needs_td_wrapper(element): td = etree.Element('td') @@ -176,8 +176,8 @@ def convert_span_table_to_tr_td(table_el): element.text = None else: for child in element: - convert_display_property_to_html_tag(child, 'td', - 'table-cell') + convert_display_property_to_html_tag( + child, 'td', 'table-cell') def wrap_element(el, tag_name, style): diff --git a/preprocess.py b/preprocess.py index 851785b71..f3d9c5a44 100755 --- a/preprocess.py +++ b/preprocess.py @@ -51,9 +51,11 @@ def main(): file_list = preprocess.find_html_files(root) with concurrent.futures.ProcessPoolExecutor() as executor: - futures = [executor.submit(preprocess.preprocess_html_file, root, fn, - rename_map) - for fn in file_list] + futures = [ + executor.submit(preprocess.preprocess_html_file, + root, fn, rename_map) + for fn in file_list + ] for future in futures: output = future.result() diff --git a/preprocess_qch.py b/preprocess_qch.py index 6b7302550..26f487449 100755 --- a/preprocess_qch.py +++ b/preprocess_qch.py @@ -53,20 +53,18 @@ def main(): src_path = os.path.join(root, file) rel_path = os.path.relpath(src_path, source_root) dst_path = os.path.join(dest_root, rel_path) - tuple = (src_path, dst_path) - paths_list.append(tuple) + paths_list.append((src_path, dst_path)) with concurrent.futures.ProcessPoolExecutor() as executor: futures = [ - (executor.submit(preprocess_cssless.preprocess_html_merge_cssless, - src_path, dst_path), - i) - for i, (src_path, dst_path) in enumerate(paths_list) + executor.submit(preprocess_cssless.preprocess_html_merge_cssless, + src_path, dst_path) + for src_path, dst_path in paths_list ] - for future, i in futures: - print('Processing file: {}/{}: {}'.format(i, len(paths_list), - paths_list[i][1])) + for i, future in enumerate(futures): + print('Processing file: {}/{}: {}'.format( + i, len(paths_list), paths_list[i][1])) output = future.result() if verbose: print(output) diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index c9d02e8ef..523319920 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -231,6 +231,10 @@ def test_transform_ranges_placeholder(self): '../algorithm/all_any_none_of.html'), ] + def msg(target, file, root): + return "target='{}', file='{}', root='{}'".format( + target, file, root) + # transform_ranges_placeholder(target, file, root) # target: the placeholder link # file: path of the file that contains the link @@ -239,14 +243,12 @@ def test_transform_ranges_placeholder(self): for target, file, expected in entries: res = transform_ranges_placeholder(target, file, root) self.assertEqual(expected, res, - msg="target='{}', file='{}', root='{}'".format( - target, file, root)) + msg=msg(target, file, root)) target = target.replace('http://', 'https://') res = transform_ranges_placeholder(target, file, root) self.assertEqual(expected, res, - msg="target='{}', file='{}', root='{}'".format( - target, file, root)) + msg=msg(target, file, root)) class TestPreprocessHtml(unittest.TestCase): From 30c065ad6b7dc692b495ba7d8851f6c2366eb387 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Dec 2018 13:54:15 +0100 Subject: [PATCH 021/114] Transform/DDG: fix wrong indentation --- index2ddg.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/index2ddg.py b/index2ddg.py index 9e03566ed..6fe6130d5 100755 --- a/index2ddg.py +++ b/index2ddg.py @@ -74,11 +74,10 @@ def get_item_type(el): if el.get('link') == '.': return ITEM_TYPE_FUNCTION_INLINEMEM return ITEM_TYPE_FUNCTION - - if el.tag == 'variable': - if el.get('link') == '.': - return ITEM_TYPE_VARIABLE_INLINEMEM - return ITEM_TYPE_VARIABLE + if el.tag == 'variable': + if el.get('link') == '.': + return ITEM_TYPE_VARIABLE_INLINEMEM + return ITEM_TYPE_VARIABLE if el.tag == 'constructor': if el.get('link') == '.': return ITEM_TYPE_CONSTRUCTOR_INLINEMEM From a719f6516926aa1dc493a175ea12c2584e8cfbc6 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Dec 2018 13:56:03 +0100 Subject: [PATCH 022/114] Transform/DDG: fix some minor issues This fixes some dead code and unused variable warnings, and fixes a pylint warning by removing an unnecessary if expression. --- index2ddg.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index2ddg.py b/index2ddg.py index 6fe6130d5..0cfa55705 100755 --- a/index2ddg.py +++ b/index2ddg.py @@ -144,7 +144,7 @@ def process_item_hook(self, el, full_name, full_link): def get_html_files(root): files = [] - for dir, dirnames, filenames in os.walk(root): + for dir, _, filenames in os.walk(root): for filename in fnmatch.filter(filenames, '*.html'): files.append(os.path.join(dir, filename)) return files @@ -206,8 +206,8 @@ def build_abstract(decls, desc, max_code_lines, split_code_lines, # limit the number of code snippets to be included so that total number # of lines is less than max_code_lines. The limit becomes active only # for the second and subsequent snippets. - first = True if i == 0 else False - last = True if i == len(decls)-1 else False + first = (i == 0) + last = (i == len(decls)-1) if not first: if last: @@ -423,24 +423,23 @@ def process_identifier(out, redirects, root, link, item_ident, item_type, elif item_type in [ITEM_TYPE_FUNCTION_INLINEMEM, ITEM_TYPE_CONSTRUCTOR_INLINEMEM, ITEM_TYPE_DESTRUCTOR_INLINEMEM]: - raise DdgException("INLINEMEM") # not implemented ''' Implementation notes: * the declarations are possibly versioned * declaration is selected from the member table * the member table is found according to the identifier (last part after :: is enough, hopefully) ''' + raise DdgException("INLINEMEM") # not implemented elif item_type in [ITEM_TYPE_VARIABLE, ITEM_TYPE_VARIABLE_INLINEMEM, ITEM_TYPE_ENUM]: - raise DdgException("ENUM") # not implemented ''' Implementation notes: * the declarations are possibly versioned ''' + raise DdgException("ENUM") # not implemented elif item_type == ITEM_TYPE_ENUM_CONST: - raise DdgException("ENUM_CONST") # not implemented ''' Implementation notes: * the abstract will come from the const -> definition table, which is always put before the first heading. @@ -448,6 +447,7 @@ def process_identifier(out, redirects, root, link, item_ident, item_type, to split the content at ';' and ',', then search for the name of the enum. If we find duplicates, signal an error. ''' + raise DdgException("ENUM_CONST") # not implemented if debug.enabled: debug.debug_abstracts_file.write("--------------\n") From 573e92315a4bc14230ba5bb930bad36035a67671 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sat, 2 Feb 2019 17:03:54 +0100 Subject: [PATCH 023/114] Fix QCH build This changes the file extension of the qhelpgenerator input file to use a .qhp extension instead of .xml. This is required because an update to qhelpgenerator now rejects the .xml extension. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7af6e0cae..40a9e7750 100644 --- a/Makefile +++ b/Makefile @@ -175,13 +175,13 @@ output/cppreference-doc-en-cpp.devhelp2: \ #build the .qch (QT help) file output/cppreference-doc-en-cpp.qch: output/qch-help-project-cpp.xml #qhelpgenerator only works if the project file is in the same directory as the documentation - cp "output/qch-help-project-cpp.xml" "output/reference_cssless/qch.xml" + cp "output/qch-help-project-cpp.xml" "output/reference_cssless/qch.qhp" pushd "output/reference_cssless" > /dev/null; \ - $(qhelpgenerator) "qch.xml" -o "../cppreference-doc-en-cpp.qch"; \ + $(qhelpgenerator) "qch.qhp" -o "../cppreference-doc-en-cpp.qch"; \ popd > /dev/null - rm -f "output/reference_cssless/qch.xml" + rm -f "output/reference_cssless/qch.qhp" output/qch-help-project-cpp.xml: \ output/cppreference-doc-en-cpp.devhelp2 \ From 56f765ade13252601ebc3bc39f903c3aceed6f8d Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 3 Feb 2019 11:33:57 +0100 Subject: [PATCH 024/114] Add LICENSE file --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..f288702d2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 1b0916ebb43b8c4ca1b863109f8b0de51bd42ec0 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 21 Feb 2019 19:43:21 +0200 Subject: [PATCH 025/114] headers: Fix definition of NULL --- headers/cstddef | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headers/cstddef b/headers/cstddef index 7e8ac2349..84da4b527 100644 --- a/headers/cstddef +++ b/headers/cstddef @@ -22,7 +22,7 @@ namespace std { #define offsetof(type,member_designator) 0 // SIMPLIFIED #endif #ifndef NULL -#define NULL +#define NULL 0 #endif namespace std { From 6b1186a46fdb94c19419735a281b6b94adf6ed17 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 14:03:09 +0200 Subject: [PATCH 026/114] Index: Update chapters --- index-chapters-c.xml | 4 +++- index-chapters-cpp.xml | 35 ++++++++++++++++++++++++++++++++--- index-cpp-search-app.txt | 8 ++++++++ 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/index-chapters-c.xml b/index-chapters-c.xml index 7ed4dffe1..f45bb438d 100644 --- a/index-chapters-c.xml +++ b/index-chapters-c.xml @@ -20,6 +20,7 @@ + @@ -29,7 +30,7 @@ - + @@ -38,4 +39,5 @@ + diff --git a/index-chapters-cpp.xml b/index-chapters-cpp.xml index 7802cb588..0ce073067 100644 --- a/index-chapters-cpp.xml +++ b/index-chapters-cpp.xml @@ -14,12 +14,13 @@ Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. --> - + + @@ -27,6 +28,7 @@ + @@ -34,8 +36,11 @@ + + + @@ -79,11 +84,13 @@ + + @@ -91,6 +98,7 @@ + @@ -103,22 +111,33 @@ + + + + + + - - + + + + + + + @@ -138,14 +157,19 @@ + + + + + @@ -162,10 +186,15 @@ + + + + + diff --git a/index-cpp-search-app.txt b/index-cpp-search-app.txt index 0125baa38..08c6c8b75 100644 --- a/index-cpp-search-app.txt +++ b/index-cpp-search-app.txt @@ -63,6 +63,7 @@ Pointers => cpp/language/pointer Arrays => cpp/language/array Enumerations and enumerators => cpp/language/enum const/volatile => cpp/language/cv +consteval specifier => cpp/language/consteval constexpr specifier => cpp/language/constexpr decltype operator => cpp/language/decltype auto specifier => cpp/language/auto @@ -210,6 +211,7 @@ bool type => cpp/language/types#Boolean_type case label => cpp/language/switch default label => cpp/language/switch type char => cpp/language/types +char8_t type => cpp/language/types#Character_types char16_t type => cpp/language/types#Character_types char32_t type => cpp/language/types#Character_types compl keyword => cpp/language/operator_alternative @@ -263,5 +265,11 @@ using (type alias, alias template) => cpp/language/type_alias ODR => cpp/language/definition#One_Definition_Rule odr-use => cpp/language/definition#One_Definition_Rule __has_include => cpp/preprocessor/include +__has_cpp_attribute => cpp/feature_test final => cpp/language/final override => cpp/language/override +type byte => cpp/types/byte +feature test => cpp/feature_test +keyword co_await => cpp/language/coroutines +keyword co_return => cpp/language/coroutines +keyword co_yield => cpp/language/coroutines From 0fa7fee13cbd286ca4b50429c8f86def47f043df Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 19:27:55 +0200 Subject: [PATCH 027/114] Index: Sort type traits Sort type traits so the order matches cppreference. Add missing is_aggregate trait. Fix callable trait names and add invoke_result. --- index-functions-cpp.xml | 54 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 9e40f9ebd..eff4b9b02 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -472,14 +472,20 @@ - - + + + + + + + + @@ -490,27 +496,19 @@ - - - - - - - - - - - - - - + + + + + + @@ -528,14 +526,18 @@ + + - - + + + + @@ -591,10 +593,6 @@ - - - - @@ -620,6 +618,14 @@ + + + + + + + + @@ -665,7 +671,6 @@ - @@ -674,6 +679,9 @@ + + + From 549be9900b6bebab0018639935856545acceaf3d Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 19:54:45 +0200 Subject: [PATCH 028/114] Index: Add missing iterator class contents --- index-functions-cpp.xml | 124 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 113 insertions(+), 11 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index eff4b9b02..535e254e7 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -707,38 +707,140 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - + + + + + + + - + + + + + + - + - + + + + + + + + + + + - + + + + + + + + + + - + + + + + + + + - + + + + + + + + From 603a090e5a8f40956e341de82a4d7d04e6bdc2f5 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 20:12:48 +0200 Subject: [PATCH 029/114] Index: Add missing member variables Add missing member variables to random number engines and localization facet categories. --- index-functions-cpp.xml | 57 +++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 535e254e7..ce6fd64f5 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -3460,7 +3460,10 @@ - + + + + @@ -3476,7 +3479,20 @@ - + + + + + + + + + + + + + + @@ -3492,7 +3508,10 @@ - + + + + @@ -3509,7 +3528,8 @@ - + + @@ -3525,8 +3545,6 @@ - - @@ -3543,7 +3561,7 @@ - + @@ -4803,7 +4821,7 @@ - + @@ -4834,7 +4852,7 @@ - + @@ -4852,7 +4870,7 @@ - + @@ -4872,7 +4890,7 @@ - + @@ -4900,7 +4918,7 @@ - + @@ -4916,7 +4934,7 @@ - + @@ -4930,7 +4948,7 @@ - + @@ -4944,7 +4962,7 @@ - + @@ -4966,7 +4984,7 @@ - + @@ -4983,7 +5001,7 @@ - + @@ -5000,7 +5018,7 @@ - + @@ -5031,7 +5049,8 @@ - + + From 5b7bff61891cece6dc11cd84c11bf10ed1e25795 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 20:24:09 +0200 Subject: [PATCH 030/114] Index: Add missing filesystem entries Add missing filesystem::perm_options type, and missing bitwise operators for copy_options and directory_options types. --- index-functions-cpp.xml | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index ce6fd64f5..254be85d9 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -5911,6 +5911,21 @@ + + + + + + + + + + + + + + + @@ -5922,17 +5937,34 @@ + + + + + + + + + + + + + + + + + + - @@ -6444,5 +6476,4 @@ - From 4643b72dd2aab896949f744f7261e0db296abe3c Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 20:41:47 +0200 Subject: [PATCH 031/114] Index: Add missing since C++11 attributes Adds since C++11 attribute to a number of entities. --- index-functions-cpp.xml | 68 ++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 254be85d9..b8a58d3fe 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -1499,7 +1499,7 @@ - + @@ -2157,10 +2157,10 @@ - - - - + + + + @@ -2230,19 +2230,19 @@ - - + + - + - + - + - + @@ -2250,13 +2250,13 @@ - + - + @@ -4001,9 +4001,9 @@ - - - + + + @@ -4012,7 +4012,7 @@ - + @@ -4020,11 +4020,11 @@ - - + + - - + + @@ -4046,19 +4046,19 @@ - + - + - + - + - - + + @@ -4078,8 +4078,8 @@ - - + + @@ -4089,12 +4089,12 @@ - - + + - + @@ -4102,7 +4102,7 @@ - + @@ -4289,7 +4289,7 @@ - + From be4361f02e5dddd3ffd353ccf6926707c721d079 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 20:47:20 +0200 Subject: [PATCH 032/114] Index: Add various missing C++17 entries This adds a number of missing C++17 and C++14 entries: * byte type * uncaugt_exceptions * initializer_list: rbegin and rend * to_chars, from_chars, chars_format * string: operator basic_string_view Also fixes a couple of other issues, including: * Change tags from `operator` to `function` * Change enum to class for types with overloaded operators * Fix `since` attribute of for_each_n * Move unary_function and binary_function to function objects section * Add bit_xor and fix bit_not `since` attribute --- index-functions-cpp.xml | 68 +++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 13 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index b8a58d3fe..e0b0f4136 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -32,6 +32,20 @@ + + + + + + + + + + + + + + @@ -1245,6 +1259,7 @@ + @@ -1507,6 +1522,8 @@ + + @@ -1801,7 +1818,11 @@ - + + + + + @@ -1855,15 +1876,15 @@ - + - + - + @@ -1882,6 +1903,9 @@ + + + @@ -2061,6 +2085,7 @@ + @@ -2074,14 +2099,29 @@ + + + + + + + + + + + + + + + + + + - - - @@ -2234,6 +2274,7 @@ + @@ -2258,6 +2299,7 @@ + @@ -4005,11 +4047,10 @@ - + - @@ -4093,6 +4134,7 @@ + @@ -4600,12 +4642,12 @@ - + - + @@ -5704,7 +5746,7 @@ - + @@ -5713,7 +5755,7 @@ - + From 98c385baac71f562f165d556bdd36e46bb397ec4 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 21:03:12 +0200 Subject: [PATCH 033/114] Index: Add C++20 type traits --- index-functions-cpp.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index e0b0f4136..f963e21a6 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -556,6 +556,10 @@ + + + + @@ -632,6 +636,8 @@ + + @@ -683,12 +689,17 @@ + + + + + @@ -696,6 +707,8 @@ + + @@ -709,6 +722,14 @@ + + + + + + + + @@ -720,6 +741,14 @@ + + + + + + + + From f08d0b2dc22468bd1b005b50ba6b9dd19398a2a5 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 21:05:48 +0200 Subject: [PATCH 034/114] Index: Add C++20 comparison-related entries --- index-functions-cpp.xml | 95 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index f963e21a6..16282be6c 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -2123,6 +2123,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4165,6 +4257,9 @@ + + + From 9a7ff484522167c3f40f70b59e7b4b85228fd2b1 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 21:10:28 +0200 Subject: [PATCH 035/114] Index: Add C++20 container and string changes Adds C++20 uniform container erasure, `contains` for associative containers, std::span, and UTF-8 string additions. --- index-functions-cpp.xml | 74 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 16282be6c..7a848b5bb 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -2318,6 +2318,8 @@ + + @@ -2422,6 +2424,8 @@ + + @@ -2446,6 +2450,8 @@ + + @@ -2455,11 +2461,13 @@ + + @@ -2495,6 +2503,8 @@ + + @@ -2509,12 +2519,15 @@ + + + @@ -2672,6 +2685,8 @@ + + @@ -2722,6 +2737,8 @@ + + @@ -2770,6 +2787,8 @@ + + @@ -2825,6 +2844,8 @@ + + @@ -2858,6 +2879,7 @@ + @@ -2873,6 +2895,7 @@ + @@ -2906,6 +2929,7 @@ + @@ -2921,6 +2945,7 @@ + @@ -2961,6 +2986,7 @@ + @@ -2976,6 +3002,7 @@ + @@ -3012,6 +3039,7 @@ + @@ -3027,6 +3055,7 @@ + @@ -3056,6 +3085,7 @@ + @@ -3080,6 +3110,7 @@ + @@ -3109,6 +3140,7 @@ + @@ -3133,6 +3165,7 @@ + @@ -3166,6 +3199,7 @@ + @@ -3190,6 +3224,7 @@ + @@ -3219,6 +3254,7 @@ + @@ -3243,6 +3279,7 @@ + @@ -3318,6 +3355,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4d3a0e996589db2cbd52959ec4f16f35c16109c7 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 21:15:19 +0200 Subject: [PATCH 036/114] Index: Add C++20 synchronized IO --- index-functions-cpp.xml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 7a848b5bb..eaa2f3271 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -4460,6 +4460,24 @@ + + + + + + + + + + + + + + + + + + @@ -4699,9 +4717,22 @@ + + + + + + + + + + + + + @@ -4711,10 +4742,12 @@ + + @@ -4724,6 +4757,7 @@ + @@ -4815,6 +4849,9 @@ + + + From 96ae9e32b3ee733f866cdf787a30e0c455278e4b Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 21:17:46 +0200 Subject: [PATCH 037/114] Index: Add C++20 memory changes --- index-functions-cpp.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index eaa2f3271..ae2b4ba2d 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -969,6 +969,9 @@ + + + @@ -1221,8 +1224,10 @@ + + From bc5aadd22c949770a5a720bc259cc43b437e48b9 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 21:18:25 +0200 Subject: [PATCH 038/114] Index: Add C++20 algorithms and changes to functional --- index-functions-cpp.xml | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index ae2b4ba2d..a58b34324 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -900,9 +900,13 @@ + + + + @@ -1874,7 +1878,12 @@ + + + + + @@ -1935,6 +1944,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2120,6 +2163,7 @@ + @@ -4237,9 +4281,11 @@ + + @@ -4286,6 +4332,8 @@ + + From 771518c21e68aac1b875e3b16c165938cbea0436 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Sun, 2 Jun 2019 21:19:17 +0200 Subject: [PATCH 039/114] Index: Add C++20 atomic_ref --- index-functions-cpp.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index a58b34324..a0e62a8ea 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -5654,6 +5654,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From c6a82c69fe8a3c0e25ee30efbbf5517ef936ea66 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Mon, 3 Jun 2019 20:56:51 +0200 Subject: [PATCH 040/114] Index: Fix a bunch of errors This fixes a bunch of typos and wrong links. --- index-chapters-cpp.xml | 2 +- index-functions-c.xml | 5 +-- index-functions-cpp.xml | 88 +++++++++++++++++------------------------ 3 files changed, 40 insertions(+), 55 deletions(-) diff --git a/index-chapters-cpp.xml b/index-chapters-cpp.xml index 0ce073067..e62d4a448 100644 --- a/index-chapters-cpp.xml +++ b/index-chapters-cpp.xml @@ -116,7 +116,7 @@ - + diff --git a/index-functions-c.xml b/index-functions-c.xml index 40f45c556..74104616d 100644 --- a/index-functions-c.xml +++ b/index-functions-c.xml @@ -31,7 +31,6 @@ - @@ -1094,8 +1093,8 @@ - - + + diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index a0e62a8ea..062917ddb 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -613,12 +613,12 @@ - - + + - - + + @@ -859,7 +859,7 @@ - @@ -883,7 +883,7 @@ - @@ -924,19 +924,13 @@ - - + - - - - - @@ -1000,11 +994,11 @@ - + - - + + @@ -1203,8 +1197,7 @@ - - + @@ -1693,7 +1686,7 @@ - + @@ -1912,7 +1905,6 @@ - @@ -2040,11 +2032,12 @@ - - - - - + + + + + + @@ -2068,7 +2061,6 @@ - @@ -2083,18 +2075,18 @@ - - - + + + - - - - - - + + + + + + - + @@ -2162,7 +2154,6 @@ - @@ -4310,8 +4301,8 @@ - - + + @@ -4340,7 +4331,7 @@ - + @@ -5969,8 +5960,6 @@ - - @@ -6024,8 +6013,6 @@ - - @@ -6219,7 +6206,7 @@ - + @@ -6422,23 +6409,23 @@ - + - + - + - + - + @@ -6594,7 +6581,6 @@ - From a2a6459adcd05add0a2aa7f7a05541f6a00ce2f7 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 5 Jun 2019 22:59:02 +0300 Subject: [PATCH 041/114] test: Fix errors that appeared after releasing new pylint --- config/pylintrc | 1 + ddg_parse_html.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/pylintrc b/config/pylintrc index 9fbfd511c..373c6473f 100644 --- a/config/pylintrc +++ b/config/pylintrc @@ -63,6 +63,7 @@ disable= missing-docstring, too-many-lines, no-self-use, + chained-comparison, duplicate-code, too-many-ancestors, too-many-instance-attributes, diff --git a/ddg_parse_html.py b/ddg_parse_html.py index 4ee52b89d..bf1f76ef5 100644 --- a/ddg_parse_html.py +++ b/ddg_parse_html.py @@ -111,8 +111,7 @@ def get_declarations(root_el, name): if len(dcls) == 0: if not ignored: raise DdgException("dcl table contains no declarations") - else: - raise DdgException("All entries in dcl table were ignored") + raise DdgException("All entries in dcl table were ignored") return dcls From c4580cbfef62db05c0f23b8038918221ea91706a Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 5 Jun 2019 23:05:31 +0300 Subject: [PATCH 042/114] travis: Check whether index-functions-{c,cpp}.xml can be parsed --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 45d61ce3b..1ea58be4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,9 @@ before_script: script: - "python -m unittest discover" + - "mkdir -p tmp" + - "python index2browser.py index-functions-c.xml tmp/index-functions-c-web.html" + - "python index2browser.py index-functions-cpp.xml tmp/index-functions-cpp-web.html" notifications: email: false From ac516a890a5cd5e537461129aefa99838f20a008 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 7 Jun 2019 23:53:16 +0300 Subject: [PATCH 043/114] Release 20190607 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 40a9e7750..b68b890c2 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,7 @@ qhelpgenerator = qhelpgenerator #Version -VERSION=20181028 +VERSION=20190607 #STANDARD RULES From aca918320f5baf3091f5f970648aefcb2c2c8826 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 9 Oct 2019 15:04:42 +0300 Subject: [PATCH 044/114] Fix new errors after upgrading pylint --- index2autolinker.py | 2 +- index2ddg.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index2autolinker.py b/index2autolinker.py index 7a5182497..45ebc44ba 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 0cfa55705..f8c9e1210 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 From 24a4abd27b77b556088429508efdff6bb3b9d26f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 9 Oct 2019 14:57:04 +0300 Subject: [PATCH 045/114] Makefile: Fix retrieval of exported contents --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b68b890c2..644e3a566 100644 --- a/Makefile +++ b/Makefile @@ -257,4 +257,4 @@ source: http://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 From a32fcf36fe689b69e05446bb01ccf71db2e483cf Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 9 Oct 2019 14:58:31 +0300 Subject: [PATCH 046/114] Headers: Remove TODO list --- headers/progress | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 headers/progress diff --git a/headers/progress b/headers/progress deleted file mode 100644 index c0f40196a..000000000 --- a/headers/progress +++ /dev/null @@ -1,11 +0,0 @@ - -done: -algorithm -array -atomic -cassert -cfenv -ciso646 -deque -list -vector From 6d6a9761239e35f4e70443369337318e0305b7c8 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 9 Oct 2019 14:58:32 +0300 Subject: [PATCH 047/114] Headers: Make sure all headers compile --- headers/algorithm | 25 ++++----- headers/array | 11 +--- headers/atomic | 7 ++- headers/bitset | 8 ++- headers/chrono | 19 +++---- headers/codecvt | 17 ++++--- headers/complex | 10 ++-- headers/condition_variable | 2 + headers/csetjmp | 2 +- headers/cstdarg | 6 ++- headers/cstddef | 9 ++-- headers/cstdio | 12 +++-- headers/cstdlib | 2 + headers/cstring | 2 + headers/ctime | 2 + headers/cuchar | 4 ++ headers/cwchar | 4 ++ headers/deque | 1 + headers/exception | 7 +-- headers/fstream | 48 +++++++++++------ headers/functional | 23 +++++++-- headers/future | 28 +++++++--- headers/initializer_list | 2 + headers/iomanip | 3 +- headers/ios | 102 +++++++++++++++++++------------------ headers/iosfwd | 4 +- headers/istream | 31 ++++++----- headers/iterator | 19 +++++-- headers/limits | 64 +++++++++++------------ headers/list | 1 + headers/locale | 63 +++++++++++++---------- headers/map | 15 +++--- headers/memory | 33 +++++++----- headers/mutex | 2 + headers/new | 4 +- headers/ostream | 13 ++++- headers/queue | 1 + headers/random | 53 ++++++++++--------- headers/ratio | 4 +- headers/regex | 50 +++++++++--------- headers/scoped_allocator | 7 +-- headers/set | 9 ++-- headers/shared_mutex | 2 + headers/sstream | 50 ++++++++++-------- headers/stack | 2 + headers/stdexcept | 1 + headers/streambuf | 4 +- headers/string | 59 +++++++++++---------- headers/system_error | 7 +++ headers/thread | 3 ++ headers/tuple | 41 +++++++++------ headers/type_traits | 6 ++- headers/typeindex | 1 + headers/typeinfo | 1 + headers/unordered_map | 11 +++- headers/unordered_set | 13 ++--- headers/utility | 11 ++-- headers/valarray | 20 ++++++-- headers/vector | 2 +- 59 files changed, 583 insertions(+), 380 deletions(-) diff --git a/headers/algorithm b/headers/algorithm index 596f60ce9..13105b42d 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,34 +39,34 @@ 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); template std::pair -mismatch(InputIt1 first1, InputIt1 last1, - InputIt2 first2); + mismatch(InputIt1 first1, InputIt1 last1, + InputIt2 first2); template std::pair -mismatch(InputIt1 first1, InputIt1 last1, - InputIt2 first2, - BinaryPredicate p); + mismatch(InputIt1 first1, InputIt1 last1, + InputIt2 first2, + BinaryPredicate p); #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 template diff --git a/headers/array b/headers/array index 29698105c..baf184781 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,8 +53,6 @@ public: void assign(std::initializer_list ilist); #endif - allocator_type get_allocator() const; - // element access reference at(size_type n); const_reference at(size_type n) const; @@ -99,6 +90,8 @@ public: 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 d246cc5ff..0142c7ba2 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 e868f7095..c457ceddc 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 9833e88b5..42f66bc6c 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,8 +158,8 @@ 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 time_point(); @@ -226,7 +227,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 +241,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 +253,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 477ca7798..0b7390501 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 086a86391..ff608bfea 100644 --- a/headers/complex +++ b/headers/complex @@ -16,6 +16,8 @@ #ifndef CPPREFERENCE_COMPLEX_H #define CPPREFERENCE_COMPLEX_H +#include + namespace std { template @@ -61,11 +63,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 diff --git a/headers/condition_variable b/headers/condition_variable index a05f1fc90..66db3a9f2 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 c867e1530..aef488b96 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 038c09f14..295e531c9 100644 --- a/headers/cstdarg +++ b/headers/cstdarg @@ -18,11 +18,13 @@ namespace std { -struct va_list; // actually a typedef +struct va_list {}; // actually a typedef } // namespace std -void va_start(std::va_list ap, int parm_n); // actually a macro +template +void va_start(std::va_list ap, T parm_n); // actually a macro + #define va_arg(x, T) T() #if CPPREFERENCE_STDVER>= 2011 void va_copy(std::va_list desc, std::va_list src); // actually a macro diff --git a/headers/cstddef b/headers/cstddef index 84da4b527..0da058de8 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,9 +25,10 @@ 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; typedef void* nullptr_t; } // namespace std diff --git a/headers/cstdio b/headers/cstdio index f4f0198cf..331e3c37a 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 0b838a51b..0d18b0f2b 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 131b33f0c..f019f3ef9 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 90cb50048..660b89acf 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 d6dde80df..c684e8dd6 100644 --- a/headers/cuchar +++ b/headers/cuchar @@ -18,8 +18,12 @@ #if CPPREFERENCE_STDVER>= 2011 +#include // for size_t +#include // for mbstate_t + #define __STDC_UTF_16__ #define __STDC_UTF_32__ + namespace std { std::size_t mbrtoc16(char16_t* pc16, diff --git a/headers/cwchar b/headers/cwchar index 35f1a6445..9c8a2ef4e 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 894c7766a..1371f1755 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/exception b/headers/exception index 1481710b9..841df33a7 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 13c31e180..406852981 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 e3cbb5b9a..b1bafd515 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: @@ -66,7 +78,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 +114,7 @@ public: template std::function mem_fn(R T::* pm); -template +template std::function bind(F&& f, Args&& ... args); template @@ -142,8 +154,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); @@ -341,7 +353,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 diff --git a/headers/future b/headers/future index c69d339d8..26b1ee31b 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; diff --git a/headers/initializer_list b/headers/initializer_list index 41bc03ed0..2079abc99 100644 --- a/headers/initializer_list +++ b/headers/initializer_list @@ -18,6 +18,8 @@ #if CPPREFERENCE_STDVER>= 2011 +#include // for size_t + namespace std { template diff --git a/headers/iomanip b/headers/iomanip index 67ffa8aed..a88e9cf98 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 174969654..8be63b1fa 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 a22df584e..ff92170eb 100644 --- a/headers/iosfwd +++ b/headers/iosfwd @@ -81,8 +81,8 @@ typedef basic_ostringstream wostringstream; typedef basic_stringstream wstringstream; template class fpos; -typedef fpos::state_type> streampos; -typedef fpos::state_type> wstreampos; +typedef fpos::state_type> streampos; +typedef fpos::state_type> wstreampos; } // namespace std diff --git a/headers/istream b/headers/istream index 8fb7ecc1e..36762cf3c 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 6ca93f058..5895ccf95 100644 --- a/headers/iterator +++ b/headers/iterator @@ -20,6 +20,12 @@ 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 +45,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 diff --git a/headers/limits b/headers/limits index 9611e7fd8..ec3fecb0f 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 1b8806c5f..6db613a5c 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 91757a18d..f3175a712 100644 --- a/headers/locale +++ b/headers/locale @@ -16,7 +16,9 @@ #ifndef CPPREFERENCE_LOCALE_H #define CPPREFERENCE_LOCALE_H +#include // for tm #include // for std::allocator +#include namespace std { @@ -82,12 +84,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(); @@ -118,7 +126,7 @@ public: Codecvt* pcvt = new Codecvt, state_type state = state_type()); #if CPPREFERENCE_STDVER >= 2014 - wbuffer_convert(const std::wbuffer_convert&) = delete; + wbuffer_convert(const wbuffer_convert&) = delete; #endif ~wbuffer_convert(); @@ -235,54 +243,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 +364,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 +375,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 b326f2951..4b099492e 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: @@ -295,7 +295,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 +324,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: diff --git a/headers/memory b/headers/memory index 9a74fa791..9527f8cfd 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(); @@ -434,7 +443,7 @@ 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); + pointer allocate(size_type n, void* hint = 0); void deallocate(pointer p, size_type n); size_type max_size() const; @@ -475,10 +484,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 +519,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 170a73b21..d38a68d44 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 9fe03e9df..08970b72d 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/ostream b/headers/ostream index 690caae7b..0e7932594 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/queue b/headers/queue index 704cc7593..312733c23 100644 --- a/headers/queue +++ b/headers/queue @@ -19,6 +19,7 @@ #if CPPREFERENCE_STDVER>= 2011 #include #endif +#include namespace std { diff --git a/headers/random b/headers/random index 97c9858b2..f405d19ba 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 4f754d480..e2bb0c7ab 100644 --- a/headers/ratio +++ b/headers/ratio @@ -27,8 +27,8 @@ 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; diff --git a/headers/regex b/headers/regex index 1d1922d7e..37008f8b0 100644 --- a/headers/regex +++ b/headers/regex @@ -20,6 +20,8 @@ #include // for std::initializer_list #include // for std::allocator +#include +#include namespace std { namespace regex_constants { @@ -154,7 +156,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 +190,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 +221,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 +232,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 +263,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 +310,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 +362,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 +390,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 +424,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 +487,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 cc9081517..ec7ec81bc 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 777ed8547..30e445732 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,8 +57,8 @@ 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; @@ -281,8 +282,8 @@ 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; diff --git a/headers/shared_mutex b/headers/shared_mutex index dccf75392..34f463860 100644 --- a/headers/shared_mutex +++ b/headers/shared_mutex @@ -18,6 +18,8 @@ #if CPPREFERENCE_STDVER>= 2014 +#include + namespace std { #if CPPREFERENCE_STDVER>= 2017 diff --git a/headers/sstream b/headers/sstream index 756498c8c..edce346e5 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 75aeac408..a8c8d3577 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 5c3a330b1..c10249f22 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 04dc92df2..d765b508c 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 9d91810c5..90d7c9282 100644 --- a/headers/string +++ b/headers/string @@ -21,11 +21,41 @@ #endif #include // for size_t, ptrdiff_t +#include // for mbstate_t +#include // for streamoff +#include #include // for std::reverse_iterator #include // for std::allocator 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,33 +88,6 @@ 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, @@ -139,7 +142,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, diff --git a/headers/system_error b/headers/system_error index 53848016d..68d8d0dc6 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 45a9ae672..8aca56cfb 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 42be3583d..925486b2d 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 { @@ -85,29 +88,43 @@ public: void swap(tuple& other); }; -template -tuple make_tuple(Types&& ... args); +template +class tuple_size; template +class tuple_size > : public std::integral_constant { }; + +template +class tuple_element; + +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 +148,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 a2d298919..3bc9ce266 100644 --- a/headers/type_traits +++ b/headers/type_traits @@ -18,6 +18,8 @@ #if CPPREFERENCE_STDVER>= 2011 +#include // for size_t + namespace std { template @@ -27,7 +29,7 @@ struct integral_constant { static constexpr T value; constexpr operator value_type() const; - constexpr operator()() const; + constexpr T operator()() const; }; typedef integral_constant false_type; @@ -71,7 +73,7 @@ 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 {}; diff --git a/headers/typeindex b/headers/typeindex index f76d2a0e2..405117a7c 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 65f865c0e..68b5293a7 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 b1fc53c42..ae667db27 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 d4f9799bb..3bfbfb1c9 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()); diff --git a/headers/utility b/headers/utility index 134492439..0424730ef 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 @@ -55,10 +58,10 @@ template T&& forward(typename std::remove_reference::type&& t); template -typename T&& move(T&& t); // SIMPLIFIED: return type +T&& move(T&& t); // SIMPLIFIED: return type template -typename T&& move_if_noexcept(T&& t); // SIMPLIFIED: return type +T&& move_if_noexcept(T&& t); // SIMPLIFIED: return type template T declval(); // SIMPLIFIED: return type @@ -67,10 +70,12 @@ struct piecewise_construct_t { }; constexpr piecewise_construct_t piecewise_construct; #endif +template class tuple; + template < class T1, class T2 - > struct pair { +> struct pair { typedef T1 first_type; typedef T2 second_type; T1 first; diff --git a/headers/valarray b/headers/valarray index 4b61f6f6c..3b407b7a2 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/vector b/headers/vector index 5b2836e6c..4f5810b1a 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 From f10c97472dd26e595f31302d0b8b44f0c470ca8d Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 27 Oct 2019 10:20:22 +0200 Subject: [PATCH 048/114] Headers: Update README --- headers/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/headers/README.md b/headers/README.md index b3de6dfa2..a994605ac 100644 --- a/headers/README.md +++ b/headers/README.md @@ -20,6 +20,8 @@ names are exposed instead of uglified identifiers used in real standard library 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 ------------- From e55936924ed3e0c7b52334681431a6e87921ec58 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 27 Oct 2019 10:20:23 +0200 Subject: [PATCH 049/114] Headers: Remove trailing lines --- headers/README.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/headers/README.md b/headers/README.md index a994605ac..64c605b54 100644 --- a/headers/README.md +++ b/headers/README.md @@ -1,23 +1,23 @@ 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. @@ -25,28 +25,28 @@ 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. From 10fc452471d1b4c55fd7f406eb7dd33c24b21ea9 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 27 Oct 2019 10:20:24 +0200 Subject: [PATCH 050/114] Headers: Add part of the APIs that are available since C++14,17 --- headers/algorithm | 137 +++++++++++++++++----- headers/array | 45 +++++++- headers/chrono | 19 +++- headers/complex | 49 ++++++++ headers/functional | 81 +++++++++++++ headers/future | 24 +++- headers/initializer_list | 13 +++ headers/iterator | 49 ++++++-- headers/map | 10 -- headers/set | 16 +-- headers/string | 56 ++++++++- headers/string_view | 193 +++++++++++++++++++++++++++++++ headers/type_traits | 240 +++++++++++++++++++++++++++++++++++---- headers/utility | 93 +++++++++++++-- 14 files changed, 930 insertions(+), 95 deletions(-) create mode 100644 headers/string_view diff --git a/headers/algorithm b/headers/algorithm index 13105b42d..d2401ae6e 100644 --- a/headers/algorithm +++ b/headers/algorithm @@ -45,6 +45,18 @@ template typename iterator_traits::difference_type count_if(InputIt first, InputIt last, UnaryPredicate p); +#if CPPREFERENCE_STDVER >= 2020 +template +std::pair +constexpr mismatch(InputIt1 first1, InputIt1 last1, + InputIt2 first2); + +template +std::pair +constexpr mismatch(InputIt1 first1, InputIt1 last1, + InputIt2 first2, + BinaryPredicate p); +#else template std::pair mismatch(InputIt1 first1, InputIt1 last1, @@ -55,6 +67,22 @@ 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 @@ -69,6 +97,22 @@ std::pair 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); @@ -88,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); @@ -556,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 @@ -598,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 @@ -653,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); @@ -663,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 baf184781..020f29d5e 100644 --- a/headers/array +++ b/headers/array @@ -54,15 +54,48 @@ public: #endif // 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 + +#if CPPREFERENCE_STDVER >= 2017 + constexpr reference front(); +#else + reference front(); +#endif - reference front(); +#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; @@ -85,7 +118,11 @@ 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); diff --git a/headers/chrono b/headers/chrono index 42f66bc6c..874ca9af7 100644 --- a/headers/chrono +++ b/headers/chrono @@ -162,12 +162,22 @@ public: 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); @@ -217,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: diff --git a/headers/complex b/headers/complex index ff608bfea..6e3e25230 100644 --- a/headers/complex +++ b/headers/complex @@ -25,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); @@ -106,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 @@ -118,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& @@ -129,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/functional b/headers/functional index b1bafd515..9e244aed4 100644 --- a/headers/functional +++ b/headers/functional @@ -41,6 +41,8 @@ public: function(function&& other); template function(F f); + +#if CPPREFERENCE_STDVER < 2017 template function(std::allocator_arg_t, const Alloc& alloc); @@ -58,6 +60,7 @@ public: template function(std::allocator_arg_t, const Alloc& alloc, F f); +#endif ~function(); @@ -188,7 +191,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; @@ -196,7 +203,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; @@ -204,7 +215,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; @@ -212,7 +227,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; @@ -220,7 +239,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; @@ -228,14 +251,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; @@ -243,7 +274,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; @@ -251,7 +286,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; @@ -259,7 +298,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; @@ -267,7 +310,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; @@ -275,7 +322,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; @@ -283,7 +334,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; @@ -291,7 +346,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; @@ -299,14 +358,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; @@ -314,7 +381,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; @@ -322,7 +393,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; @@ -330,13 +405,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; @@ -362,6 +442,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 26b1ee31b..109628dfd 100644 --- a/headers/future +++ b/headers/future @@ -184,13 +184,33 @@ public: const std::error_code& code() const; }; +#if CPPREFERENCE_STDVER >= 2020 +template +[[nodiscard]] +std::future::type> + async(Function&& f, Args&& ... args); + +template +[[nodiscard]] +std::future::type> + async(std::launch policy, Function&& f, Args&& ... args); +#elif CPPREFERENCE_STDVER >= 2017 +template +std::future::type> + async(Function&& f, Args&& ... args); + +template +std::future::type> + 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 2079abc99..30ce679b8 100644 --- a/headers/initializer_list +++ b/headers/initializer_list @@ -33,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/iterator b/headers/iterator index 5895ccf95..c28241108 100644 --- a/headers/iterator +++ b/headers/iterator @@ -441,15 +441,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 @@ -476,28 +482,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)); @@ -513,6 +542,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)); @@ -525,6 +557,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/map b/headers/map index 4b099492e..8f8d2cbb1 100644 --- a/headers/map +++ b/headers/map @@ -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); @@ -333,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/set b/headers/set index 30e445732..f36671354 100644 --- a/headers/set +++ b/headers/set @@ -64,15 +64,9 @@ public: // 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); @@ -176,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; @@ -289,15 +285,9 @@ public: // 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); @@ -401,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/string b/headers/string index 90d7c9282..e07816298 100644 --- a/headers/string +++ b/headers/string @@ -201,6 +201,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 @@ -276,6 +283,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); @@ -299,14 +315,14 @@ 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 basic_string& append(const CharT* s, size_type count); @@ -318,6 +334,14 @@ 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); @@ -345,6 +369,19 @@ public: 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 + basic_string& replace(size_type pos, size_type count, const basic_string& str); basic_string& replace(const_iterator first, const_iterator last, @@ -387,6 +424,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; diff --git a/headers/string_view b/headers/string_view new file mode 100644 index 000000000..5d897b393 --- /dev/null +++ b/headers/string_view @@ -0,0 +1,193 @@ +/* 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 + +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 = -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; + +} // namespace std + +#endif // CPPREFERENCE_STDVER >= 2017 diff --git a/headers/type_traits b/headers/type_traits index 3bc9ce266..41c6ed46a 100644 --- a/headers/type_traits +++ b/headers/type_traits @@ -35,6 +35,11 @@ struct integral_constant { 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 {}; @@ -54,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 {}; @@ -63,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 {}; @@ -80,128 +112,294 @@ 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 + 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 + 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 }; +#if CPPREFERENCE_STDVER >= 2014 +template +using underlying_type_t = int; // SIMPLIFIED typedef +#endif + template class result_of { typedef int type; }; // SIMPLIFIED: removed specializatio diff --git a/headers/utility b/headers/utility index 0424730ef..d4b729350 100644 --- a/headers/utility +++ b/headers/utility @@ -45,26 +45,48 @@ 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 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 T&& move_if_noexcept(T&& t); // SIMPLIFIED: return type +#endif +#if CPPREFERENCE_STDVER >= 2011 template T declval(); // SIMPLIFIED: return type +#endif struct piecewise_construct_t { }; constexpr piecewise_construct_t piecewise_construct; @@ -81,28 +103,58 @@ template < 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 @@ -118,6 +170,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 @@ -130,13 +196,17 @@ 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 @@ -149,6 +219,11 @@ typename std::tuple_element>::type& // SIMPLIFIED: additional overloads omitted #endif +#if CPPREFERENCE_STDVER >= 2014 +template +class tuple_size > : public std::integral_constant { }; +#endif + } // namespace std #endif // CPPREFERENCE_UTILITY_H From 6f4f551af7820141320f40618eb1565f60947018 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 27 Oct 2019 10:20:25 +0200 Subject: [PATCH 051/114] Headers: Fix several circular dependencies --- headers/detail/locale_fwd | 27 +++++++++++++++++++++++++ headers/detail/string_fwd | 42 +++++++++++++++++++++++++++++++++++++++ headers/ios | 2 +- headers/locale | 1 + headers/stdexcept | 2 +- headers/string | 6 +++--- 6 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 headers/detail/locale_fwd create mode 100644 headers/detail/string_fwd diff --git a/headers/detail/locale_fwd b/headers/detail/locale_fwd new file mode 100644 index 000000000..e67b51170 --- /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 000000000..dedac0922 --- /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/ios b/headers/ios index 8be63b1fa..615812da9 100644 --- a/headers/ios +++ b/headers/ios @@ -20,7 +20,7 @@ #include #endif #include -#include +#include namespace std { diff --git a/headers/locale b/headers/locale index f3175a712..65b916d1e 100644 --- a/headers/locale +++ b/headers/locale @@ -17,6 +17,7 @@ #define CPPREFERENCE_LOCALE_H #include // for tm +#include // for ios_base #include // for std::allocator #include diff --git a/headers/stdexcept b/headers/stdexcept index c10249f22..c313b3e5a 100644 --- a/headers/stdexcept +++ b/headers/stdexcept @@ -17,7 +17,7 @@ #define CPPREFERENCE_STDEXCEPT_H #include -#include +#include namespace std { diff --git a/headers/string b/headers/string index e07816298..1c85ae975 100644 --- a/headers/string +++ b/headers/string @@ -22,10 +22,10 @@ #include // for size_t, ptrdiff_t #include // for mbstate_t -#include // for streamoff #include #include // for std::reverse_iterator #include // for std::allocator +#include namespace std { @@ -90,8 +90,8 @@ typedef fpos::state_type> u32streampos; 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; From c380d2dec4e31fb2d38f0df613cc9205aa7f72e3 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 27 Oct 2019 10:20:26 +0200 Subject: [PATCH 052/114] Headers: Fix a number of compile errors on various compilers --- headers/cstdarg | 14 +++++ headers/cuchar | 5 ++ headers/detail/cppreference_unspecified | 33 ++++++++++ headers/functional | 5 +- headers/future | 8 +-- headers/iosfwd | 11 +++- headers/iterator | 27 +++++---- headers/locale | 7 +++ headers/memory | 5 ++ headers/queue | 2 + headers/ratio | 10 ++-- headers/regex | 80 +++++++++++++------------ headers/shared_mutex | 1 + headers/string | 40 ++++++------- headers/string_view | 4 +- headers/tuple | 6 -- headers/type_traits | 24 +++++++- headers/unordered_set | 2 + headers/utility | 9 ++- 19 files changed, 199 insertions(+), 94 deletions(-) create mode 100644 headers/detail/cppreference_unspecified diff --git a/headers/cstdarg b/headers/cstdarg index 295e531c9..f0673077f 100644 --- a/headers/cstdarg +++ b/headers/cstdarg @@ -18,18 +18,32 @@ namespace std { +#ifdef va_start +typedef ::va_list va_list; +#else struct va_list {}; // actually a typedef +#endif } // namespace std +#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/cuchar b/headers/cuchar index c684e8dd6..faccadfd2 100644 --- a/headers/cuchar +++ b/headers/cuchar @@ -21,8 +21,13 @@ #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 { diff --git a/headers/detail/cppreference_unspecified b/headers/detail/cppreference_unspecified new file mode 100644 index 000000000..226d192d7 --- /dev/null +++ b/headers/detail/cppreference_unspecified @@ -0,0 +1,33 @@ +/* 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; +#else +typedef int CPPREFERENCE_UNSPECIFIED_TYPE; +static const int CPPREFERENCE_UNSPECIFIED_TYPE_VALUE = 0; +#endif + +} // namespace std + +#endif // CPPREFERENCE_DETAIL_LOCALE_FWD_H diff --git a/headers/functional b/headers/functional index 9e244aed4..4963dfa7f 100644 --- a/headers/functional +++ b/headers/functional @@ -39,8 +39,9 @@ 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 @@ -125,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 diff --git a/headers/future b/headers/future index 109628dfd..c74f6c722 100644 --- a/headers/future +++ b/headers/future @@ -187,20 +187,20 @@ public: #if CPPREFERENCE_STDVER >= 2020 template [[nodiscard]] -std::future::type> +std::future> async(Function&& f, Args&& ... args); template [[nodiscard]] -std::future::type> +std::future> async(std::launch policy, Function&& f, Args&& ... args); #elif CPPREFERENCE_STDVER >= 2017 template -std::future::type> +std::future> async(Function&& f, Args&& ... args); template -std::future::type> +std::future> async(std::launch policy, Function&& f, Args&& ... args); #else template diff --git a/headers/iosfwd b/headers/iosfwd index ff92170eb..1f7c14bc8 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/iterator b/headers/iterator index c28241108..6d7d5dc90 100644 --- a/headers/iterator +++ b/headers/iterator @@ -17,6 +17,8 @@ #define CPPREFERENCE_ITERATOR_H #include // for size_t, ptrdiff_t +#include // char_traits +#include namespace std { @@ -146,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 @@ -299,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); @@ -369,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; @@ -387,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(); @@ -417,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; diff --git a/headers/locale b/headers/locale index 65b916d1e..a938d0066 100644 --- a/headers/locale +++ b/headers/locale @@ -123,9 +123,16 @@ 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 wbuffer_convert&) = delete; #endif diff --git a/headers/memory b/headers/memory index 9527f8cfd..8dc1da720 100644 --- a/headers/memory +++ b/headers/memory @@ -443,7 +443,12 @@ struct allocator { pointer address(reference x) const; const_pointer address(const_reference x) const; +#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; diff --git a/headers/queue b/headers/queue index 312733c23..d24bce548 100644 --- a/headers/queue +++ b/headers/queue @@ -20,6 +20,8 @@ #include #endif #include +#include +#include // less namespace std { diff --git a/headers/ratio b/headers/ratio index e2bb0c7ab..a73671712 100644 --- a/headers/ratio +++ b/headers/ratio @@ -31,8 +31,9 @@ public: 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 37008f8b0..6d48a417e 100644 --- a/headers/regex +++ b/headers/regex @@ -20,55 +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 diff --git a/headers/shared_mutex b/headers/shared_mutex index 34f463860..23a837e2b 100644 --- a/headers/shared_mutex +++ b/headers/shared_mutex @@ -19,6 +19,7 @@ #if CPPREFERENCE_STDVER>= 2014 #include +#include // try_to_lock_t and friends namespace std { diff --git a/headers/string b/headers/string index 1c85ae975..d72608490 100644 --- a/headers/string +++ b/headers/string @@ -643,26 +643,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 index 5d897b393..3189d7ded 100644 --- a/headers/string_view +++ b/headers/string_view @@ -39,7 +39,7 @@ public: using iterator = const_iterator; using const_reverse_iterator = std::reverse_iterator; using reverse_iterator = const_reverse_iterator; - static const size_type npos = -1; + static const size_type npos = static_cast(-1); // [string.view.cons], construct/copy @@ -191,3 +191,5 @@ operator>=(basic_string_view lhs, } // namespace std #endif // CPPREFERENCE_STDVER >= 2017 + +#endif // CPPREFERENCE_STRING_VIEW_H diff --git a/headers/tuple b/headers/tuple index 925486b2d..4fc8a8880 100644 --- a/headers/tuple +++ b/headers/tuple @@ -88,15 +88,9 @@ public: void swap(tuple& other); }; -template -class tuple_size; - template class tuple_size > : public std::integral_constant { }; -template -class tuple_element; - template class tuple_element > { typedef void type; diff --git a/headers/type_traits b/headers/type_traits index 41c6ed46a..6d8fcdeaf 100644 --- a/headers/type_traits +++ b/headers/type_traits @@ -27,7 +27,7 @@ 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 T operator()() const; }; @@ -400,9 +400,27 @@ template using underlying_type_t = int; // SIMPLIFIED typedef #endif -template class result_of { +#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/unordered_set b/headers/unordered_set index 3bfbfb1c9..51f1086da 100644 --- a/headers/unordered_set +++ b/headers/unordered_set @@ -409,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 d4b729350..d1734d60a 100644 --- a/headers/utility +++ b/headers/utility @@ -88,6 +88,7 @@ template T declval(); // SIMPLIFIED: return type #endif +#if CPPREFERENCE_STDVER >= 2011 struct piecewise_construct_t { }; constexpr piecewise_construct_t piecewise_construct; #endif @@ -213,13 +214,19 @@ 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 From 8550dad70ddd48927a2b53364949216a6898bdb0 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 27 Oct 2019 10:20:27 +0200 Subject: [PATCH 053/114] Headers: Implement --- headers/optional | 232 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 headers/optional diff --git a/headers/optional b/headers/optional new file mode 100644 index 000000000..c2437166c --- /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 From aa6840e48f984e8a659f5fa3f051db91e7f83647 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 27 Oct 2019 10:20:28 +0200 Subject: [PATCH 054/114] Headers: Implement --- headers/detail/cppreference_unspecified | 2 + headers/utility | 17 ++ headers/variant | 228 ++++++++++++++++++++++++ 3 files changed, 247 insertions(+) create mode 100644 headers/variant diff --git a/headers/detail/cppreference_unspecified b/headers/detail/cppreference_unspecified index 226d192d7..3e4476c9e 100644 --- a/headers/detail/cppreference_unspecified +++ b/headers/detail/cppreference_unspecified @@ -23,9 +23,11 @@ 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 diff --git a/headers/utility b/headers/utility index d1734d60a..56209e84f 100644 --- a/headers/utility +++ b/headers/utility @@ -93,6 +93,23 @@ 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 < diff --git a/headers/variant b/headers/variant new file mode 100644 index 000000000..fed65ff7d --- /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 From 4ce982c179854876d28c96d2727a9b93519c27d1 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Tue, 5 Nov 2019 15:59:36 +0200 Subject: [PATCH 055/114] Headers: Add string_view literals --- headers/string_view | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/headers/string_view b/headers/string_view index 3189d7ded..4bb3bb4fa 100644 --- a/headers/string_view +++ b/headers/string_view @@ -188,6 +188,23 @@ 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 From 3b8f3dd923650b1781dcfa9e57a618f9cc956503 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Tue, 5 Nov 2019 15:59:50 +0200 Subject: [PATCH 056/114] Headers: Fix add_pointer trait --- headers/type_traits | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/headers/type_traits b/headers/type_traits index 6d8fcdeaf..833efcab8 100644 --- a/headers/type_traits +++ b/headers/type_traits @@ -301,14 +301,14 @@ template struct remove_pointer { typedef T type; // SIMPLIFIED type }; template struct add_pointer { - typedef T type; // SIMPLIFIED 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 +using add_pointer_t = T*; // SIMPLIFIED typedef #endif // sign modifiers From e98d51dea90b50e37f58e931388ad4645d94d103 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 13 Nov 2019 13:38:27 +0200 Subject: [PATCH 057/114] Headers: Update string_view --- headers/detail/string_view_fwd | 35 +++++++++++ headers/string | 104 ++++++++++++++++++++++++++++++++- headers/string_view | 3 +- 3 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 headers/detail/string_view_fwd diff --git a/headers/detail/string_view_fwd b/headers/detail/string_view_fwd new file mode 100644 index 000000000..477ef6f9d --- /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/string b/headers/string index d72608490..153d33a72 100644 --- a/headers/string +++ b/headers/string @@ -26,6 +26,7 @@ #include // for std::reverse_iterator #include // for std::allocator #include +#include namespace std { @@ -165,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(); @@ -175,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); @@ -188,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); @@ -215,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(); @@ -270,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); @@ -323,6 +349,11 @@ public: basic_string& append(const basic_string& str, size_type pos, 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); @@ -348,6 +379,11 @@ public: #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, @@ -355,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 @@ -363,6 +398,14 @@ 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; @@ -382,6 +425,16 @@ public: 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, @@ -399,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); @@ -448,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; diff --git a/headers/string_view b/headers/string_view index 4bb3bb4fa..f9c0d50bb 100644 --- a/headers/string_view +++ b/headers/string_view @@ -19,10 +19,11 @@ #if CPPREFERENCE_STDVER >= 2017 #include // for std::reverse_iterator +#include namespace std { -template> +template*/> class basic_string_view { public: using traits_type = Traits; From 7915ced39fb920f3e8ee1a3a068b03f84932695b Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 13 Nov 2019 13:38:47 +0200 Subject: [PATCH 058/114] headers: Add non-simplified definition of nullptr_t --- headers/cstddef | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/headers/cstddef b/headers/cstddef index 0da058de8..c5fdececd 100644 --- a/headers/cstddef +++ b/headers/cstddef @@ -29,7 +29,13 @@ namespace std { 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 From f737355e7ca5c68f03111b14087a553b084eedf5 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Thu, 14 Nov 2019 17:06:30 +0800 Subject: [PATCH 059/114] Index: add formatting library --- index-functions-cpp.xml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 062917ddb..157a9e130 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -2089,6 +2089,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + From f5667576a5127d525cd352b404d928a1a167c2c4 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 6 Dec 2019 10:38:48 +0200 Subject: [PATCH 060/114] Headers: Add full implementation of enable_if --- headers/type_traits | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/headers/type_traits b/headers/type_traits index 833efcab8..9da0de80a 100644 --- a/headers/type_traits +++ b/headers/type_traits @@ -368,12 +368,15 @@ template using decay_t = T; // SIMPLIFIED typedef #endif -template struct enable_if { - typedef int type; // SIMPLIFIED type +template struct enable_if {}; + +template +struct enable_if { + typedef T type; }; #if CPPREFERENCE_STDVER >= 2014 -template -using enable_if_t = int; // SIMPLIFIED typedef +template +using enable_if_t = typename enable_if::type; #endif template struct conditional { From 2ed5d3091889286fe76e179a1b634d2e2e706e0e Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 6 Dec 2019 10:40:32 +0200 Subject: [PATCH 061/114] Headers: Add a way to select simplified implementation of enable_if --- headers/type_traits | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/headers/type_traits b/headers/type_traits index 9da0de80a..e6df9daa9 100644 --- a/headers/type_traits +++ b/headers/type_traits @@ -368,6 +368,18 @@ template using decay_t = T; // SIMPLIFIED typedef #endif +#if CPPREFERENCE_SIMPLIFY_TYPEDEFS + +template struct enable_if { + typedef int type; // SIMPLIFIED type +}; +#if CPPREFERENCE_STDVER >= 2014 +template +using enable_if_t = int; // SIMPLIFIED typedef +#endif + +#else + template struct enable_if {}; template @@ -379,6 +391,8 @@ template using enable_if_t = typename enable_if::type; #endif +#endif // CPPREFERENCE_SIMPLIFY_TYPEDEFS + template struct conditional { typedef int type; // SIMPLIFIED type }; From 6e7624c0f1380a53bab7311f8f1d0f9dc06fa05b Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Tue, 31 Dec 2019 05:43:12 +0200 Subject: [PATCH 062/114] Headers: Add allocator --- headers/memory | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/headers/memory b/headers/memory index 8dc1da720..a578e193f 100644 --- a/headers/memory +++ b/headers/memory @@ -417,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; @@ -463,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); From b0a8301b882e527f689a9492e88fab6b8e03af36 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 25 Mar 2020 12:42:57 +0200 Subject: [PATCH 063/114] Headers: emplace_{front,back} returns a reference from C++17 onwards --- headers/deque | 10 ++++++++-- headers/forward_list | 5 +++++ headers/list | 10 ++++++++-- headers/vector | 5 ++++- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/headers/deque b/headers/deque index 1371f1755..41757c0c2 100644 --- a/headers/deque +++ b/headers/deque @@ -186,7 +186,10 @@ public: void push_back(T&& value); #endif -#if CPPREFERENCE_STDVER>= 2011 +#if CPPREFERENCE_STDVER >= 2017 + template + reference emplace_back(Args&& ... args); +#elif CPPREFERENCE_STDVER >= 2011 template void emplace_back(Args&& ... args); #endif @@ -198,7 +201,10 @@ public: void push_front(T&& value); #endif -#if CPPREFERENCE_STDVER>= 2011 +#if CPPREFERENCE_STDVER >= 2017 + template + reference emplace_front(Args&& ... args); +#elif CPPREFERENCE_STDVER >= 2011 template void emplace_front(Args&& ... args); #endif diff --git a/headers/forward_list b/headers/forward_list index 38154dd48..ce9688232 100644 --- a/headers/forward_list +++ b/headers/forward_list @@ -129,8 +129,13 @@ public: void push_front(const T& value); void push_front(T&& value); +#if CPPREFERENCE_STDVER >= 2017 + template + reference emplace_front(Args&& ... args); +#else template void emplace_front(Args&& ... args); +#endif void pop_front(); diff --git a/headers/list b/headers/list index 6db613a5c..9391c3aaf 100644 --- a/headers/list +++ b/headers/list @@ -175,7 +175,10 @@ public: void push_back(T&& value); #endif -#if CPPREFERENCE_STDVER>= 2011 +#if CPPREFERENCE_STDVER >= 2017 + template + reference emplace_back(Args&& ... args); +#elif CPPREFERENCE_STDVER >= 2011 template void emplace_back(Args&& ... args); #endif @@ -187,7 +190,10 @@ public: void push_front(T&& value); #endif -#if CPPREFERENCE_STDVER>= 2011 +#if CPPREFERENCE_STDVER >= 2017 + template + reference emplace_front(Args&& ... args); +#elif CPPREFERENCE_STDVER >= 2011 template void emplace_front(Args&& ... args); #endif diff --git a/headers/vector b/headers/vector index 4f5810b1a..e02f352f0 100644 --- a/headers/vector +++ b/headers/vector @@ -191,7 +191,10 @@ public: void push_back(T&& value); #endif -#if CPPREFERENCE_STDVER>= 2011 +#if CPPREFERENCE_STDVER >= 2017 + template + reference emplace_back(Args&& ... args); +#elif CPPREFERENCE_STDVER >= 2011 template void emplace_back(Args&& ... args); #endif From 7ff3ae6462a4476d1db6560455090c4fc7e47dcb Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Wed, 14 Oct 2020 19:30:55 +0200 Subject: [PATCH 064/114] Preprocess: remove BuySellAds --- commands/preprocess.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/commands/preprocess.py b/commands/preprocess.py index f61f79aab..2b45ec9e4 100644 --- a/commands/preprocess.py +++ b/commands/preprocess.py @@ -317,14 +317,22 @@ def remove_google_analytics(html): el.getparent().remove(el) -# remove Carbon ads +# remove ads def remove_ads(html): + # Carbon Ads for el in html.xpath('//script[@src]'): if 'carbonads.com/carbon.js' in el.get('src'): el.getparent().remove(el) for el in html.xpath('/html/body/style'): if el.text is not None and '#carbonads' in el.text: el.getparent().remove(el) + # BuySellAds + for el in html.xpath('//script[@type]'): + if 'buysellads.com' in el.text: + el.getparent().remove(el) + for el in html.xpath('//div[@id]'): + if el.get('id').startswith('bsap_'): + el.getparent().remove(el) # remove links to file info pages (e.g. on images) From b85b4696cd8f1fe9e9da058243daea7417e2698e Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Wed, 14 Oct 2020 19:47:01 +0200 Subject: [PATCH 065/114] Preprocess: fix pylint errors This fixes a couple of errors introduced in the new pylint version. --- preprocess.py | 2 +- tests/test_preprocess.py | 2 +- tests/test_preprocess_cssless.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/preprocess.py b/preprocess.py index f3d9c5a44..76d36db0d 100755 --- a/preprocess.py +++ b/preprocess.py @@ -17,11 +17,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. -from commands import preprocess import argparse import concurrent.futures import os import shutil +from commands import preprocess def main(): diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index 523319920..c491fd028 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -24,6 +24,7 @@ import contextlib import unittest import unittest.mock +from lxml import etree from commands.preprocess import build_rename_map from commands.preprocess import convert_loader_name from commands.preprocess import has_class @@ -38,7 +39,6 @@ from commands.preprocess import transform_ranges_placeholder from commands.preprocess import trasform_relative_link from commands.preprocess import rename_files -from lxml import etree class DummyFile(object): diff --git a/tests/test_preprocess_cssless.py b/tests/test_preprocess_cssless.py index 0b9f58078..90957cf8a 100644 --- a/tests/test_preprocess_cssless.py +++ b/tests/test_preprocess_cssless.py @@ -17,6 +17,7 @@ import os import unittest +from lxml import etree from commands.preprocess_cssless import preprocess_html_merge_cssless from commands.preprocess_cssless import silence_cssutils_warnings from commands.preprocess_cssless import convert_span_tables_to_tr_td @@ -26,7 +27,6 @@ from commands.preprocess_cssless import convert_font_size_property_to_pt from commands.preprocess_cssless \ import convert_table_border_top_to_tr_background -from lxml import etree class TestPreprocessHtmlMergeCss(unittest.TestCase): From 7033bb488fefb6e8a81559d2171b18fbb622fc4e Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 15 Oct 2020 13:54:50 +0300 Subject: [PATCH 066/114] Freeze python dependencies --- requirements-ci.txt | 4 ++-- requirements.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements-ci.txt b/requirements-ci.txt index 37635354d..176dc6285 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -1,2 +1,2 @@ -pylint -flake8 +pylint==2.6.0 +flake8==3.8.4 diff --git a/requirements.txt b/requirements.txt index 62b9b76d4..cf5218a57 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -premailer -lxml +premailer==3.7.0 +lxml==4.5.2 From fcc6d5d1063ab83e8a18e84bf25233208973ab4f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 15 Oct 2020 13:56:49 +0300 Subject: [PATCH 067/114] Fix new pylint warnings --- ddg_parse_html.py | 4 ++-- index2ddg.py | 2 +- index_transform/autolinker.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ddg_parse_html.py b/ddg_parse_html.py index bf1f76ef5..1a92164a4 100644 --- a/ddg_parse_html.py +++ b/ddg_parse_html.py @@ -34,8 +34,8 @@ def get_content_el(root_el): /div[@id="content"] /div[@id="bodyContent"] /div[@class="mw-content-ltr"]''')[0] - except Exception: - raise DdgException("Could not find content element") + except Exception as e: + raise DdgException("Could not find content element") from e VERSION_C89 = 0 diff --git a/index2ddg.py b/index2ddg.py index f8c9e1210..28ff529e4 100755 --- a/index2ddg.py +++ b/index2ddg.py @@ -129,7 +129,7 @@ class Index2DuckDuckGoList(IndexTransform): def __init__(self, ident_map): self.ident_map = ident_map - super(Index2DuckDuckGoList, self).__init__(ignore_typedefs=True) + super().__init__(ignore_typedefs=True) def process_item_hook(self, el, full_name, full_link): diff --git a/index_transform/autolinker.py b/index_transform/autolinker.py index ad68c0953..350d73534 100644 --- a/index_transform/autolinker.py +++ b/index_transform/autolinker.py @@ -75,7 +75,7 @@ def process_item_hook(self, el, full_name, full_link): class Index2AutolinkerLinks(IndexTransform): def __init__(self): - super(Index2AutolinkerLinks, self).__init__() + super().__init__() self.links = [] self.curr_group = None From d8b047217546b05bc55e49c98cfd5ae525bab8a8 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Thu, 15 Oct 2020 14:05:03 +0300 Subject: [PATCH 068/114] Sort python imports --- build_link_map.py | 3 ++- commands/preprocess.py | 3 ++- commands/preprocess_cssless.py | 3 ++- ddg_parse_html.py | 1 + devhelp2qch.py | 2 ++ export.py | 2 +- fix_devhelp-links.py | 3 ++- gadgets/replace_tests_base.py | 1 + gadgets/standard_revisions_tests/base.py | 1 + gadgets/sync_tests_mwiki.py | 10 +++++----- images/math-atan2.py | 8 ++++---- images/math.py | 5 +++-- index2autolinker.py | 1 + index2browser.py | 1 + index2ddg.py | 8 +++++--- index2devhelp.py | 1 + index2doxygen-tag.py | 4 +++- index2highlight.py | 1 + index2search.py | 1 + index_transform/common.py | 1 - index_transform/devhelp.py | 1 + index_transform/doxygen_tag.py | 1 + misc/fontforge-gen.python | 5 +++-- preprocess.py | 1 + preprocess_qch.py | 1 + tests/test_devhelp.py | 1 + tests/test_devhelp_qch.py | 2 ++ tests/test_preprocess.py | 12 +++++++----- tests/test_preprocess_cssless.py | 16 +++++++++------- 29 files changed, 65 insertions(+), 35 deletions(-) diff --git a/build_link_map.py b/build_link_map.py index a0de21cb3..c5fa89092 100755 --- a/build_link_map.py +++ b/build_link_map.py @@ -21,8 +21,9 @@ # filename -> title mapping to a xml file. import fnmatch -import re import os +import re + from link_map import LinkMap diff --git a/commands/preprocess.py b/commands/preprocess.py index 2b45ec9e4..45682f54f 100644 --- a/commands/preprocess.py +++ b/commands/preprocess.py @@ -19,10 +19,11 @@ import fnmatch import io -import re import os +import re import shutil import urllib.parse + from lxml import etree diff --git a/commands/preprocess_cssless.py b/commands/preprocess_cssless.py index 8bf9142f4..e6f9e0220 100644 --- a/commands/preprocess_cssless.py +++ b/commands/preprocess_cssless.py @@ -21,10 +21,11 @@ import logging import os import warnings -from premailer import Premailer + import cssutils from lxml import etree from lxml.etree import strip_elements +from premailer import Premailer def preprocess_html_merge_cssless(src_path, dst_path): diff --git a/ddg_parse_html.py b/ddg_parse_html.py index 1a92164a4..7e30df69d 100644 --- a/ddg_parse_html.py +++ b/ddg_parse_html.py @@ -20,6 +20,7 @@ import re from copy import deepcopy + import lxml.etree as e diff --git a/devhelp2qch.py b/devhelp2qch.py index bf57ed528..44904c82a 100755 --- a/devhelp2qch.py +++ b/devhelp2qch.py @@ -19,7 +19,9 @@ import argparse + from lxml import etree + from index_transform.devhelp_qch import convert_devhelp_to_qch diff --git a/export.py b/export.py index a7a8d2cfc..b4d5b4241 100755 --- a/export.py +++ b/export.py @@ -19,9 +19,9 @@ ''' import argparse +import json import urllib.parse import urllib.request -import json def retrieve_page_names(root, ns_index): diff --git a/fix_devhelp-links.py b/fix_devhelp-links.py index 84860626d..87e71c73e 100755 --- a/fix_devhelp-links.py +++ b/fix_devhelp-links.py @@ -19,9 +19,10 @@ ''' import sys + import lxml.etree as e -from link_map import LinkMap +from link_map import LinkMap if len(sys.argv) != 3: print('''Please provide the following 2 argument: diff --git a/gadgets/replace_tests_base.py b/gadgets/replace_tests_base.py index f7322eeb6..353d927b1 100755 --- a/gadgets/replace_tests_base.py +++ b/gadgets/replace_tests_base.py @@ -24,6 +24,7 @@ import re import sys + def get_html_files(root): files = [] for dir, dirnames, filenames in os.walk(root): diff --git a/gadgets/standard_revisions_tests/base.py b/gadgets/standard_revisions_tests/base.py index b780e8d18..8b1269c84 100644 --- a/gadgets/standard_revisions_tests/base.py +++ b/gadgets/standard_revisions_tests/base.py @@ -18,6 +18,7 @@ ''' import unittest + from selenium import webdriver from selenium.webdriver.support.ui import Select diff --git a/gadgets/sync_tests_mwiki.py b/gadgets/sync_tests_mwiki.py index 9aa3fc70b..b9e13374b 100755 --- a/gadgets/sync_tests_mwiki.py +++ b/gadgets/sync_tests_mwiki.py @@ -29,17 +29,17 @@ # command line. os.environ['PYWIKIBOT2_NO_USER_CONFIG']='1' -import pywikibot -import pywikibot.config2 -import pywikibot.pagegenerators -import pywikibot.data.api - import argparse import itertools import shutil import sys import urllib +import pywikibot +import pywikibot.config2 +import pywikibot.data.api +import pywikibot.pagegenerators + SYNC_DIRECTION_UPLOAD = 1 SYNC_DIRECTION_DOWNLOAD = 2 diff --git a/images/math-atan2.py b/images/math-atan2.py index d1e02cf01..3679f4c3c 100644 --- a/images/math-atan2.py +++ b/images/math-atan2.py @@ -17,14 +17,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. +import math +import os +import pprint + import matplotlib.cm as cm import matplotlib.colors as colors import matplotlib.pyplot as plt - -import os import numpy as np -import math -import pprint font = {'family' : 'DejaVu Sans', 'weight' : 'normal', diff --git a/images/math.py b/images/math.py index 99b929e9f..6fee22734 100644 --- a/images/math.py +++ b/images/math.py @@ -16,11 +16,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. -import matplotlib.pyplot as plt import os -from numpy import * from bisect import * +import matplotlib.pyplot as plt +from numpy import * + # # DATA - array of items describing data to plot # Each item consists of the following parts diff --git a/index2autolinker.py b/index2autolinker.py index 45ebc44ba..4b18c89d0 100755 --- a/index2autolinker.py +++ b/index2autolinker.py @@ -20,6 +20,7 @@ import argparse import json + from index_transform.autolinker import Index2AutolinkerGroups from index_transform.autolinker import Index2AutolinkerLinks diff --git a/index2browser.py b/index2browser.py index 99b36225f..1f62c88e8 100755 --- a/index2browser.py +++ b/index2browser.py @@ -19,6 +19,7 @@ ''' import argparse + from index_transform.browser import Index2Browser diff --git a/index2ddg.py b/index2ddg.py index 28ff529e4..71d15ed87 100755 --- a/index2ddg.py +++ b/index2ddg.py @@ -21,15 +21,17 @@ import argparse import fnmatch import os -import sys import re +import sys import lxml.etree as e from lxml import html -from index_transform.common import IndexTransform from build_link_map import build_link_map -from ddg_parse_html import get_declarations, get_short_description, DdgException +from ddg_parse_html import DdgException +from ddg_parse_html import get_declarations +from ddg_parse_html import get_short_description +from index_transform.common import IndexTransform # Entry types # a class or struct diff --git a/index2devhelp.py b/index2devhelp.py index e69633ba7..e6332d477 100755 --- a/index2devhelp.py +++ b/index2devhelp.py @@ -19,6 +19,7 @@ ''' import argparse + from index_transform.devhelp import transform_devhelp diff --git a/index2doxygen-tag.py b/index2doxygen-tag.py index dc979fd6c..f90b89cc1 100755 --- a/index2doxygen-tag.py +++ b/index2doxygen-tag.py @@ -19,11 +19,13 @@ ''' import argparse + from lxml import etree -from link_map import LinkMap + from index_transform.doxygen_tag import Index2DoxygenTag from index_transform.doxygen_tag import Item from index_transform.doxygen_tag import print_map +from link_map import LinkMap def main(): diff --git a/index2highlight.py b/index2highlight.py index 210cd335c..d8d80558d 100755 --- a/index2highlight.py +++ b/index2highlight.py @@ -19,6 +19,7 @@ ''' import argparse + from index_transform.highlight import Index2Highlight diff --git a/index2search.py b/index2search.py index d4d6105f8..ebfcb536c 100755 --- a/index2search.py +++ b/index2search.py @@ -19,6 +19,7 @@ ''' import argparse + from index_transform.search import Index2Search diff --git a/index_transform/common.py b/index_transform/common.py index 2d163ce28..08e378f61 100755 --- a/index_transform/common.py +++ b/index_transform/common.py @@ -20,7 +20,6 @@ import lxml.etree as e - ''' This is a python script for various transformations of the index. diff --git a/index_transform/devhelp.py b/index_transform/devhelp.py index ad1546fbd..d20e8c183 100644 --- a/index_transform/devhelp.py +++ b/index_transform/devhelp.py @@ -19,6 +19,7 @@ ''' from lxml import etree + from index_transform.common import IndexTransform diff --git a/index_transform/doxygen_tag.py b/index_transform/doxygen_tag.py index 963f55112..73ade7be6 100644 --- a/index_transform/doxygen_tag.py +++ b/index_transform/doxygen_tag.py @@ -19,6 +19,7 @@ ''' from functools import total_ordering + from index_transform.common import IndexTransform from xml_utils import xml_escape diff --git a/misc/fontforge-gen.python b/misc/fontforge-gen.python index c042eecc0..ec8982f17 100644 --- a/misc/fontforge-gen.python +++ b/misc/fontforge-gen.python @@ -18,11 +18,12 @@ # along with this program. If not, see http://www.gnu.org/licenses/. -import fontforge import os -import psMat import sys +import fontforge +import psMat + inputFont = sys.argv[1] outputFont = os.path.splitext(inputFont)[0] + "Condensed80.otf" diff --git a/preprocess.py b/preprocess.py index 76d36db0d..65e73d61f 100755 --- a/preprocess.py +++ b/preprocess.py @@ -21,6 +21,7 @@ import concurrent.futures import os import shutil + from commands import preprocess diff --git a/preprocess_qch.py b/preprocess_qch.py index 26f487449..856afb57c 100755 --- a/preprocess_qch.py +++ b/preprocess_qch.py @@ -21,6 +21,7 @@ import concurrent.futures import os import shutil + from commands import preprocess_cssless diff --git a/tests/test_devhelp.py b/tests/test_devhelp.py index 365d626a0..e708a9c62 100644 --- a/tests/test_devhelp.py +++ b/tests/test_devhelp.py @@ -17,6 +17,7 @@ import os import unittest + from index_transform.devhelp import transform_devhelp diff --git a/tests/test_devhelp_qch.py b/tests/test_devhelp_qch.py index 4416f12cd..8c941ab1e 100644 --- a/tests/test_devhelp_qch.py +++ b/tests/test_devhelp_qch.py @@ -17,7 +17,9 @@ import os import unittest + from lxml import etree + from index_transform.devhelp_qch import convert_devhelp_to_qch diff --git a/tests/test_preprocess.py b/tests/test_preprocess.py index c491fd028..3c0c95259 100644 --- a/tests/test_preprocess.py +++ b/tests/test_preprocess.py @@ -18,27 +18,29 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/. +import contextlib import io import os import sys -import contextlib import unittest import unittest.mock + from lxml import etree + from commands.preprocess import build_rename_map from commands.preprocess import convert_loader_name from commands.preprocess import has_class from commands.preprocess import is_external_link from commands.preprocess import is_ranges_placeholder -from commands.preprocess import remove_noprint -from commands.preprocess import remove_see_also -from commands.preprocess import remove_google_analytics from commands.preprocess import remove_ads from commands.preprocess import remove_fileinfo +from commands.preprocess import remove_google_analytics +from commands.preprocess import remove_noprint +from commands.preprocess import remove_see_also from commands.preprocess import remove_unused_external +from commands.preprocess import rename_files from commands.preprocess import transform_ranges_placeholder from commands.preprocess import trasform_relative_link -from commands.preprocess import rename_files class DummyFile(object): diff --git a/tests/test_preprocess_cssless.py b/tests/test_preprocess_cssless.py index 90957cf8a..64864ccf2 100644 --- a/tests/test_preprocess_cssless.py +++ b/tests/test_preprocess_cssless.py @@ -17,16 +17,18 @@ import os import unittest + from lxml import etree -from commands.preprocess_cssless import preprocess_html_merge_cssless -from commands.preprocess_cssless import silence_cssutils_warnings -from commands.preprocess_cssless import convert_span_tables_to_tr_td -from commands.preprocess_cssless import convert_inline_block_elements_to_table -from commands.preprocess_cssless import convert_zero_td_width_to_nonzero + from commands.preprocess_cssless import apply_font_size from commands.preprocess_cssless import convert_font_size_property_to_pt -from commands.preprocess_cssless \ - import convert_table_border_top_to_tr_background +from commands.preprocess_cssless import convert_inline_block_elements_to_table +from commands.preprocess_cssless import convert_span_tables_to_tr_td +from commands.preprocess_cssless import \ + convert_table_border_top_to_tr_background +from commands.preprocess_cssless import convert_zero_td_width_to_nonzero +from commands.preprocess_cssless import preprocess_html_merge_cssless +from commands.preprocess_cssless import silence_cssutils_warnings class TestPreprocessHtmlMergeCss(unittest.TestCase): From 4ba2171c45a2514006903cec9e8df043ac8c4dea Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Tue, 2 Feb 2021 14:48:36 +0200 Subject: [PATCH 069/114] travis: Update python version for tests --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1ea58be4d..ca5f98594 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,8 @@ language: python # Available Python versions: # http://about.travis-ci.org/docs/user/ci-environment/#Python-VM-images python: - - "3.5" - "3.6" + - "3.7" # Dependencies installation commands install: From 979c03ce35f17db6429cebe21e4a3424eae3bd93 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Tue, 2 Feb 2021 14:51:00 +0200 Subject: [PATCH 070/114] travis: Update ubuntu distribution to bionic --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ca5f98594..f474b634d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ # Travis CI configuration file # http://about.travis-ci.org/docs/ -dist: trusty +dist: bionic language: python From ab47b315bd89279c2d8bafd7a124344de1179745 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Mon, 1 Feb 2021 23:43:05 +0800 Subject: [PATCH 071/114] Index: add interpolations & bit operations --- index-functions-cpp.xml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 157a9e130..5190b71af 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -3458,6 +3458,24 @@ + + + + + + + + + + + + + + + + + + From 8cfee077794a3f497d9ce7bb0d08274593bf0340 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Mon, 1 Feb 2021 11:25:03 +0800 Subject: [PATCH 072/114] Index: add legacy function objects and valarray members --- index-functions-cpp.xml | 162 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 153 insertions(+), 9 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 157a9e130..db454d91b 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -1970,11 +1970,32 @@ - - + + + + + + + + + + + + + + + + + + + + + + + @@ -3727,25 +3748,148 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - + + + + - + + + + + + + + + + + + + - + + + + + + + + + + + + + - + + + + + + + + + + + + + - + + + + + + + + + + + + + From 6f7815db24b1ef27afd398f067b911d57bdbc584 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Mon, 1 Feb 2021 10:18:43 +0800 Subject: [PATCH 073/114] Index: update thread support library --- index-functions-cpp.xml | 111 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 0cb51d9e3..0597b1808 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -5993,11 +5993,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6013,6 +6073,7 @@ + @@ -6021,6 +6082,7 @@ + @@ -6031,6 +6093,7 @@ + @@ -6041,6 +6104,7 @@ + @@ -6056,6 +6120,7 @@ + @@ -6079,6 +6144,11 @@ + + + + + @@ -6162,6 +6232,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6173,6 +6281,7 @@ + @@ -6213,6 +6322,7 @@ + @@ -6232,6 +6342,7 @@ + From 2bd16fa0850a4ac26705b6019f6765ca75180627 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Sun, 31 Jan 2021 23:50:46 +0800 Subject: [PATCH 074/114] Index: change "special_math" to "special_functions" --- index-functions-cpp.xml | 130 ++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 0cb51d9e3..7ca6cffc3 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -3612,71 +3612,71 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e340002f36e27755978ca30e48ebcd8777ff5a19 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Sun, 31 Jan 2021 23:27:24 +0800 Subject: [PATCH 075/114] Index: update sections for the atomic library --- index-functions-cpp.xml | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 0cb51d9e3..505649f02 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -5814,6 +5814,11 @@ + + + + + @@ -5843,6 +5848,12 @@ + + + + + + @@ -5884,8 +5895,8 @@ - - + + @@ -5893,12 +5904,32 @@ + + + + + - + + + + + + + + + + + + + + + + From 9ce29339f22afabc408269d1030daae862322bbe Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Sun, 31 Jan 2021 23:16:20 +0800 Subject: [PATCH 076/114] Index: add std::ranges algorithms --- index-functions-cpp.xml | 116 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 2 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 9055a73cd..862ab46c9 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -1074,6 +1074,24 @@ + + + + + + + + + + + + + + + + + + @@ -4563,8 +4581,7 @@ - - + @@ -4583,6 +4600,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 6dc449d823795702f78f857690865a4fde678f40 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Sun, 31 Jan 2021 22:55:58 +0800 Subject: [PATCH 077/114] Index: remove extra whitespace and remove SCNX* --- index-functions-c.xml | 37 +++++++++++-------------------------- index-functions-cpp.xml | 37 +++++++++++-------------------------- 2 files changed, 22 insertions(+), 52 deletions(-) diff --git a/index-functions-c.xml b/index-functions-c.xml index 74104616d..da9847b6a 100644 --- a/index-functions-c.xml +++ b/index-functions-c.xml @@ -125,7 +125,7 @@ - + @@ -140,7 +140,7 @@ - + @@ -155,7 +155,7 @@ - + @@ -170,7 +170,7 @@ - + @@ -185,7 +185,7 @@ - + @@ -200,7 +200,7 @@ - + @@ -215,7 +215,7 @@ - + @@ -230,7 +230,7 @@ - + @@ -245,7 +245,7 @@ - + @@ -260,7 +260,7 @@ - + @@ -275,22 +275,7 @@ - - - - - - - - - - - - - - - - + diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 9055a73cd..cca2c209d 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -137,7 +137,7 @@ - + @@ -152,7 +152,7 @@ - + @@ -167,7 +167,7 @@ - + @@ -182,7 +182,7 @@ - + @@ -197,7 +197,7 @@ - + @@ -212,7 +212,7 @@ - + @@ -227,7 +227,7 @@ - + @@ -242,7 +242,7 @@ - + @@ -257,7 +257,7 @@ - + @@ -272,7 +272,7 @@ - + @@ -287,22 +287,7 @@ - - - - - - - - - - - - - - - - + From 7793526a7767335067bf0208ce6cc8a9455bedd4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Feb 2021 12:46:49 +0000 Subject: [PATCH 078/114] Bump lxml from 4.5.2 to 4.6.2 Bumps [lxml](https://github.com/lxml/lxml) from 4.5.2 to 4.6.2. - [Release notes](https://github.com/lxml/lxml/releases) - [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt) - [Commits](https://github.com/lxml/lxml/compare/lxml-4.5.2...lxml-4.6.2) Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cf5218a57..b8ca418b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ premailer==3.7.0 -lxml==4.5.2 +lxml==4.6.2 From e89f9bad1998073f2407b2fd69c8c6fd83b542b7 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Tue, 2 Feb 2021 23:40:50 +0800 Subject: [PATCH 079/114] Index: add calendar and time zone library --- index-functions-cpp.xml | 479 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 477 insertions(+), 2 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 68862f8bf..9e95332c0 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -1613,8 +1613,11 @@ - - + + + + + @@ -1669,13 +1672,19 @@ + + + + + + @@ -1684,6 +1693,10 @@ + + + + @@ -1704,6 +1717,14 @@ + + + + + + + + @@ -1714,6 +1735,460 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 7667e3ae5d576cc94a5a389ab7ac7a9443cc91db Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Sun, 7 Feb 2021 06:16:04 +0800 Subject: [PATCH 080/114] Index: update filesystem library --- index-functions-cpp.xml | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 68862f8bf..ebf605e77 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -6495,6 +6495,8 @@ + + @@ -6573,6 +6575,7 @@ + @@ -6583,18 +6586,34 @@ + + + + + + + + + + + + + - - - - - - + + + + + + + + + @@ -6637,6 +6656,8 @@ + + @@ -7085,6 +7106,7 @@ + From be177052158e1243a0dabe5a57b59bf5754be85b Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Sun, 7 Feb 2021 06:29:04 +0800 Subject: [PATCH 081/114] Index: delete removed names --- index-functions-cpp.xml | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 68862f8bf..fe8d92d2f 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -2213,36 +2213,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - @@ -2257,7 +2233,6 @@ - @@ -2275,8 +2250,6 @@ - - @@ -2302,8 +2275,6 @@ - - @@ -3471,14 +3442,8 @@ - - - - - - From a57bab18989cf03cbd7fbcd58eb54d2b17f88940 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Thu, 11 Feb 2021 18:48:10 +0800 Subject: [PATCH 082/114] Index: add chrono literals --- index-functions-cpp.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 9e95332c0..17e789715 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -1710,6 +1710,13 @@ + + + + + + + @@ -1851,6 +1858,7 @@ + @@ -1910,6 +1918,7 @@ + From 837725a7c73c7e3ec988abd5159b5b4aaca0b2e7 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Mon, 8 Feb 2021 17:17:15 +0800 Subject: [PATCH 083/114] Index: update experimental libraries --- index-functions-cpp.xml | 275 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 263 insertions(+), 12 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 078bd6884..132d7bc7e 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -7250,6 +7250,7 @@ + @@ -7270,13 +7271,19 @@ - + + + + + + + @@ -7285,6 +7292,7 @@ + @@ -7299,16 +7307,73 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + @@ -7371,6 +7436,7 @@ + @@ -7458,6 +7524,7 @@ + @@ -7469,18 +7536,118 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -7537,6 +7704,9 @@ + + + @@ -7719,4 +7889,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 291c76363dc0f85193b64460d6f8a99adc026137 Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Mon, 8 Feb 2021 18:32:02 +0800 Subject: [PATCH 084/114] Index: add floating-point comparison functions --- index-functions-cpp.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 078bd6884..26dd081be 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -4046,6 +4046,12 @@ + + + + + + From a8dea6f4409365a9789f041f84eb6dae0fd22fff Mon Sep 17 00:00:00 2001 From: "S. B. Tam" Date: Thu, 11 Feb 2021 19:03:20 +0800 Subject: [PATCH 085/114] Index: add literal operators --- index-functions-cpp.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 078bd6884..a19170bf7 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -3016,6 +3016,8 @@ + + @@ -3076,6 +3078,8 @@ + + @@ -4214,6 +4218,9 @@ + + + From 7252902ff3cc711abf6681d64d78444279412313 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Sat, 20 Mar 2021 19:16:50 +0800 Subject: [PATCH 086/114] Index: add some protected members --- index-functions-cpp.xml | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 910a18df2..47fc60ae7 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -797,6 +797,9 @@ + + + @@ -806,6 +809,9 @@ + + + @@ -815,6 +821,10 @@ + + + + @@ -909,6 +919,7 @@ + @@ -3499,7 +3510,12 @@ - + + + + + + @@ -3556,7 +3572,12 @@ - + + + + + + @@ -3856,6 +3877,9 @@ + + + @@ -3883,6 +3907,9 @@ + + + @@ -3902,6 +3929,9 @@ + + + From 01ce1041a22447fd3378242dd20919ac7f357d21 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Sat, 20 Mar 2021 17:49:36 +0800 Subject: [PATCH 087/114] Index: mark various C++11 features as such --- index-functions-cpp.xml | 945 +++++++++++++++++++++------------------- 1 file changed, 494 insertions(+), 451 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 910a18df2..01b494035 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -28,9 +28,9 @@ - + - + @@ -442,7 +442,7 @@ - + @@ -467,133 +467,133 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -605,21 +605,21 @@ - + - + - + - + - + - + - + @@ -668,29 +668,29 @@ - + - + - + - + - + - + - + - + - + @@ -702,10 +702,10 @@ - + - - + + @@ -873,8 +873,8 @@ - - + + @@ -902,7 +902,7 @@ - + @@ -938,7 +938,9 @@ - + + + @@ -947,18 +949,19 @@ - - + + - + - + + @@ -1007,7 +1010,7 @@ - + @@ -1019,7 +1022,7 @@ - + @@ -1031,7 +1034,7 @@ - + @@ -1088,7 +1091,7 @@ - + @@ -1099,6 +1102,7 @@ + @@ -1107,12 +1111,14 @@ + - + + @@ -1145,21 +1151,25 @@ - - - - + + + + - - - - - - - + + + + + + + + + + + @@ -1173,7 +1183,7 @@ - + @@ -1186,11 +1196,11 @@ - + - + @@ -1198,39 +1208,41 @@ - + - + - - - - + + + + - + - + - + + + - - + + - + @@ -1294,30 +1306,30 @@ - - - - + + + + - + - - + + - + - + @@ -1400,7 +1412,7 @@ - + @@ -1412,10 +1424,10 @@ - - + + - + @@ -1428,12 +1440,14 @@ + + - + - + @@ -1448,12 +1462,14 @@ + + - + - + @@ -1574,10 +1590,10 @@ - - + + - + @@ -1607,7 +1623,7 @@ - + @@ -1636,9 +1652,9 @@ - + - + @@ -1687,24 +1703,24 @@ - - - - - - + + + + + + - + - + - + @@ -1717,7 +1733,7 @@ - + @@ -1732,12 +1748,12 @@ - + - + @@ -2344,34 +2360,22 @@ - - - - - - - - - - - - - + - - + + - + - + @@ -2382,19 +2386,19 @@ - + - + - + @@ -2408,11 +2412,8 @@ - - - - + @@ -2420,10 +2421,11 @@ - - + + + @@ -2478,8 +2480,16 @@ - - + + + + + + + + + + @@ -2603,6 +2613,7 @@ + @@ -2641,15 +2652,15 @@ - + - - + + - + @@ -2673,8 +2684,8 @@ - - + + @@ -2682,18 +2693,18 @@ - - - - - + + + + + - + - - - + + + @@ -2783,7 +2794,7 @@ - + @@ -2809,11 +2820,11 @@ - + - + @@ -3007,8 +3018,8 @@ - - + + @@ -3083,16 +3094,16 @@ - - - - - - - - - - + + + + + + + + + + @@ -3112,7 +3123,7 @@ - + @@ -3291,7 +3302,7 @@ - + @@ -3957,7 +3968,8 @@ - + + @@ -3997,6 +4009,7 @@ + @@ -4377,7 +4390,7 @@ - + @@ -4396,7 +4409,7 @@ - + @@ -4425,7 +4438,7 @@ - + @@ -4444,7 +4457,7 @@ - + @@ -4459,10 +4472,10 @@ - + - + @@ -4477,7 +4490,7 @@ - + @@ -4494,7 +4507,7 @@ - + @@ -4502,31 +4515,31 @@ - - - - - - - - - - + + + + + + + + + + - + - + - + @@ -4544,10 +4557,10 @@ - + - + @@ -4562,10 +4575,10 @@ - + - + @@ -4579,7 +4592,7 @@ - + @@ -4597,10 +4610,10 @@ - + - + @@ -4615,10 +4628,10 @@ - + - + @@ -4632,10 +4645,10 @@ - + - + @@ -4649,7 +4662,7 @@ - + @@ -4666,7 +4679,7 @@ - + @@ -4684,7 +4697,7 @@ - + @@ -4702,7 +4715,7 @@ - + @@ -4720,7 +4733,7 @@ - + @@ -4738,7 +4751,7 @@ - + @@ -4756,7 +4769,7 @@ - + @@ -4773,7 +4786,7 @@ - + @@ -4791,7 +4804,7 @@ - + @@ -4809,7 +4822,7 @@ - + @@ -4826,7 +4839,7 @@ - + @@ -4843,7 +4856,7 @@ - + @@ -4861,7 +4874,7 @@ - + @@ -4881,43 +4894,45 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + @@ -5524,6 +5539,7 @@ + @@ -5539,6 +5555,7 @@ + @@ -5633,8 +5650,8 @@ - - + + @@ -5650,10 +5667,10 @@ - - - - + + + + @@ -5664,11 +5681,12 @@ - - + + + - + @@ -5683,6 +5701,7 @@ + @@ -5699,8 +5718,10 @@ + + @@ -5745,11 +5766,11 @@ - - - - - + + + + + @@ -5806,7 +5827,7 @@ - + @@ -5815,7 +5836,7 @@ - + @@ -5876,6 +5897,7 @@ + @@ -5884,6 +5906,7 @@ + @@ -6199,7 +6222,7 @@ - + @@ -6212,12 +6235,16 @@ + + - - + + - + + + @@ -6225,12 +6252,12 @@ - - - - + + + + - + @@ -6257,16 +6284,16 @@ - - - - + + + + - - - + + + - + @@ -6277,12 +6304,12 @@ - - - - + + + + - + @@ -6293,18 +6320,18 @@ - - - - + + + + - + - + @@ -6319,51 +6346,52 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -6432,43 +6460,43 @@ - + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - + @@ -6490,23 +6518,31 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - + + + + @@ -6517,6 +6553,7 @@ + @@ -6550,10 +6587,12 @@ + + - + @@ -6604,10 +6643,10 @@ - - - - + + + + @@ -6639,10 +6678,12 @@ - - + + + + + - @@ -6652,7 +6693,7 @@ - + @@ -6661,7 +6702,7 @@ - + @@ -6670,7 +6711,7 @@ - + @@ -6681,7 +6722,7 @@ - + @@ -6721,15 +6762,15 @@ - - - + + + - - - + + + - + @@ -6739,7 +6780,7 @@ - + @@ -6781,10 +6822,10 @@ - - + + - + @@ -6798,7 +6839,7 @@ - + @@ -6810,14 +6851,14 @@ - + - + - + - + @@ -6849,6 +6890,8 @@ + + @@ -6860,7 +6903,7 @@ - + @@ -6875,7 +6918,7 @@ - + @@ -6888,7 +6931,7 @@ - + @@ -6900,7 +6943,7 @@ - + @@ -6916,20 +6959,20 @@ - + - + - + - + @@ -6937,9 +6980,9 @@ - + - + @@ -7051,7 +7094,7 @@ - + From c33c076afee3a9fe398ff18c967d4fdb63a9a442 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Sat, 19 Jun 2021 11:05:09 +0800 Subject: [PATCH 088/114] Index: add C++20 source_location --- index-functions-cpp.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index be58a0dbc..b4d9661c5 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -1572,6 +1572,19 @@ + + + + + + + + + + + + + From 4d71b2321fea9dddf1761a18b2109c3a7a492147 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Sat, 19 Jun 2021 11:26:53 +0800 Subject: [PATCH 089/114] Index: add C++20 coroutines --- index-functions-cpp.xml | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index be58a0dbc..9f4e52ff8 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -1587,6 +1587,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 3e223d55679b1a7017410819737e21c3732a0817 Mon Sep 17 00:00:00 2001 From: cpplearner Date: Sat, 2 Oct 2021 02:43:07 +0800 Subject: [PATCH 090/114] Index: misc fixes --- index-functions-cpp.xml | 55 +++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index be58a0dbc..88d75532d 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -458,12 +458,12 @@ - + - + @@ -924,7 +924,7 @@ - + @@ -2436,7 +2436,7 @@ - + @@ -2639,7 +2639,6 @@ - @@ -2788,7 +2787,9 @@ + + @@ -5422,6 +5423,8 @@ + + @@ -5451,6 +5454,8 @@ + + @@ -5473,84 +5478,86 @@ + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + @@ -6274,7 +6281,7 @@ - + From 6ab8a2a9482869b55da2302274cbd298f2b19420 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Dec 2021 19:48:34 +0000 Subject: [PATCH 091/114] Bump lxml from 4.6.2 to 4.6.5 Bumps [lxml](https://github.com/lxml/lxml) from 4.6.2 to 4.6.5. - [Release notes](https://github.com/lxml/lxml/releases) - [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt) - [Commits](https://github.com/lxml/lxml/compare/lxml-4.6.2...lxml-4.6.5) --- updated-dependencies: - dependency-name: lxml dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b8ca418b7..0531cca52 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ premailer==3.7.0 -lxml==4.6.2 +lxml==4.6.5 From 3d1da45cb2c6fdfb3876421bab6a122a6eeeb1e3 Mon Sep 17 00:00:00 2001 From: Peter Feichtinger Date: Mon, 7 Mar 2022 20:33:06 +0100 Subject: [PATCH 092/114] Index: fix unescaped angle bracket --- index-functions-cpp.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index-functions-cpp.xml b/index-functions-cpp.xml index 59d567f28..3cd881ccc 100644 --- a/index-functions-cpp.xml +++ b/index-functions-cpp.xml @@ -1612,7 +1612,7 @@ - + From 4fe19fccc6edf25ab839b4b11beb58ca17b2ff3f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 22 Apr 2022 15:04:22 +0300 Subject: [PATCH 093/114] headers: Add header --- headers/compare | 121 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 headers/compare diff --git a/headers/compare b/headers/compare new file mode 100644 index 000000000..66e59fc36 --- /dev/null +++ b/headers/compare @@ -0,0 +1,121 @@ +/* Copyright (C) 2022 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_COMPARE_H +#define CPPREFERENCE_COMPARE_H + +#if CPPREFERENCE_STDVER >= 2020 +namespace std { + +class partial_ordering { +public: + struct __unspec {}; + + static const partial_ordering less; + static const partial_ordering equivalent; + static const partial_ordering greater; + static const partial_ordering unordered; + + friend constexpr bool operator==(partial_ordering a, __unspec b) noexcept; + friend constexpr bool operator==(partial_ordering a, partial_ordering b) noexcept; + friend constexpr bool operator<(partial_ordering a, __unspec b) noexcept; + friend constexpr bool operator<(__unspec a, partial_ordering b) noexcept; + friend constexpr bool operator<=(partial_ordering a, __unspec b) noexcept; + friend constexpr bool operator<=(__unspec a, partial_ordering b) noexcept; + friend constexpr bool operator>(partial_ordering a, __unspec b) noexcept; + friend constexpr bool operator>(__unspec a, partial_ordering b) noexcept; + friend constexpr bool operator>=(partial_ordering a, __unspec b) noexcept; + friend constexpr bool operator>=(__unspec a, partial_ordering b) noexcept; + friend constexpr bool operator<=>(partial_ordering a, __unspec b) noexcept; + friend constexpr bool operator<=>(__unspec a, partial_ordering b) noexcept; +}; + +class weak_ordering { +public: + struct __unspec {}; + + static const weak_ordering less; + static const weak_ordering equivalent; + static const weak_ordering greater; + + constexpr operator partial_ordering() const noexcept; + + friend constexpr bool operator==(weak_ordering a, __unspec b) noexcept; + friend constexpr bool operator==(weak_ordering a, weak_ordering b) noexcept; + friend constexpr bool operator<(weak_ordering a, __unspec b) noexcept; + friend constexpr bool operator<(__unspec a, weak_ordering b) noexcept; + friend constexpr bool operator<=(weak_ordering a, __unspec b) noexcept; + friend constexpr bool operator<=(__unspec a, weak_ordering b) noexcept; + friend constexpr bool operator>(weak_ordering a, __unspec b) noexcept; + friend constexpr bool operator>(__unspec a, weak_ordering b) noexcept; + friend constexpr bool operator>=(weak_ordering a, __unspec b) noexcept; + friend constexpr bool operator>=(__unspec a, weak_ordering b) noexcept; + friend constexpr bool operator<=>(weak_ordering a, __unspec b) noexcept; + friend constexpr bool operator<=>(__unspec a, weak_ordering b) noexcept; +}; + + +class strong_ordering { +public: + struct __unspec {}; + + static const strong_ordering less; + static const strong_ordering equal; + static const strong_ordering equivalent; + static const strong_ordering greater; + + constexpr operator partial_ordering() const noexcept; + constexpr operator weak_ordering() const noexcept; + + friend constexpr bool operator==(strong_ordering a, __unspec b) noexcept; + friend constexpr bool operator==(strong_ordering a, strong_ordering b) noexcept; + friend constexpr bool operator<(strong_ordering a, __unspec b) noexcept; + friend constexpr bool operator<(__unspec a, strong_ordering b) noexcept; + friend constexpr bool operator<=(strong_ordering a, __unspec b) noexcept; + friend constexpr bool operator<=(__unspec a, strong_ordering b) noexcept; + friend constexpr bool operator>(strong_ordering a, __unspec b) noexcept; + friend constexpr bool operator>(__unspec a, strong_ordering b) noexcept; + friend constexpr bool operator>=(strong_ordering a, __unspec b) noexcept; + friend constexpr bool operator>=(__unspec a, strong_ordering b) noexcept; + friend constexpr bool operator<=>(strong_ordering a, __unspec b) noexcept; + friend constexpr bool operator<=>(__unspec a, strong_ordering b) noexcept; +}; + +constexpr bool is_eq(partial_ordering cmp) noexcept; +constexpr bool is_neq(partial_ordering cmp) noexcept; +constexpr bool is_lt(partial_ordering cmp) noexcept; +constexpr bool is_lteq(partial_ordering cmp) noexcept; +constexpr bool is_gt(partial_ordering cmp) noexcept; +constexpr bool is_gteq(partial_ordering cmp) noexcept; + +template +struct common_comparison_category { + using type = partial_ordering; // SIMPLIFIED +}; + +template +using common_comparison_category_t = typename common_comparison_category::type; + +template struct compare_three_way_result; + +template +using compare_three_way_result_t = typename compare_three_way_result::type; + +struct compare_three_way; + +} // namespace std +#endif // CPPREFERENCE_STDVER >= 2020 + +#endif // CPPREFERENCE_COMPARE_H From d729cea902435caa4282590e49e923aa82e6d6e2 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 22 Apr 2022 15:04:39 +0300 Subject: [PATCH 094/114] headers: Work around isnan being defined in math.h on certain compilers --- headers/cmath | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/headers/cmath b/headers/cmath index 567aa370b..b52b12274 100644 --- a/headers/cmath +++ b/headers/cmath @@ -37,6 +37,11 @@ typedef float float_t; typedef double double_t; #endif // CPPREFERENCE_STDVER>= 2011 +// Workaround system headers being inluded and defining isnan +#ifdef isnan +#undef isnan +#endif + float abs(float arg); double abs(double arg); long double abs(long double arg); From 65a15f618e95a234ebdc877b3fa09ad8a7e88bc9 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 23 Apr 2022 18:40:38 +0300 Subject: [PATCH 095/114] headers: Use struct for tuple_size --- headers/tuple | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headers/tuple b/headers/tuple index 4fc8a8880..607c29bd4 100644 --- a/headers/tuple +++ b/headers/tuple @@ -89,7 +89,7 @@ public: }; template -class tuple_size > : public std::integral_constant { }; +struct tuple_size > : std::integral_constant { }; template class tuple_element > { From e195685b8f46d8653b6f5b2c95e03b8eb1a9a984 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 23 Apr 2022 18:40:39 +0300 Subject: [PATCH 096/114] headers: Use struct for tuple_element --- headers/tuple | 2 +- headers/utility | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/headers/tuple b/headers/tuple index 607c29bd4..26044473a 100644 --- a/headers/tuple +++ b/headers/tuple @@ -92,7 +92,7 @@ template struct tuple_size > : std::integral_constant { }; template -class tuple_element > { +struct tuple_element > { typedef void type; }; // SIMPLIFIED diff --git a/headers/utility b/headers/utility index 56209e84f..43ddd35f5 100644 --- a/headers/utility +++ b/headers/utility @@ -232,7 +232,7 @@ void swap(pair& lhs, pair& rhs); #if CPPREFERENCE_STDVER>= 2011 template -class tuple_element; +struct tuple_element; template typename tuple_element>::type& From 6e5df5f8c9b567f9c809a4eef69c0d394ae15ec1 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 23 Apr 2022 18:40:40 +0300 Subject: [PATCH 097/114] headers: Add enough overloads of std::get to fix structured bindings --- headers/utility | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/headers/utility b/headers/utility index 43ddd35f5..63eb5f768 100644 --- a/headers/utility +++ b/headers/utility @@ -234,9 +234,27 @@ void swap(pair& lhs, pair& rhs); template struct tuple_element; +template +struct tuple_element<0, std::pair> { using type = T1; }; +template +struct tuple_element<1, std::pair> { using type = T2; }; + template typename tuple_element>::type& get(pair& p); + +template +const typename tuple_element>::type& + get(const pair& p); + +template +typename tuple_element>::type&& + get(pair&& p); + +template +const typename tuple_element>::type&& + get(const pair&& p); + // SIMPLIFIED: additional overloads omitted #endif From fe7098cfe2b4fdbd9c2dfcc9fefe5d6e759a4427 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 23 Apr 2022 18:56:04 +0300 Subject: [PATCH 098/114] headers: Properly implement tuple_element for tuple --- headers/tuple | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/headers/tuple b/headers/tuple index 26044473a..934e6aeb2 100644 --- a/headers/tuple +++ b/headers/tuple @@ -91,10 +91,15 @@ public: template struct tuple_size > : std::integral_constant { }; -template -struct tuple_element > { - typedef void type; -}; // SIMPLIFIED +template +struct tuple_element > { + using type = tuple_element; +}; + +template +struct tuple_element<0, tuple > { + typedef Type type; +}; template tuple make_tuple(Types&& ... args); From 3e2b277339dd43318fcd6fb2b1453bced61e4510 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 23 Apr 2022 18:56:37 +0300 Subject: [PATCH 099/114] headers: Add insert_or_assign and try_emplace map functions --- headers/map | 28 ++++++++++++++++++++++++++++ headers/unordered_map | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/headers/map b/headers/map index 8f8d2cbb1..7f77b82a0 100644 --- a/headers/map +++ b/headers/map @@ -179,6 +179,20 @@ public: template void insert(InputIt first, InputIt last); +#if CPPREFERENCE_STDVER >= 2017 + template + std::pair insert_or_assign(const Key& key, M&& obj); + + template + std::pair insert_or_assign(Key&& key, M&& obj); + + template + iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); + + template + iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); +#endif + #if CPPREFERENCE_STDVER>= 2011 template std::pair emplace(Args&& ... args); @@ -187,6 +201,20 @@ public: iterator emplace_hint(const_iterator hint, Args&& ... args); #endif +#if CPPREFERENCE_STDVER >= 2017 + template + std::pair try_emplace(const Key& key, Args&& ... args); + + template + std::pair try_emplace(Key&& key, Args&& ... args); + + template + std::pair try_emplace(const_iterator hint, const Key& key, Args&& ... args); + + template + std::pair try_emplace(const_iterator hint, Key&& key, Args&& ... args); +#endif + #if CPPREFERENCE_STDVER <2011 void erase(iterator pos); void erase(iterator first, iterator last); diff --git a/headers/unordered_map b/headers/unordered_map index ae667db27..93f102083 100644 --- a/headers/unordered_map +++ b/headers/unordered_map @@ -183,12 +183,40 @@ public: void insert(std::initializer_list ilist); +#if CPPREFERENCE_STDVER >= 2017 + template + std::pair insert_or_assign(const Key& key, M&& obj); + + template + std::pair insert_or_assign(Key&& key, M&& obj); + + template + iterator insert_or_assign(const_iterator hint, const Key& key, M&& obj); + + template + iterator insert_or_assign(const_iterator hint, Key&& key, M&& obj); +#endif + template std::pair emplace(Args&& ... args); template iterator emplace_hint(const_iterator hint, Args&& ... args); +#if CPPREFERENCE_STDVER >= 2017 + template + std::pair try_emplace(const Key& key, Args&& ... args); + + template + std::pair try_emplace(Key&& key, Args&& ... args); + + template + std::pair try_emplace(const_iterator hint, const Key& key, Args&& ... args); + + template + std::pair try_emplace(const_iterator hint, Key&& key, Args&& ... args); +#endif + iterator erase(const_iterator pos); iterator erase(const_iterator first, const_iterator last); size_type erase(const key_type& key); From 46672de670574b19d68bb644b9c04ec8b64b0a8d Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 11 May 2022 13:50:37 +0300 Subject: [PATCH 100/114] Headers: Use consistent declarations of templates --- headers/utility | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/headers/utility b/headers/utility index 63eb5f768..81698b5ae 100644 --- a/headers/utility +++ b/headers/utility @@ -231,7 +231,7 @@ template void swap(pair& lhs, pair& rhs); #if CPPREFERENCE_STDVER>= 2011 -template +template struct tuple_element; template @@ -260,10 +260,10 @@ const typename tuple_element>::type&& #if CPPREFERENCE_STDVER >= 2014 template -class tuple_size; +struct tuple_size; template -class tuple_size > : public std::integral_constant { }; +struct tuple_size > : public std::integral_constant { }; #endif } // namespace std From db08f7d4ca9cf65512a9612c8e77bc656dd7a405 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 11 May 2022 13:50:38 +0300 Subject: [PATCH 101/114] headers: Fix tuple_element to to make structured bindings work --- headers/tuple | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/headers/tuple b/headers/tuple index 934e6aeb2..020cf2272 100644 --- a/headers/tuple +++ b/headers/tuple @@ -91,15 +91,25 @@ public: template struct tuple_size > : std::integral_constant { }; -template -struct tuple_element > { - using type = tuple_element; +#if CPPREFERENCE_SIMPLIFY_TYPEDEFS +template +struct tuple_element > { + typedef void type; +}; +#else +template +struct tuple_element; + +template +struct tuple_element<0, tuple > { + using type = T; }; -template -struct tuple_element<0, tuple > { - typedef Type type; +template +struct tuple_element > { + using type = typename tuple_element::type; }; +#endif template tuple make_tuple(Types&& ... args); From 0478d34e620b62c04a62375b6b2949afa7137d9f Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 11 May 2022 13:50:39 +0300 Subject: [PATCH 102/114] Headers: Add std::clamp --- headers/algorithm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/headers/algorithm b/headers/algorithm index d2401ae6e..cf3fe9fcd 100644 --- a/headers/algorithm +++ b/headers/algorithm @@ -711,6 +711,13 @@ constexpr std::pair minmax_element(ForwardIt first, ForwardIt last, Compare comp); #endif +#if CPPREFERENCE_STDVER >= 2017 +template +constexpr const T& clamp(const T& v, const T& lo, const T& hi); +template +constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); +#endif + template bool lexicographical_compare(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2); From ac00c6eaeaccb50449436ebeeb3255b81cdede03 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Wed, 11 May 2022 13:50:40 +0300 Subject: [PATCH 103/114] Headers: Remove excessive spacing --- headers/algorithm | 350 ++++++++++++++++++++++----------------------- headers/codecvt | 4 +- headers/functional | 62 ++++---- headers/iterator | 102 ++++++------- headers/locale | 4 +- headers/optional | 6 +- headers/random | 328 +++++++++++++++++++++--------------------- headers/tuple | 64 ++++----- 8 files changed, 460 insertions(+), 460 deletions(-) diff --git a/headers/algorithm b/headers/algorithm index cf3fe9fcd..86a1ef42d 100644 --- a/headers/algorithm +++ b/headers/algorithm @@ -34,35 +34,35 @@ template bool none_of(InputIt first, InputIt last, UnaryPredicate p); #endif -template +template UnaryFunction for_each(InputIt first, InputIt last, UnaryFunction f); -template +template typename iterator_traits::difference_type count(InputIt first, InputIt last, const T& value); -template +template typename iterator_traits::difference_type count_if(InputIt first, InputIt last, UnaryPredicate p); #if CPPREFERENCE_STDVER >= 2020 -template +template std::pair constexpr mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2); -template +template std::pair constexpr mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p); #else -template +template std::pair mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2); -template +template std::pair mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, @@ -70,13 +70,13 @@ std::pair #endif #if CPPREFERENCE_STDVER >= 2017 -template +template std::pair mismatch(ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, InputIt2 first2); -template +template std::pair mismatch(ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, @@ -85,12 +85,12 @@ std::pair #endif #if CPPREFERENCE_STDVER >= 2014 -template +template std::pair mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2); -template +template std::pair mismatch(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, @@ -98,13 +98,13 @@ std::pair #endif #if CPPREFERENCE_STDVER >= 2017 -template +template std::pair mismatch(ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2); -template +template std::pair mismatch(ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, @@ -113,367 +113,367 @@ std::pair #endif -template +template bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2); -template +template bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p); #if CPPREFERENCE_STDVER >= 2014 -template +template bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2); -template +template bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPredicate p); #endif #if CPPREFERENCE_STDVER >= 2017 -template +template bool equal(ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, InputIt2 first2); -template +template bool equal(ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p); -template +template bool equal(ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2); -template +template bool equal(ExecutionPolicy&& policy, InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, BinaryPredicate p); #endif -template +template InputIt find(InputIt first, InputIt last, const T& value); -template +template InputIt find_if(InputIt first, InputIt last, UnaryPredicate p); #if CPPREFERENCE_STDVER >= 2011 -template +template InputIt find_if_not(InputIt first, InputIt last, UnaryPredicate q); #endif -template +template ForwardIt1 find_end(ForwardIt1 first, ForwardIt1 last, ForwardIt2 s_first, ForwardIt2 s_last); -template +template ForwardIt1 find_end(ForwardIt1 first, ForwardIt1 last, ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p); #if CPPREFERENCE_STDVER >= 2011 -template +template InputIt find_first_of(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last); -template +template InputIt find_first_of(InputIt first, InputIt last, ForwardIt s_first, ForwardIt s_last, BinaryPredicate p); #else -template +template ForwardIt1 find_first_of(ForwardIt1 first, ForwardIt1 last, ForwardIt2 s_first, ForwardIt2 s_last); -template +template ForwardIt1 find_first_of(ForwardIt1 first, ForwardIt1 last, ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p); #endif -template +template ForwardIt adjacent_find(ForwardIt first, ForwardIt last); template ForwardIt adjacent_find(ForwardIt first, ForwardIt last, BinaryPredicate p); -template +template ForwardIt1 search(ForwardIt1 first, ForwardIt1 last, ForwardIt2 s_first, ForwardIt2 s_last); -template +template ForwardIt1 search(ForwardIt1 first, ForwardIt1 last, ForwardIt2 s_first, ForwardIt2 s_last, BinaryPredicate p); -template +template ForwardIt search_n(ForwardIt first, ForwardIt last, Size count, const T& value); -template +template ForwardIt search_n(ForwardIt first, ForwardIt last, Size count, const T& value, BinaryPredicate p); -template +template OutputIt copy(InputIt first, InputIt last, OutputIt d_first); #if CPPREFERENCE_STDVER >= 2011 -template +template OutputIt copy_if(InputIt first, InputIt last, OutputIt d_first, UnaryPredicate pred); #endif #if CPPREFERENCE_STDVER >= 2011 -template +template OutputIt copy_n(InputIt first, Size count, OutputIt result); #endif -template +template BidirIt2 copy_backward(BidirIt1 first, BidirIt1 last, BidirIt2 d_last); #if CPPREFERENCE_STDVER >= 2011 -template +template OutputIt move(InputIt first, InputIt last, OutputIt d_first); #endif #if CPPREFERENCE_STDVER >= 2011 -template +template OutputIt move(InputIt first, InputIt last, OutputIt d_first); #endif -template +template void fill(ForwardIt first, ForwardIt last, const T& value); #if CPPREFERENCE_STDVER >= 2011 -template +template OutputIt fill_n(OutputIt first, Size count, const T& value); #else -template +template void fill_n(OutputIt first, Size count, const T& value); #endif -template +template OutputIt transform(InputIt first1, InputIt last1, OutputIt d_first, UnaryOperation unary_op); -template +template OutputIt transform(InputIt1 first1, InputIt1 last1, InputIt2 first2, OutputIt d_first, BinaryOperation binary_op); -template +template void generate(ForwardIt first, ForwardIt last, Generator g); #if CPPREFERENCE_STDVER >= 2011 -template +template OutputIt generate_n(OutputIt first, Size count, Generator g); #else -template +template void generate_n(OutputIt first, Size count, Generator g); #endif -template +template ForwardIt remove(ForwardIt first, ForwardIt last, const T& value); -template +template ForwardIt remove_if(ForwardIt first, ForwardIt last, UnaryPredicate p); -template +template OutputIt remove_copy(InputIt first, InputIt last, OutputIt d_first, const T& value); -template +template OutputIt remove_copy_if(InputIt first, InputIt last, OutputIt d_first, UnaryPredicate p); -template +template OutputIt remove_copy_if(InputIt first, InputIt last, OutputIt d_first, UnaryPredicate p); -template +template void replace_if(ForwardIt first, ForwardIt last, UnaryPredicate p, const T& new_value); -template +template OutputIt replace_copy(InputIt first, InputIt last, OutputIt d_first, const T& old_value, const T& new_value); -template +template OutputIt replace_copy_if(InputIt first, InputIt last, OutputIt d_first, UnaryPredicate p, const T& new_value); // defined in in C++11 #if CPPREFERENCE_STDVER >= 2011 -template +template void swap(T& a, T& b); #endif -template +template ForwardIt2 swap_ranges(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2); -template +template void iter_swap(ForwardIt1 a, ForwardIt2 b); -template +template void reverse(BidirIt first, BidirIt last); -template +template OutputIt reverse_copy(BidirIt first, BidirIt last, OutputIt d_first); #if CPPREFERENCE_STDVER >= 2011 -template +template ForwardIt rotate(ForwardIt first, ForwardIt n_first, ForwardIt last); #else -template +template void rotate(ForwardIt first, ForwardIt n_first, ForwardIt last); #endif -template +template OutputIt rotate_copy(ForwardIt first, ForwardIt n_first, ForwardIt last, OutputIt d_first); #if CPPREFERENCE_STDVER <2017 // deprecated in C++14 -template +template void random_shuffle(RandomIt first, RandomIt last); #endif #if CPPREFERENCE_STDVER <2011 -template +template void random_shuffle(RandomIt first, RandomIt last, RandomFunc&& r); #elif CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2017 // deprecated in C++14 -template +template void random_shuffle(RandomIt first, RandomIt last, RandomFunc& r); #endif #if CPPREFERENCE_STDVER >= 2011 -template +template void shuffle(RandomIt first, RandomIt last, URNG&& g); #endif -template +template ForwardIt unique(ForwardIt first, ForwardIt last); -template +template ForwardIt unique(ForwardIt first, ForwardIt last, BinaryPredicate p); -template +template OutputIt unique_copy(InputIt first, InputIt last, OutputIt d_first); -template +template OutputIt unique_copy(InputIt first, InputIt last, OutputIt d_first, BinaryPredicate p); #if CPPREFERENCE_STDVER >= 2011 -template +template bool is_partitioned(InputIt first, InputIt last, UnaryPredicate p); #endif #if CPPREFERENCE_STDVER <2011 -template +template BidirIt partition(BidirIt first, BidirIt last, UnaryPredicate p); #else -template +template ForwardIt partition(ForwardIt first, ForwardIt last, UnaryPredicate p); #endif #if CPPREFERENCE_STDVER >= 2011 template + class OutputIt2, class UnaryPredicate> std::pair partition_copy(InputIt first, InputIt last, OutputIt1 d_first_true, OutputIt2 d_first_false, UnaryPredicate p); #endif -template +template BidirIt stable_partition(BidirIt first, BidirIt last, UnaryPredicate p); #if CPPREFERENCE_STDVER >= 2011 -template +template ForwardIt partition_point(ForwardIt first, ForwardIt last, UnaryPredicate p); #endif #if CPPREFERENCE_STDVER >= 2011 -template +template bool is_sorted(ForwardIt first, ForwardIt last); -template +template bool is_sorted(ForwardIt first, ForwardIt last, Compare comp); -template +template ForwardIt is_sorted_until(ForwardIt first, ForwardIt last); -template +template ForwardIt is_sorted_until(ForwardIt first, ForwardIt last, Compare comp); #endif -template +template void sort(RandomIt first, RandomIt last); -template +template void sort(RandomIt first, RandomIt last, Compare comp); -template +template void partial_sort(RandomIt first, RandomIt middle, RandomIt last); -template +template void partial_sort(RandomIt first, RandomIt middle, RandomIt last, Compare comp); -template +template RandomIt partial_sort_copy(InputIt first, InputIt last, RandomIt d_first, RandomIt d_last); -template +template RandomIt partial_sort_copy(InputIt first, InputIt last, RandomIt d_first, RandomIt d_last, Compare comp); -template +template void stable_sort(RandomIt first, RandomIt last); -template +template void stable_sort(RandomIt first, RandomIt last, Compare comp); -template +template void nth_element(RandomIt first, RandomIt nth, RandomIt last); -template +template void nth_element(RandomIt first, RandomIt nth, RandomIt last, Compare comp); -template +template ForwardIt lower_bound(ForwardIt first, ForwardIt last, const T& value); -template +template ForwardIt lower_bound(ForwardIt first, ForwardIt last, const T& value, Compare comp); -template +template ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T& value); -template +template ForwardIt upper_bound(ForwardIt first, ForwardIt last, const T& value, Compare comp); -template +template bool binary_search(ForwardIt first, ForwardIt last, const T& value); -template +template bool binary_search(ForwardIt first, ForwardIt last, const T& value, Compare comp); -template +template std::pair equal_range(ForwardIt first, ForwardIt last, const T& value); -template +template std::pair equal_range(ForwardIt first, ForwardIt last, const T& value, Compare comp); -template +template OutputIt merge(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first); @@ -483,230 +483,230 @@ OutputIt merge(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp); -template +template void inplace_merge(BidirIt first, BidirIt middle, BidirIt last); template void inplace_merge(BidirIt first, BidirIt middle, BidirIt last, Compare comp); -template +template bool includes(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2); -template +template bool includes(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp); -template +template OutputIt set_difference(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first); template + class OutputIt, class Compare> OutputIt set_difference(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp); -template +template OutputIt set_intersection(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first); template + class OutputIt, class Compare> OutputIt set_intersection(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp); -template +template OutputIt set_symmetric_difference(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first); template + class OutputIt, class Compare> OutputIt set_symmetric_difference(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp); -template +template OutputIt set_union(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first); template + class OutputIt, class Compare> OutputIt set_union(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp); #if CPPREFERENCE_STDVER >= 2011 -template +template bool is_heap(RandomIt first, RandomIt last); -template +template bool is_heap(RandomIt first, RandomIt last, Compare comp); -template +template RandomIt is_heap_until(RandomIt first, RandomIt last); -template +template RandomIt is_heap_until(RandomIt first, RandomIt last, Compare comp); #endif -template +template void make_heap(RandomIt first, RandomIt last); -template +template void make_heap(RandomIt first, RandomIt last, Compare comp); -template +template void push_heap(RandomIt first, RandomIt last); -template +template void push_heap(RandomIt first, RandomIt last, Compare comp); -template +template void pop_heap(RandomIt first, RandomIt last); -template +template void pop_heap(RandomIt first, RandomIt last, Compare comp); -template +template void sort_heap(RandomIt first, RandomIt last); -template +template void sort_heap(RandomIt first, RandomIt last, Compare comp); #if CPPREFERENCE_STDVER <2014 -template +template const T& max(const T& a, const T& b); -template +template const T& max(const T& a, const T& b, Compare comp); #else -template +template constexpr const T& max(const T& a, const T& b); -template +template constexpr const T& max(const T& a, const T& b, Compare comp); #endif #if CPPREFERENCE_STDVER >= 2011 -template +template T max(std::initializer_list ilist); -template +template T max(std::initializer_list ilist, Compare comp); #elif CPPREFERENCE_STDVER >= 2014 -template +template constexpr T max(std::initializer_list ilist); -template +template constexpr T max(std::initializer_list ilist, Compare comp); #endif #if CPPREFERENCE_STDVER <2017 -template +template ForwardIt max_element(ForwardIt first, ForwardIt last); -template +template ForwardIt max_element(ForwardIt first, ForwardIt last, Compare cmp); #else -template +template constexpr ForwardIt max_element(ForwardIt first, ForwardIt last); -template +template constexpr ForwardIt max_element(ForwardIt first, ForwardIt last, Compare cmp); #endif #if CPPREFERENCE_STDVER >= 2014 -template +template constexpr const T& min(const T& a, const T& b); -template +template constexpr const T& min(const T& a, const T& b, Compare comp); #else -template +template const T& min(const T& a, const T& b); -template +template const T& min(const T& a, const T& b, Compare comp); #endif #if CPPREFERENCE_STDVER >= 2014 -template +template constexpr T min(std::initializer_list ilist); -template +template constexpr T min(std::initializer_list ilist, Compare comp); #elif CPPREFERENCE_STDVER >= 2011 -template +template T min(std::initializer_list ilist); -template +template T min(std::initializer_list ilist, Compare comp); #endif #if CPPREFERENCE_STDVER <2017 -template +template ForwardIt min_element(ForwardIt first, ForwardIt last); -template +template ForwardIt min_element(ForwardIt first, ForwardIt last, Compare cmp); #else -template +template constexpr ForwardIt min_element(ForwardIt first, ForwardIt last); -template +template constexpr ForwardIt min_element(ForwardIt first, ForwardIt last, Compare cmp); #endif #if CPPREFERENCE_STDVER >= 2014 -template +template constexpr std::pair minmax(const T& a, const T& b); -template +template constexpr std::pair minmax(const T& a, const T& b, Compare comp); -template +template constexpr std::pair minmax(std::initializer_list ilist); -template +template constexpr std::pair minmax(std::initializer_list ilist, Compare comp); #elif CPPREFERENCE_STDVER >= 2011 -template +template std::pair minmax(const T& a, const T& b); -template +template std::pair minmax(const T& a, const T& b, Compare comp); -template +template std::pair minmax(std::initializer_list ilist); -template +template std::pair minmax(std::initializer_list ilist, Compare comp); #endif #if CPPREFERENCE_STDVER >= 2011 && CPPREFERENCE_STDVER <2017 -template +template std::pair minmax_element(ForwardIt first, ForwardIt last); -template +template std::pair minmax_element(ForwardIt first, ForwardIt last, Compare comp); #elif CPPREFERENCE_STDVER >= 2017 -template +template constexpr std::pair minmax_element(ForwardIt first, ForwardIt last); -template +template constexpr std::pair minmax_element(ForwardIt first, ForwardIt last, Compare comp); #endif @@ -718,64 +718,64 @@ template constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); #endif -template +template bool lexicographical_compare(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2); -template +template bool lexicographical_compare(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, Compare comp); #if CPPREFERENCE_STDVER >= 2020 -template +template constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2); -template +template constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, BinaryPredicate p); #elif CPPREFERENCE_STDVER >= 2011 -template +template bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2); -template +template bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, BinaryPredicate p); #endif #if CPPREFERENCE_STDVER >= 2020 -template +template constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2); -template +template constexpr bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2, BinaryPredicate p); #elif CPPREFERENCE_STDVER >= 2011 -template +template bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2); -template +template bool is_permutation(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, ForwardIt2 last2, BinaryPredicate p); #endif -template +template bool next_permutation(BidirIt first, BidirIt last); -template +template bool next_permutation(BidirIt first, BidirIt last, Compare comp); -template +template bool prev_permutation(BidirIt first, BidirIt last); -template +template bool prev_permutation(BidirIt first, BidirIt last, Compare comp); } // namespace std diff --git a/headers/codecvt b/headers/codecvt index 0b7390501..5701fac90 100644 --- a/headers/codecvt +++ b/headers/codecvt @@ -41,7 +41,7 @@ public: template(0) > + std::codecvt_mode Mode = static_cast(0)> class codecvt_utf16 : public std::codecvt { public: explicit codecvt_utf16(std::size_t refs = 0); @@ -50,7 +50,7 @@ public: template(0) > + 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/functional b/headers/functional index 4963dfa7f..bb650b49b 100644 --- a/headers/functional +++ b/headers/functional @@ -40,26 +40,26 @@ public: function(const function& other); function(function&& other); - template + template function(F f) { (void) f; } #if CPPREFERENCE_STDVER < 2017 - template + template function(std::allocator_arg_t, const Alloc& alloc); - template + template function(std::allocator_arg_t, const Alloc& alloc, std::nullptr_t); - template + template function(std::allocator_arg_t, const Alloc& alloc, const function& other); - template + template function(std::allocator_arg_t, const Alloc& alloc, function&& other); - template + template function(std::allocator_arg_t, const Alloc& alloc, F f); #endif @@ -69,15 +69,15 @@ public: function& operator=(function&& other); function& operator=(std::nullptr_t); - template + template function& operator=(F&& f); - template + template function& operator=(std::reference_wrapper f); void swap(function& other); - template + template void assign(F&& f, const Alloc& alloc); explicit operator bool() const; @@ -86,26 +86,26 @@ public: const std::type_info& target_type() const; - template + template T* target(); - template + template const T* target() const; }; template void swap(function& lhs, function& rhs); -template +template bool operator==(const std::function& f, std::nullptr_t); -template +template bool operator==(std::nullptr_t, const std::function& f); -template +template bool operator!=(const std::function& f, std::nullptr_t); -template +template bool operator!=(std::nullptr_t, const std::function& f); class bad_function_call : public std::exception { @@ -115,13 +115,13 @@ public: // SIMPLIFIED: actual result is unspecified, std::function is only for // providing return type -template +template std::function mem_fn(R T::* pm); -template +template std::function bind(F&& f, Args&& ... args); -template +template std::function bind(F&& f, Args&& ... args); #if CPPREFERENCE_STDVER >= 2017 @@ -130,10 +130,10 @@ std::result_of_t invoke(F&& f, ArgTypes&&... args); #endif // SIMPLIFIED: the inherited type is simplified -template +template struct is_bind_expression : std::integral_constant {}; -template +template struct is_placeholder : std::integral_constant {}; namespace placeholders { // SIMPLIFIED: the actual type is unspecified @@ -167,24 +167,24 @@ public: operator T& () const; T& get() const; - template - typename std::result_of < T& (ArgTypes&& ...) >::type + template + typename std::result_of::type operator()(ArgTypes&& ... args) const; // only if T is function }; -template +template std::reference_wrapper ref(T& t); -template +template std::reference_wrapper ref(std::reference_wrapper t); template void ref(const T&&) = delete; -template +template std::reference_wrapper cref(const T& t); -template +template std::reference_wrapper cref(std::reference_wrapper t); template @@ -418,7 +418,7 @@ struct bit_not { }; #if CPPREFERENCE_STDVER <= 2020 -template +template struct unary_negate { typedef bool result_type; typedef typename Predicate::argument_type argument_type; @@ -427,7 +427,7 @@ struct unary_negate { result_type operator()(argument_type const& x) const; }; -template +template struct binary_negate { typedef bool result_type; typedef typename Predicate::first_argument_type first_argument_type; @@ -438,15 +438,15 @@ struct binary_negate { const second_argument_type& rhs) const; }; -template +template std::unary_negate not1(const Predicate& pred); -template +template std::binary_negate not2(const Predicate& pred); #endif #if CPPREFERENCE_STDVER >= 2011 -template +template struct hash { typedef Key argument_type; typedef std::size_t result_type; diff --git a/headers/iterator b/headers/iterator index 6d7d5dc90..add673bd6 100644 --- a/headers/iterator +++ b/headers/iterator @@ -108,36 +108,36 @@ protected: Iterator current; }; -template +template bool operator==(const reverse_iterator& lhs, const reverse_iterator& rhs); -template +template bool operator!=(const reverse_iterator& lhs, const reverse_iterator& rhs); -template +template bool operator<(const reverse_iterator& lhs, const reverse_iterator& rhs); -template +template bool operator<=(const reverse_iterator& lhs, const reverse_iterator& rhs); -template +template bool operator>(const reverse_iterator& lhs, const reverse_iterator& rhs); -template +template bool operator>=(const reverse_iterator& lhs, const reverse_iterator& rhs); -template +template reverse_iterator operator+(typename reverse_iterator::difference_type n, const reverse_iterator& it); -template +template typename reverse_iterator::difference_type operator-(const reverse_iterator& lhs, const reverse_iterator& rhs); @@ -183,36 +183,36 @@ public: }; -template +template bool operator==(const move_iterator& lhs, const move_iterator& rhs); -template +template bool operator!=(const move_iterator& lhs, const move_iterator& rhs); -template +template bool operator<(const move_iterator& lhs, const move_iterator& rhs); -template +template bool operator<=(const move_iterator& lhs, const move_iterator& rhs); -template +template bool operator>(const move_iterator& lhs, const move_iterator& rhs); -template +template bool operator>=(const move_iterator& lhs, const move_iterator& rhs); -template +template move_iterator operator+(typename move_iterator::difference_type n, const move_iterator& it); -template +template typename move_iterator::difference_type operator-(const move_iterator& lhs, const move_iterator& rhs); @@ -310,7 +310,7 @@ protected: template, - class Distance = std::ptrdiff_t > + class Distance = std::ptrdiff_t> class istream_iterator { // SIMPLIFIED: does not inherit iterator public: typedef CharT char_type; @@ -370,7 +370,7 @@ public: ostream_iterator& operator++(int); }; -template +template bool operator==(const ostream_iterator& lhs, const ostream_iterator& rhs); @@ -413,11 +413,11 @@ public: bool equal(const istreambuf_iterator& it) const; }; -template +template bool operator==(const istreambuf_iterator& lhs, const istreambuf_iterator& rhs); -template +template bool operator!=(const istreambuf_iterator& lhs, const istreambuf_iterator& rhs); @@ -447,125 +447,125 @@ public: }; #if CPPREFERENCE_STDVER >= 2017 -template +template constexpr std::move_iterator make_move_iterator(Iterator i); template constexpr std::reverse_iterator make_reverse_iterator(Iterator i); #elif CPPREFERENCE_STDVER >= 2014 -template +template std::move_iterator make_move_iterator(Iterator i); template std::reverse_iterator make_reverse_iterator(Iterator i); #elif CPPREFERENCE_STDVER >= 2011 -template +template std::move_iterator make_move_iterator(const Iterator& i); #endif -template +template std::front_insert_iterator front_inserter(Container& c); -template +template std::back_insert_iterator back_inserter(Container& c); -template +template std::insert_iterator inserter(Container& c, typename Container::iterator i); template void advance(InputIt& it, Distance n); -template +template typename std::iterator_traits::difference_type distance(InputIt first, InputIt last); #if CPPREFERENCE_STDVER >= 2011 -template +template ForwardIt next(ForwardIt it, typename std::iterator_traits::difference_type n = 1); -template +template BidirIt prev(BidirIt it, typename std::iterator_traits::difference_type n = 1); #endif #if CPPREFERENCE_STDVER >= 2017 -template +template constexpr auto begin(C& c) -> decltype(c.begin()); -template +template constexpr auto begin(const C& c) -> decltype(c.begin()); -template +template constexpr auto end(C& c) -> decltype(c.end()); -template +template constexpr auto end(const C& c) -> decltype(c.end()); #elif CPPREFERENCE_STDVER >= 2011 -template +template auto begin(C& c) -> decltype(c.begin()); -template +template auto begin(const C& c) -> decltype(c.begin()); -template +template auto end(C& c) -> decltype(c.end()); -template +template auto end(const C& c) -> decltype(c.end()); #endif #if CPPREFERENCE_STDVER >= 2014 -template +template constexpr T* begin(T(&array)[N]); -template +template constexpr T* end(T(&array)[N]); #elif CPPREFERENCE_STDVER >= 2011 -template +template T* begin(T(&array)[N]); -template +template T* end(T(&array)[N]); #endif #if CPPREFERENCE_STDVER >= 2014 -template +template constexpr auto cbegin(const C& c) -> decltype(std::begin(c)); -template +template constexpr auto cend(const C& c) -> decltype(std::end(c)); -template +template auto rbegin(C& c) -> decltype(c.rbegin()); -template +template auto rbegin(const C& c) -> decltype(c.rbegin()); -template +template reverse_iterator rbegin(T(&array)[N]); template reverse_iterator rbegin(std::initializer_list il); -template +template auto crbegin(const C& c) -> decltype(std::rbegin(c)); -template +template auto rend(C& c) -> decltype(c.rend()); -template +template auto rend(const C& c) -> decltype(c.rend()); -template +template reverse_iterator rend(T(&array)[N]); template reverse_iterator rend(std::initializer_list il); -template +template auto crend(const C& c) -> decltype(std::rend(c)); #endif // CPPREFERENCE_STDVER >= 2014 diff --git a/headers/locale b/headers/locale index a938d0066..6f5ccc018 100644 --- a/headers/locale +++ b/headers/locale @@ -70,7 +70,7 @@ public: bool operator==(const locale& other) const; bool operator!=(const locale& other) const; - template + template bool operator()(const basic_string& s1, const basic_string& s2) const; @@ -592,7 +592,7 @@ protected: virtual ~money_put(); }; -template +template class moneypunct : public money_base, public locale::facet { public: typedef CharT char_type; diff --git a/headers/optional b/headers/optional index c2437166c..2051f610d 100644 --- a/headers/optional +++ b/headers/optional @@ -210,13 +210,13 @@ constexpr bool operator>=(const optional& opt, const U& value); template constexpr bool operator>=(const T& value, const optional& opt); -template +template constexpr optional> make_optional(T&& value); -template +template constexpr optional make_optional(Args&&... args); -template +template constexpr optional make_optional(initializer_list il, Args&&... args); template diff --git a/headers/random b/headers/random index f405d19ba..c2e9a50c0 100644 --- a/headers/random +++ b/headers/random @@ -58,22 +58,22 @@ public: static constexpr result_type max(); }; -template +template bool operator==(const linear_congruential_engine& lhs, const linear_congruential_engine& rhs); -template +template bool operator==(const linear_congruential_engine& lhs, const linear_congruential_engine& rhs); template + class UIntType, UIntType a, UIntType c, UIntType m> std::basic_ostream& operator<<(std::basic_ostream& ost, const linear_congruential_engine& e); template + class UIntType, UIntType a, UIntType c, UIntType m> std::basic_istream& operator>>(std::basic_istream& ist, linear_congruential_engine& e); @@ -129,7 +129,7 @@ template + UIntType c, size_t l, UIntType f> bool operator==(const mersenne_twister_engine& lhs, const mersenne_twister_engine& rhs); @@ -137,7 +137,7 @@ template + UIntType c, size_t l, UIntType f> bool operator==(const mersenne_twister_engine& lhs, const mersenne_twister_engine& rhs); @@ -147,7 +147,7 @@ template + UIntType c, size_t l, UIntType f> std::basic_ostream& operator<<(std::basic_ostream& ost, const mersenne_twister_engine& e); @@ -158,7 +158,7 @@ template + UIntType c, size_t l, UIntType f> std::basic_istream& operator>>(std::basic_istream& ist, mersenne_twister_engine& e); @@ -206,22 +206,22 @@ public: static constexpr result_type max(); }; -template +template bool operator==(const subtract_with_carry_engine& lhs, const subtract_with_carry_engine& rhs); -template +template bool operator==(const subtract_with_carry_engine& lhs, const subtract_with_carry_engine& rhs); template + class UIntType, size_t w, size_t s, size_t r> std::basic_ostream& operator<<(std::basic_ostream& ost, const subtract_with_carry_engine& e); template + class UIntType, size_t w, size_t s, size_t r> std::basic_istream& operator>>(std::basic_istream& ist, subtract_with_carry_engine& e); @@ -263,22 +263,22 @@ public: static constexpr result_type max(); }; -template +template bool operator==(const discard_block_engine& lhs, const discard_block_engine& rhs); -template +template bool operator!=(const discard_block_engine& lhs, const discard_block_engine& rhs); template + class Engine, size_t p, size_t r> std::basic_ostream& operator<<(std::basic_ostream& ost, const discard_block_engine& e); template + class Engine, size_t p, size_t r> std::basic_istream& operator>>(std::basic_istream& ist, discard_block_engine& e); @@ -361,22 +361,22 @@ public: seed_seq(); seed_seq(const seed_seq&) = delete; - template + template seed_seq(InputIt begin, InputIt end); - template + template seed_seq(std::initializer_list il); - template + template void generate(RandomIt begin, RandomIt end); std::size_t size() const; - template + template void param(OutputIt dest) const; }; -template +template class uniform_int_distribution { public: typedef IntType result_type; @@ -388,10 +388,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type a() const; @@ -405,23 +405,23 @@ public: result_type max() const; }; -template +template bool operator==(const uniform_int_distribution& lhs, const uniform_int_distribution& rhs); -template +template bool operator!=(const uniform_int_distribution& lhs, const uniform_int_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const uniform_int_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, uniform_int_distribution& d); -template +template class uniform_real_distribution { public: typedef RealType result_type; @@ -432,10 +432,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type a() const; @@ -449,23 +449,23 @@ public: result_type max() const; }; -template +template bool operator==(const uniform_real_distribution& lhs, const uniform_real_distribution& rhs); -template +template bool operator!=(const uniform_real_distribution& lhs, const uniform_real_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const uniform_real_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, uniform_real_distribution& d); -template +template RealType generate_canonical(Generator& g); class bernoulli_distribution { @@ -478,10 +478,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); double p() const; @@ -507,7 +507,7 @@ template std::basic_istream& operator>>(std::basic_istream& ist, bernoulli_distribution& d); -template +template class binomial_distribution { public: typedef IntType result_type; @@ -518,10 +518,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); double p() const; @@ -535,23 +535,23 @@ public: }; -template +template bool operator==(const binomial_distribution& lhs, const binomial_distribution& rhs); -template +template bool operator!=(const binomial_distribution& lhs, const binomial_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const binomial_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, binomial_distribution& d); -template +template class negative_binomial_distribution { public: typedef IntType result_type; @@ -562,10 +562,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); double p() const; @@ -579,23 +579,23 @@ public: }; -template +template bool operator==(const negative_binomial_distribution& lhs, const negative_binomial_distribution& rhs); -template +template bool operator!=(const negative_binomial_distribution& lhs, const negative_binomial_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const negative_binomial_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, negative_binomial_distribution& d); -template +template class geometric_distribution { public: typedef IntType result_type; @@ -606,10 +606,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); double p() const; @@ -622,23 +622,23 @@ public: }; -template +template bool operator==(const geometric_distribution& lhs, const geometric_distribution& rhs); -template +template bool operator!=(const geometric_distribution& lhs, const geometric_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const geometric_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, geometric_distribution& d); -template +template class poisson_distribution { public: typedef IntType result_type; @@ -649,10 +649,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); double mean() const; @@ -665,23 +665,23 @@ public: }; -template +template bool operator==(const poisson_distribution& lhs, const poisson_distribution& rhs); -template +template bool operator!=(const poisson_distribution& lhs, const poisson_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const poisson_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, poisson_distribution& d); -template +template class exponential_distribution { public: typedef RealType result_type; @@ -692,10 +692,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type lambda() const; @@ -707,23 +707,23 @@ public: result_type max() const; }; -template +template bool operator==(const exponential_distribution& lhs, const exponential_distribution& rhs); -template +template bool operator!=(const exponential_distribution& lhs, const exponential_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const exponential_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, exponential_distribution& d); -template +template class gamma_distribution { public: typedef RealType result_type; @@ -734,10 +734,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type alpha() const; @@ -750,23 +750,23 @@ public: result_type max() const; }; -template +template bool operator==(const gamma_distribution& lhs, const gamma_distribution& rhs); -template +template bool operator!=(const gamma_distribution& lhs, const gamma_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const gamma_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, gamma_distribution& d); -template +template class weibull_distribution { public: typedef RealType result_type; @@ -777,10 +777,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type a() const; @@ -793,23 +793,23 @@ public: result_type max() const; }; -template +template bool operator==(const weibull_distribution& lhs, const weibull_distribution& rhs); -template +template bool operator!=(const weibull_distribution& lhs, const weibull_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const weibull_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, weibull_distribution& d); -template +template class extreme_value_distribution { public: typedef RealType result_type; @@ -820,10 +820,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type a() const; @@ -836,23 +836,23 @@ public: result_type max() const; }; -template +template bool operator==(const extreme_value_distribution& lhs, const extreme_value_distribution& rhs); -template +template bool operator!=(const extreme_value_distribution& lhs, const extreme_value_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const extreme_value_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, extreme_value_distribution& d); -template +template class normal_distribution { public: typedef RealType result_type; @@ -863,10 +863,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type mean() const; @@ -879,23 +879,23 @@ public: result_type max() const; }; -template +template bool operator==(const normal_distribution& lhs, const normal_distribution& rhs); -template +template bool operator!=(const normal_distribution& lhs, const normal_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const normal_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, normal_distribution& d); -template +template class lognormal_distribution { public: typedef RealType result_type; @@ -906,10 +906,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type m() const; @@ -922,23 +922,23 @@ public: result_type max() const; }; -template +template bool operator==(const lognormal_distribution& lhs, const lognormal_distribution& rhs); -template +template bool operator!=(const lognormal_distribution& lhs, const lognormal_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const lognormal_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, lognormal_distribution& d); -template +template class chi_squared_distribution { public: typedef RealType result_type; @@ -949,10 +949,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type n() const; @@ -964,23 +964,23 @@ public: result_type max() const; }; -template +template bool operator==(const chi_squared_distribution& lhs, const chi_squared_distribution& rhs); -template +template bool operator!=(const chi_squared_distribution& lhs, const chi_squared_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const chi_squared_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, chi_squared_distribution& d); -template +template class cauchy_distribution { public: typedef RealType result_type; @@ -991,10 +991,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type a() const; @@ -1007,23 +1007,23 @@ public: result_type max() const; }; -template +template bool operator==(const cauchy_distribution& lhs, const cauchy_distribution& rhs); -template +template bool operator!=(const cauchy_distribution& lhs, const cauchy_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const cauchy_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, cauchy_distribution& d); -template +template class fisher_f_distribution { public: typedef RealType result_type; @@ -1034,10 +1034,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type m() const; @@ -1050,23 +1050,23 @@ public: result_type max() const; }; -template +template bool operator==(const fisher_f_distribution& lhs, const fisher_f_distribution& rhs); -template +template bool operator!=(const fisher_f_distribution& lhs, const fisher_f_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const fisher_f_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, fisher_f_distribution& d); -template +template class student_t_distribution { public: typedef RealType result_type; @@ -1077,10 +1077,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); result_type n() const; @@ -1092,23 +1092,23 @@ public: result_type max() const; }; -template +template bool operator==(const student_t_distribution& lhs, const student_t_distribution& rhs); -template +template bool operator!=(const student_t_distribution& lhs, const student_t_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const student_t_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, student_t_distribution& d); -template +template class discrete_distribution { public: typedef IntType result_type; @@ -1116,12 +1116,12 @@ public: discrete_distribution(); - template + template discrete_distribution(InputIt first, InputIt last); discrete_distribution(std::initializer_list weights); - template + template discrete_distribution(std::size_t count, double xmin, double xmax, UnaryOperation unary_op); @@ -1129,10 +1129,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); std::vector probabilities() const; @@ -1145,23 +1145,23 @@ public: }; -template +template bool operator==(const discrete_distribution& lhs, const discrete_distribution& rhs); -template +template bool operator!=(const discrete_distribution& lhs, const discrete_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const discrete_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, discrete_distribution& d); -template +template class piecewise_constant_distribution { public: typedef RealType result_type; @@ -1169,15 +1169,15 @@ public: piecewise_constant_distribution(); - template + template piecewise_constant_distribution(InputIt1 first_i, InputIt1 last_i, InputIt2 first_w); - template + template piecewise_constant_distribution(std::initializer_list bl, UnaryOperation fw); - template + template piecewise_constant_distribution(std::size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); @@ -1186,10 +1186,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); std::vector intervals() const; @@ -1202,23 +1202,23 @@ public: result_type max() const; }; -template +template bool operator==(const piecewise_constant_distribution& lhs, const piecewise_constant_distribution& rhs); -template +template bool operator!=(const piecewise_constant_distribution& lhs, const piecewise_constant_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const piecewise_constant_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, piecewise_constant_distribution& d); -template +template class piecewise_linear_distribution { public: typedef RealType result_type; @@ -1226,15 +1226,15 @@ public: piecewise_linear_distribution(); - template + template piecewise_linear_distribution(InputIt1 first_i, InputIt1 last_i, InputIt2 first_w); - template + template piecewise_linear_distribution(std::initializer_list ilist, UnaryOperation fw); - template + template piecewise_linear_distribution(std::size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); @@ -1243,10 +1243,10 @@ public: void reset(); - template + template result_type operator()(Generator& g); - template + template result_type operator()(Generator& g, const param_type& params); std::vector intervals() const; @@ -1259,19 +1259,19 @@ public: result_type max() const; }; -template +template bool operator==(const piecewise_linear_distribution& lhs, const piecewise_linear_distribution& rhs); -template +template bool operator!=(const piecewise_linear_distribution& lhs, const piecewise_linear_distribution& rhs); -template +template std::basic_ostream& operator<<(std::basic_ostream& ost, const piecewise_linear_distribution& d); -template +template std::basic_istream& operator>>(std::basic_istream& ist, piecewise_linear_distribution& d); diff --git a/headers/tuple b/headers/tuple index 020cf2272..0e4520ee7 100644 --- a/headers/tuple +++ b/headers/tuple @@ -25,87 +25,87 @@ namespace std { -template +template class tuple { public: constexpr tuple(); - template + template explicit tuple(UTypes&& ... args); - template + template tuple(const tuple& other); template tuple(tuple&& other); - template + template tuple(const pair& p); - template + template tuple(pair&& p); tuple(const tuple& other) = default; tuple(tuple&& other) = default; - template + template tuple(std::allocator_arg_t, const Alloc& a); - template + template tuple(std::allocator_arg_t, const Alloc& a, const Types& ... args); - template + template tuple(std::allocator_arg_t, const Alloc& a, UTypes&& ... args); template tuple(std::allocator_arg_t, const Alloc& a, const tuple& other); - template + template tuple(std::allocator_arg_t, const Alloc& a, tuple&& other); - template + template tuple(std::allocator_arg_t, const Alloc& a, const pair& p); - template + template tuple(std::allocator_arg_t, const Alloc& a, pair&& p); - template + template tuple(std::allocator_arg_t, const Alloc& a, const tuple& other); - template + template tuple(std::allocator_arg_t, const Alloc& a, tuple&& other); tuple& operator=(const tuple& other); tuple& operator=(tuple&& other); - template + template tuple& operator=(const tuple& other); - template + template tuple& operator=(tuple&& other); - template + template tuple& operator=(const pair& p); - template + template tuple& operator=(pair&& p); void swap(tuple& other); }; -template +template struct tuple_size > : std::integral_constant { }; #if CPPREFERENCE_SIMPLIFY_TYPEDEFS -template +template struct tuple_element > { typedef void type; }; #else -template +template struct tuple_element; -template +template struct tuple_element<0, tuple > { using type = T; }; -template +template struct tuple_element > { using type = typename tuple_element::type; }; @@ -123,38 +123,38 @@ tuple forward_as_tuple(Types&& ... args); template std::tuple tuple_cat(Tuples&& ... args); -template +template typename std::tuple_element >::type& get(tuple& t); -template +template typename std::tuple_element >::type&& get(tuple&& t); -template +template typename std::tuple_element >::type const& get(const tuple& t); -template +template bool operator==(const tuple& lhs, const tuple& rhs); -template +template bool operator!=(const tuple& lhs, const tuple& rhs); -template +template bool operator<(const tuple& lhs, const tuple& rhs); -template +template bool operator<=(const tuple& lhs, const tuple& rhs); -template +template bool operator>(const tuple& lhs, const tuple& rhs); -template +template bool operator>=(const tuple& lhs, const tuple& rhs); -template +template void swap(tuple& lhs, tuple& rhs); const void* ignore; // SIMPLIFIED From bf93a5190d8ddb56112494c2956d72b66742b7e3 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 3 Jul 2022 22:24:49 +0300 Subject: [PATCH 104/114] Headers: Add some C++20 additions to --- headers/chrono | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/headers/chrono b/headers/chrono index 874ca9af7..e701d6156 100644 --- a/headers/chrono +++ b/headers/chrono @@ -19,6 +19,8 @@ #if CPPREFERENCE_STDVER>= 2011 #include #include // for time_t +#include +#include namespace std { namespace chrono { @@ -133,6 +135,12 @@ typedef duration milliseconds; typedef duration seconds; typedef duration> minutes; typedef duration> hours; +#if CPPREFERENCE_STDVER >= 2020 +using days = duration>; +using weeks = duration>; +using months = duration>; +using years = duration>; +#endif template struct treat_as_floating_point : std::is_floating_point {}; @@ -251,6 +259,26 @@ public: static std::chrono::system_clock::time_point from_time_t(std::time_t t); }; +#if CPPREFERENCE_STDVER >= 2020 +template +using sys_time = time_point; + +using sys_seconds = sys_time; +using sys_days = sys_time; + +template > +basic_istream& + from_stream(basic_istream& is, const CharT* fmt, + sys_time& time_point, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + +template +basic_ostream& + operator<<(basic_ostream& os, + const sys_time& time_point); +#endif + class steady_clock { public: typedef int rep; // SIMPLIFIED: actually unspecified @@ -275,6 +303,82 @@ public: static std::chrono::time_point now(); }; +#if CPPREFERENCE_STDVER >= 2020 +class utc_clock { +public: + using rep = int; // SIMPLIFIED: actually unspecified + using period = ratio<1>; // SIMPLIFIED: actually unspecified + using duration = std::chrono::duration; + using time_point = std::chrono::time_point; + + static time_point now(); + + template + static sys_time> + to_sys(const std::chrono::time_point& t); + + template + static std::chrono::time_point> + from_sys(const sys_time& t); +}; + +template +using utc_time = time_point; + +using utc_seconds = utc_time; + +template > +basic_istream& + from_stream(basic_istream& is, const CharT* fmt, + utc_time& time_point, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + +template +basic_ostream& + operator<<(basic_ostream& os, const chrono::utc_time& time_point); + +class file_clock { +public: + using rep = int; // SIMPLIFIED: actually unspecified + using period = std::ratio<1>; // SIMPLIFIED: actually unspecified + using duration = duration; + using time_point = time_point; + + static time_point now(); + + template + static sys_time> + to_sys(const std::chrono::time_point& t); + + template + static std::chrono::time_point> + from_sys(const sys_time& t); + + template + static utc_time> + to_utc(const std::chrono::time_point& t); + + template + static std::chrono::time_point> + from_utc(const utc_time& t); +}; + +template +using file_time = time_point; + +template > +basic_istream& + from_stream(basic_istream& is, const CharT* fmt, + file_time& time_point, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + +template +basic_ostream& + operator<<(basic_ostream& os, const file_time& time_point); +#endif + } // namespace chrono } // namespace std From 846d4802e2fdb8c1d88ac5e47d820235ba45b6c1 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 3 Jul 2022 22:24:50 +0300 Subject: [PATCH 105/114] Headers: Add std::u8string --- headers/string | 3 +++ 1 file changed, 3 insertions(+) diff --git a/headers/string b/headers/string index 153d33a72..e76f7235b 100644 --- a/headers/string +++ b/headers/string @@ -588,6 +588,9 @@ typedef std::basic_string wstring; typedef std::basic_string u16string; typedef std::basic_string u32string; #endif +#if CPPREFERENCE_STDVER >= 2020 +using u8string = std::basic_string; +#endif template basic_string From 661959aba7fe3acc69b0896d6969a6354775423d Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 3 Jul 2022 22:24:51 +0300 Subject: [PATCH 106/114] Headers: Add header --- headers/filesystem | 593 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 593 insertions(+) create mode 100644 headers/filesystem diff --git a/headers/filesystem b/headers/filesystem new file mode 100644 index 000000000..f71dff866 --- /dev/null +++ b/headers/filesystem @@ -0,0 +1,593 @@ +/* Copyright (C) 2022 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_FILESYSTEM_H +#define CPPREFERENCE_FILESYSTEM_H + +#if CPPREFERENCE_STDVER >= 2017 + +#include +#include +#include +#include +#include + +namespace std::filesystem { + +enum class file_type { + none, + not_found, + regular, + directory, + symlink, + block, + character, + fifo, + socket, + unknown +}; + +enum class perms { + none, + owner_read, + owner_write, + owner_exec, + owner_all, + group_read, + group_write, + group_exec, + group_all, + others_read, + others_write, + others_exec, + others_all, + all, + set_uid, + set_gid, + sticky_bit, + mask, + unknown, +}; + +enum class perm_options { + replace, + add, + remove, + nofollow +}; + +enum class copy_options { + none, + skip_existing, + overwrite_existing, + update_existing, + recursive, + copy_symlinks, + skip_symlinks, + directories_only, + create_symlinks, + create_hard_links, +}; + +enum class directory_options { + none, + follow_directory_symlink, + skip_permission_denied, +}; + +class path { +public: + using value_type = char; // SIMPLIFIED, actually implementation-dependent + using string_type = basic_string; + static constexpr value_type preferred_separator = '/'; + + enum format { + native_format, + generic_format, + auto_format + }; + + path() noexcept; + path(const path& other); + path(path&& other) noexcept; + path(string_type&& source, format fmt = auto_format); + + template + path(const Source& source, format fmt = auto_format); + + template + path(InputIt first, InputIt last, format fmt = auto_format); + + template + path(const Source& source, const locale& loc, format fmt = auto_format); + + template + path(InputIt first, InputIt last, const locale& loc, format fmt = auto_format); + + ~path(); + + path& operator=(const path& other); + path& operator=(path&& other) noexcept; + path& operator=(string_type&& source); + + path& assign(string_type&& source); + + template + path& operator=(const Source& source); + + template + path& assign(const Source& source); + + template + path& assign(InputIt first, InputIt last); + + path& operator/=(const path& p); + + template + path& operator/=(const Source& source); + + template + path& append(const Source& source); + + template + path& append(InputIt first, InputIt last); + + path& operator+=(const path& x); + path& operator+=(const string_type& x); + path& operator+=(basic_string_view x); + path& operator+=(const value_type* x); + path& operator+=(value_type x); + + template + path& operator+=(const Source& x); + + template + path& operator+=(ECharT x); + + template + path& concat(const Source& x); + + template + path& concat(InputIt first, InputIt last); + + void clear() noexcept; + path& make_preferred(); + path& remove_filename(); + path& replace_filename(const path& replacement); + path& replace_extension(const path& replacement = path()); + void swap(path& rhs) noexcept; + + const string_type& native() const noexcept; + const value_type* c_str() const noexcept; + operator string_type() const; + + template, + class Allocator = allocator> + basic_string + string(const Allocator& a = Allocator()) const; + + std::string string() const; + std::wstring wstring() const; +#if CPPREFERENCE_STDVER >= 2020 + std::u8string u8string() const; +#endif + std::u16string u16string() const; + std::u32string u32string() const; + + // generic format observers + template, + class Allocator = allocator> + basic_string + generic_string(const Allocator& a = Allocator()) const; + + std::string generic_string() const; + std::wstring generic_wstring() const; +#if CPPREFERENCE_STDVER >= 2020 + std::u8string generic_u8string() const; +#endif + std::u16string generic_u16string() const; + std::u32string generic_u32string() const; + + int compare(const path& p) const noexcept; + int compare(const string_type& s) const; + int compare(basic_string_view s) const; + int compare(const value_type* s) const; + + path root_name() const; + path root_directory() const; + path root_path() const; + path relative_path() const; + path parent_path() const; + path filename() const; + path stem() const; + path extension() const; + + [[nodiscard]] bool empty() const noexcept; + bool has_root_name() const; + bool has_root_directory() const; + bool has_root_path() const; + bool has_relative_path() const; + bool has_parent_path() const; + bool has_filename() const; + bool has_stem() const; + bool has_extension() const; + bool is_absolute() const; + bool is_relative() const; + + path lexically_normal() const; + path lexically_relative(const path& base) const; + path lexically_proximate(const path& base) const; + + class iterator; + using const_iterator = iterator; + + iterator begin() const; + iterator end() const; + +#if CPPREFERENCE_STDVER >= 2020 + friend strong_ordering operator<=>(const path& lhs, const path& rhs) noexcept; +#else + friend bool operator==(const path& lhs, const path& rhs) noexcept; + friend bool operator!=(const path& lhs, const path& rhs) noexcept; + friend bool operator>(const path& lhs, const path& rhs) noexcept; + friend bool operator>=(const path& lhs, const path& rhs) noexcept; + friend bool operator<(const path& lhs, const path& rhs) noexcept; + friend bool operator<=(const path& lhs, const path& rhs) noexcept; +#endif + friend path operator/(const path& lhs, const path& rhs); +}; + +void swap(path& lhs, path& rhs) noexcept; +size_t hash_value(const path& p) noexcept; + +// deprecated +template +path u8path(const Source& source); + +template +path u8path(InputIt first, InputIt last); + +template +basic_ostream& + operator<<(basic_ostream& os, const path& p); + +template +basic_istream& + operator>>(basic_istream& is, path& p); + +class filesystem_error : public system_error { +public: + filesystem_error(const string& what, error_code ec); + filesystem_error(const string& what, const path& path1, error_code ec); + filesystem_error(const string& what_arg, const path& path1, const path& path2, error_code ec); + + const path& path1() const noexcept; + const path& path2() const noexcept; + const char* what() const noexcept override; +}; + +class file_status { +public: + file_status() noexcept; + explicit file_status(file_type ft, + perms prms = perms::unknown) noexcept; + + file_status(const file_status& other) noexcept = default; + file_status(file_status&& other) noexcept = default; + ~file_status(); + + file_status& operator=(const file_status& other) noexcept = default; + file_status& operator=(file_status&& other) noexcept = default; + + void type(file_type ft) noexcept; + void permissions(perms prms) noexcept; + + file_type type() const noexcept; + perms permissions() const noexcept; + +}; + +bool operator==(const file_status& lhs, const file_status& rhs) noexcept; + +using file_time_type = chrono::time_point; + +class directory_entry { +public: + // constructors and destructor + directory_entry() noexcept = default; + directory_entry(const directory_entry& other) = default; + directory_entry(directory_entry&& other) noexcept = default; + + explicit directory_entry(const filesystem::path& p); + + directory_entry(const filesystem::path& p, error_code& ec); + ~directory_entry(); + + directory_entry& operator=(const directory_entry&) = default; + directory_entry& operator=(directory_entry&&) noexcept = default; + + void assign(const filesystem::path& p); + void assign(const filesystem::path& p, error_code& ec); + void replace_filename(const filesystem::path& p); + void replace_filename(const filesystem::path& p, error_code& ec); + void refresh(); + void refresh(error_code& ec) noexcept; + + const filesystem::path& path() const noexcept; + operator const filesystem::path&() const noexcept; + bool exists() const; + bool exists(error_code& ec) const noexcept; + bool is_block_file() const; + bool is_block_file(error_code& ec) const noexcept; + bool is_character_file() const; + bool is_character_file(error_code& ec) const noexcept; + bool is_directory() const; + bool is_directory(error_code& ec) const noexcept; + bool is_fifo() const; + bool is_fifo(error_code& ec) const noexcept; + bool is_other() const; + bool is_other(error_code& ec) const noexcept; + bool is_regular_file() const; + bool is_regular_file(error_code& ec) const noexcept; + bool is_socket() const; + bool is_socket(error_code& ec) const noexcept; + bool is_symlink() const; + bool is_symlink(error_code& ec) const noexcept; + uintmax_t file_size() const; + uintmax_t file_size(error_code& ec) const noexcept; + uintmax_t hard_link_count() const; + uintmax_t hard_link_count(error_code& ec) const noexcept; + file_time_type last_write_time() const; + file_time_type last_write_time(error_code& ec) const noexcept; + file_status status() const; + file_status status(error_code& ec) const noexcept; + file_status symlink_status() const; + file_status symlink_status(error_code& ec) const noexcept; + + bool operator==(const directory_entry& rhs) const noexcept; + auto operator<=>const directory_entry& rhs) const noexcept = default; +}; + +template +basic_ostream& + operator<<(basic_ostream& os, const directory_entry& d); + + +class directory_iterator { +public: + using iterator_category = input_iterator_tag; + using value_type = directory_entry; + using difference_type = ptrdiff_t; + using pointer = const directory_entry*; + using reference = const directory_entry&; + + directory_iterator() noexcept; + explicit directory_iterator(const path& p); + directory_iterator(const path& p, directory_options options); + directory_iterator(const path& p, error_code& ec); + directory_iterator(const path& p, directory_options options, error_code& ec); + directory_iterator(const directory_iterator& other); + directory_iterator(directory_iterator&& other) noexcept; + ~directory_iterator(); + + directory_iterator& operator=(const directory_iterator& other); + directory_iterator& operator=(directory_iterator&& other) noexcept; + + const directory_entry& operator*() const; + const directory_entry* operator->() const; + directory_iterator& operator++(); + directory_iterator& increment(error_code& ec); +}; + +directory_iterator begin(directory_iterator iter) noexcept; +directory_iterator end(directory_iterator) noexcept; + +class recursive_directory_iterator { +public: + using iterator_category = input_iterator_tag; + using value_type = directory_entry; + using difference_type = ptrdiff_t; + using pointer = const directory_entry*; + using reference = const directory_entry&; + + recursive_directory_iterator() noexcept; + explicit recursive_directory_iterator(const path& p); + recursive_directory_iterator(const path& p, directory_options options); + recursive_directory_iterator(const path& p, directory_options options, error_code& ec); + recursive_directory_iterator(const path& p, error_code& ec); + recursive_directory_iterator(const recursive_directory_iterator& other); + recursive_directory_iterator(recursive_directory_iterator&& other) noexcept; + ~recursive_directory_iterator(); + + recursive_directory_iterator& operator=(const recursive_directory_iterator& other); + recursive_directory_iterator& operator=(recursive_directory_iterator&& other) noexcept; + + directory_options options() const; + int depth() const; + bool recursion_pending() const; + + const directory_entry& operator*() const; + const directory_entry* operator->() const; + + recursive_directory_iterator& operator++(); + recursive_directory_iterator& increment(error_code& ec); + + void pop(); + void pop(error_code& ec); + void disable_recursion_pending(); +}; + +recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; +recursive_directory_iterator end(recursive_directory_iterator) noexcept; + +struct space_info { + uintmax_t capacity; + uintmax_t free; + uintmax_t available; + friend bool operator==(const space_info&, const space_info&); +}; + +path absolute(const path& p); +path absolute(const path& p, error_code& ec); + +path canonical(const path& p); +path canonical(const path& p, error_code& ec); + +void copy(const path& from, const path& to); +void copy(const path& from, const path& to, error_code& ec); +void copy(const path& from, const path& to, copy_options options); +void copy(const path& from, const path& to, copy_options options, + error_code& ec); + +bool copy_file(const path& from, const path& to); +bool copy_file(const path& from, const path& to, error_code& ec); +bool copy_file(const path& from, const path& to, copy_options option); +bool copy_file(const path& from, const path& to, copy_options option, + error_code& ec); + +void copy_symlink(const path& existing_symlink, const path& new_symlink); +void copy_symlink(const path& existing_symlink, const path& new_symlink, + error_code& ec) noexcept; + +bool create_directories(const path& p); +bool create_directories(const path& p, error_code& ec); + +bool create_directory(const path& p); +bool create_directory(const path& p, error_code& ec) noexcept; + +bool create_directory(const path& p, const path& attributes); +bool create_directory(const path& p, const path& attributes, + error_code& ec) noexcept; + +void create_directory_symlink(const path& to, const path& new_symlink); +void create_directory_symlink(const path& to, const path& new_symlink, + error_code& ec) noexcept; + +void create_hard_link(const path& to, const path& new_hard_link); +void create_hard_link(const path& to, const path& new_hard_link, + error_code& ec) noexcept; + +void create_symlink(const path& to, const path& new_symlink); +void create_symlink(const path& to, const path& new_symlink, + error_code& ec) noexcept; + +path current_path(); +path current_path(error_code& ec); +void current_path(const path& p); +void current_path(const path& p, error_code& ec) noexcept; + +bool equivalent(const path& p1, const path& p2); +bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept; + +bool exists(file_status s) noexcept; +bool exists(const path& p); +bool exists(const path& p, error_code& ec) noexcept; + +uintmax_t file_size(const path& p); +uintmax_t file_size(const path& p, error_code& ec) noexcept; + +uintmax_t hard_link_count(const path& p); +uintmax_t hard_link_count(const path& p, error_code& ec) noexcept; + +bool is_block_file(file_status s) noexcept; +bool is_block_file(const path& p); +bool is_block_file(const path& p, error_code& ec) noexcept; + +bool is_character_file(file_status s) noexcept; +bool is_character_file(const path& p); +bool is_character_file(const path& p, error_code& ec) noexcept; + +bool is_directory(file_status s) noexcept; +bool is_directory(const path& p); +bool is_directory(const path& p, error_code& ec) noexcept; + +bool is_empty(const path& p); +bool is_empty(const path& p, error_code& ec); + +bool is_fifo(file_status s) noexcept; +bool is_fifo(const path& p); +bool is_fifo(const path& p, error_code& ec) noexcept; + +bool is_other(file_status s) noexcept; +bool is_other(const path& p); +bool is_other(const path& p, error_code& ec) noexcept; + +bool is_regular_file(file_status s) noexcept; +bool is_regular_file(const path& p); +bool is_regular_file(const path& p, error_code& ec) noexcept; + +bool is_socket(file_status s) noexcept; +bool is_socket(const path& p); +bool is_socket(const path& p, error_code& ec) noexcept; + +bool is_symlink(file_status s) noexcept; +bool is_symlink(const path& p); +bool is_symlink(const path& p, error_code& ec) noexcept; + +file_time_type last_write_time(const path& p); +file_time_type last_write_time(const path& p, error_code& ec) noexcept; +void last_write_time(const path& p, file_time_type new_time); +void last_write_time(const path& p, file_time_type new_time, + error_code& ec) noexcept; + +void permissions(const path& p, perms prms, perm_options opts=perm_options::replace); +void permissions(const path& p, perms prms, error_code& ec) noexcept; +void permissions(const path& p, perms prms, perm_options opts, error_code& ec); + +path proximate(const path& p, error_code& ec); +path proximate(const path& p, const path& base = current_path()); +path proximate(const path& p, const path& base, error_code& ec); + +path read_symlink(const path& p); +path read_symlink(const path& p, error_code& ec); + +path relative(const path& p, error_code& ec); +path relative(const path& p, const path& base = current_path()); +path relative(const path& p, const path& base, error_code& ec); + +bool remove(const path& p); +bool remove(const path& p, error_code& ec) noexcept; + +uintmax_t remove_all(const path& p); +uintmax_t remove_all(const path& p, error_code& ec); + +void rename(const path& from, const path& to); +void rename(const path& from, const path& to, error_code& ec) noexcept; + +void resize_file(const path& p, uintmax_t size); +void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept; + +space_info space(const path& p); +space_info space(const path& p, error_code& ec) noexcept; + +file_status status(const path& p); +file_status status(const path& p, error_code& ec) noexcept; + +bool status_known(file_status s) noexcept; + +file_status symlink_status(const path& p); +file_status symlink_status(const path& p, error_code& ec) noexcept; + +path temp_directory_path(); +path temp_directory_path(error_code& ec); + +path weakly_canonical(const path& p); +path weakly_canonical(const path& p, error_code& ec); + +} // namespace std::filesystem + +#endif // if CPPREFERENCE_STDVER >= 2017 + +#endif // CPPREFERENCE_FILESYSTEM_H From 045fae8de35f81038fb7e83def6d61a5c22a3bcc Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 3 Jul 2022 22:24:52 +0300 Subject: [PATCH 107/114] Headers: Add non-simplified std::remove_reference --- headers/type_traits | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/headers/type_traits b/headers/type_traits index e6df9daa9..acb197287 100644 --- a/headers/type_traits +++ b/headers/type_traits @@ -278,8 +278,15 @@ using add_volatile_t = T; // SIMPLIFIED typedef // references template struct remove_reference { - typedef T type; // SIMPLIFIED type + typedef T type; +}; +template struct remove_reference { + typedef T type; }; +template struct remove_reference { + typedef T type; +}; + template struct add_lvalue_reference { typedef T type; // SIMPLIFIED type }; From a843a8ea91422445863db727f7bc60ccb526d806 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sun, 3 Jul 2022 22:24:53 +0300 Subject: [PATCH 108/114] Headers: Add non-simplified std::move --- headers/utility | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/headers/utility b/headers/utility index 81698b5ae..55dd9b965 100644 --- a/headers/utility +++ b/headers/utility @@ -69,10 +69,19 @@ T&& forward(typename std::remove_reference::type&& t); #if CPPREFERENCE_STDVER >= 2014 template -constexpr T&& move(T&& t); // SIMPLIFIED: return type +#if CPPREFERENCE_SIMPLIFY_TYPEDEFS +constexpr T&& move(T&& t); +#else +constexpr typename remove_reference::type&& move(T&& t); +#endif #elif CPPREFERENCE_STDVER >= 2011 +#if CPPREFERENCE_SIMPLIFY_TYPEDEFS template -T&& move(T&& t); // SIMPLIFIED: return type +T&& move(T&& t); +#else +template +typename remove_reference::type&& move(T&& t); +#endif #endif #if CPPREFERENCE_STDVER >= 2014 From 17cd9f1ce0d37e37ccc84a8e9dbcd7ddd662d185 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Jul 2022 21:39:13 +0000 Subject: [PATCH 109/114] Bump lxml from 4.6.5 to 4.9.1 Bumps [lxml](https://github.com/lxml/lxml) from 4.6.5 to 4.9.1. - [Release notes](https://github.com/lxml/lxml/releases) - [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt) - [Commits](https://github.com/lxml/lxml/compare/lxml-4.6.5...lxml-4.9.1) --- updated-dependencies: - dependency-name: lxml dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0531cca52..3731ef5df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ premailer==3.7.0 -lxml==4.6.5 +lxml==4.9.1 From c852a32a08e29408772924da9949183daa1e4d31 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 31 Oct 2022 22:34:27 +0200 Subject: [PATCH 110/114] Headers: Put integer typedefs to global namespace too by default --- headers/README.md | 4 ++++ headers/cstddef | 6 ++++++ headers/cstdint | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/headers/README.md b/headers/README.md index 64c605b54..e44dd4452 100644 --- a/headers/README.md +++ b/headers/README.md @@ -32,6 +32,10 @@ macros: values are 1998, 2003, 2011, 2014, 2017 which correspond to the respective C++ standards. + - CPPREFERENCE_INT_TYPES_ONLY_IN_STD: non-zero value results in integer types + such as std::size_t, std::uint16_t and so on being defined only in std + namespace. + - 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. diff --git a/headers/cstddef b/headers/cstddef index c5fdececd..81a1bc751 100644 --- a/headers/cstddef +++ b/headers/cstddef @@ -38,4 +38,10 @@ typedef decltype(nullptr) nullptr_t; #endif } // namespace std +#if !CPPREFERENCE_INT_TYPES_ONLY_IN_STD +using std::ptrdiff_t; +using std::size_t; +using std::max_align_t; +#endif // !CPPREFERENCE_INT_TYPES_ONLY_IN_STD + #endif // CPPREFERENCE_CSTDDEF_H diff --git a/headers/cstdint b/headers/cstdint index 0e84cb082..d97d2b671 100644 --- a/headers/cstdint +++ b/headers/cstdint @@ -142,4 +142,36 @@ typedef unsigned long long uintmax_t; } // namespace std #endif // CPPREFERENCE_STDVER>= 2011 +#if !CPPREFERENCE_INT_TYPES_ONLY_IN_STD +using std::int8_t; +using std::int16_t; +using std::int32_t; +using std::int64_t; +using std::uint8_t; +using std::uint16_t; +using std::uint32_t; +using std::uint64_t; +using std::int_fast8_t; +using std::int_fast16_t; +using std::int_fast32_t; +using std::int_fast64_t; +using std::uint_fast8_t; +using std::uint_fast16_t; +using std::uint_fast32_t; +using std::uint_fast64_t; +using std::int_least8_t; +using std::int_least16_t; +using std::int_least32_t; +using std::int_least64_t; +using std::uint_least8_t; +using std::uint_least16_t; +using std::uint_least32_t; +using std::uint_least64_t; + +using std::intptr_t; +using std::uintptr_t; +using std::intmax_t; +using std::uintmax_t; +#endif + #endif // CPPREFERENCE_CSTDINT_H From 8d75ef0062e43278b2c3212eb5ccd4cbf2f6fceb Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 4 Feb 2023 18:13:21 +0200 Subject: [PATCH 111/114] Headers: Add C++17 std::basic_string::data() overload --- headers/string | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/headers/string b/headers/string index e76f7235b..a3c9c082b 100644 --- a/headers/string +++ b/headers/string @@ -242,7 +242,12 @@ public: CharT& back(); const CharT& back() const; #endif + const CharT* data() const; +#if CPPREFERENCE_STDVER >= 2017 + CharT* data(); +#endif + const CharT* c_str() const; // iterators From bc6b766fde619e1b2116cacb4343c1d96811b06e Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 4 Feb 2023 18:13:22 +0200 Subject: [PATCH 112/114] Headers: Add C++17 std::byte to cstddef --- headers/cstddef | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/headers/cstddef b/headers/cstddef index 81a1bc751..9bb8598db 100644 --- a/headers/cstddef +++ b/headers/cstddef @@ -36,6 +36,35 @@ typedef void* nullptr_t; typedef decltype(nullptr) nullptr_t; #endif #endif + +#if CPPREFERENCE_STDVER >= 2017 +enum class byte : unsigned char {}; + +template +constexpr IntegerType to_integer(std::byte b) noexcept; + +constexpr std::byte operator|(std::byte l, std::byte r) noexcept; +constexpr std::byte operator&(std::byte l, std::byte r) noexcept; +constexpr std::byte operator^(std::byte l, std::byte r) noexcept; +constexpr std::byte operator~(std::byte b) noexcept; + +constexpr std::byte& operator|=(std::byte& l, std::byte r) noexcept; +constexpr std::byte& operator&=(std::byte& l, std::byte r) noexcept; +constexpr std::byte& operator^=(std::byte& l, std::byte r) noexcept; + +template +constexpr std::byte operator<<(std::byte b, IntegerType shift) noexcept; + +template +constexpr std::byte operator>>(std::byte b, IntegerType shift) noexcept; + +template +constexpr std::byte& operator<<=(std::byte& b, IntegerType shift) noexcept; + +template +constexpr std::byte& operator>>=(std::byte& b, IntegerType shift) noexcept; +#endif + } // namespace std #if !CPPREFERENCE_INT_TYPES_ONLY_IN_STD From a57926e68e5a1946be4b13acd83d4e9857943e50 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Sat, 4 Feb 2023 18:13:23 +0200 Subject: [PATCH 113/114] Headers: Add C++20 span header --- headers/span | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 headers/span diff --git a/headers/span b/headers/span new file mode 100644 index 000000000..b83fe891a --- /dev/null +++ b/headers/span @@ -0,0 +1,120 @@ +/* Copyright (C) 2023 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_SPAN_H +#define CPPREFERENCE_SPAN_H + +#if CPPREFERENCE_STDVER >= 2020 + +#include +#include +#include + +namespace std { + +inline constexpr size_t dynamic_extent = numeric_limits::max(); + +template +class span { + using element_type = T; + using value_type = remove_cv_t; + using size_type = size_t; + using difference_type = ptrdiff_t; + using pointer = element_type*; + using const_pointer = const element_type*; + using reference = element_type&; + using const_reference = const element_type&; + using iterator = T*; // actual type is unspecified + using const_iterator = const T*; // actual type is const_iterator; + using reverse_iterator = T*; // actual type is reverse_iterator; + using const_reverse_iterator = const T*; // actual type is const_iterator; + static constexpr size_type extent = Extent; + + // constructor + constexpr span() noexcept; + + template + constexpr explicit(extent != dynamic_extent) span(It first, size_type count); + + template + constexpr explicit(extent != dynamic_extent) span(It first, End last); + + template + constexpr span(type_identity_t (&arr)[N]) noexcept; + + template + constexpr span(array& arr) noexcept; + + template + constexpr span(const array& arr) noexcept; + + template + constexpr explicit(extent != dynamic_extent) span(R&& r); + + constexpr span(const span& other) noexcept = default; + + template + constexpr explicit span(const span& s) noexcept; + + ~span() noexcept = default; + + constexpr span& operator=(const span& other) noexcept = default; + + // subviews + template + constexpr span first() const; + + template + constexpr span last() const; + + template + constexpr span subspan() const; + + constexpr span first(size_type count) const; + constexpr span last(size_type count) const; + constexpr span subspan(size_type offset, + size_type count = dynamic_extent) const; + // observers + constexpr size_type size() const noexcept; + constexpr size_type size_bytes() const noexcept; + [[nodiscard]] constexpr bool empty() const noexcept; + + // element access + constexpr reference operator[](size_type idx) const; + constexpr reference front() const; + constexpr reference back() const; + constexpr pointer data() const noexcept; + + // iterator support + constexpr iterator begin() const noexcept; + constexpr iterator end() const noexcept; + constexpr const_iterator cbegin() const noexcept; + constexpr const_iterator cend() const noexcept; + constexpr reverse_iterator rbegin() const noexcept; + constexpr reverse_iterator rend() const noexcept; + constexpr const_reverse_iterator crbegin() const noexcept; + constexpr const_reverse_iterator crend() const noexcept; +}; + +template +span as_bytes(span s) noexcept; + +template +span as_writable_bytes(span s) noexcept + +} // namespace std +#endif + +#endif // CPPREFERENCE_OSTREAM_H From 985db4c313abddd2f41a9fadb6a045d06cbcf10a Mon Sep 17 00:00:00 2001 From: myfreeer Date: Mon, 7 Oct 2024 17:52:06 +0800 Subject: [PATCH 114/114] preprocess-css: update font-family names to match the website In this file, font-family uses names with spaces, but the website declares it without spaces, this would update the font-family names to match the website. Fixes https://github.com/p12tic/cppreference-doc/issues/138 --- preprocess-css.css | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/preprocess-css.css b/preprocess-css.css index 53547f25a..2e20f40e5 100644 --- a/preprocess-css.css +++ b/preprocess-css.css @@ -14,7 +14,7 @@ div#content { } html, body { - font-family: "DejaVu Sans", arial, sans-serif; + font-family: DejaVuSans, "DejaVu Sans", arial, sans-serif; font-size: 1em; } @@ -31,21 +31,21 @@ pre, } .t-dcl-list-see-monospace > span { - font-family: "DejaVu Sans Mono", courier, monospace; + font-family: DejaVuSansMono, "DejaVu Sans Mono", courier, monospace; } .t-sb-list-ln-table tr > td:first-child { - font-family: "DejaVu Sans Mono", courier, monospace; + font-family: DejaVuSansMono, "DejaVu Sans Mono", courier, monospace; } .t-param-list-item > td:first-child { - font-family: "DejaVu Sans Mono", courier, monospace; + font-family: DejaVuSansMono, "DejaVu Sans Mono", courier, monospace; } .t-dcl-member-div > div:first-child { - font-family: "DejaVu Sans Mono", courier, monospace; + font-family: DejaVuSansMono, "DejaVu Sans Mono", courier, monospace; } .t-dcl-member-nobold-div > div:first-child { - font-family: "DejaVu Sans", arial, sans-serif; + font-family: DejaVuSans, "DejaVu Sans", arial, sans-serif; }