Talk:Main Page/suggestions/archive 2
std::inner_product description typo?
In the first sentence of the initial description of std::inner_product, I believe std::distance(first1, first2) should be std::distance(first1, last1).
NCSUMaxPower (talk) 08:44, 5 August 2024 (PDT)
<type_traits> header page is missing reference_converts/constructs_from_temporary
Thanks for the great work of maintaining the website!
The "<type_traits> header page" (https://en.cppreference.com/w/cpp/header/type_traits) is missing the following entries:
- std::reference_converts_from_temporary: https://en.cppreference.com/w/cpp/types/reference_converts_from_temporary
- std::reference_constructs_from_temporary: https://en.cppreference.com/w/cpp/types/reference_constructs_from_temporary
The expected result is it has a similar "Supported operations" section as the "Metaprogramming library" (https://en.cppreference.com/w/cpp/meta)
Regards, Zhao
Span's Defect reports has a type
Defect report LWG 3903 unnucessary should be unnecessary
82.75.229.3 10:25, 20 July 2024 (PDT) Hupie
LegacyInputIterator requirements: wrong type / semantics for r
In the requirements summary for LegacyInputIterator, the expression r
is introduced to have type T&
, namely a reference to X
's value type (where X
is a supposed LegacyInputIterator), and then is described to have iterator semantics, as evidenced by the following sample that appears in the table :
T x = *r;
++r;
return x;
This doesn't make sense and is very puzzling to stumble upon. This used to be correct up until a revision on June 16th 2024: before then, r was described as an lvalue of type It, for which the above semantics made sense.
--Deqyra (talk) 00:37, 17 July 2024 (PDT)
- That's quite an oversight, thanks. Fixed and improved the names so this kind of thing should be harder to allow ✔ Done --Ybab321 (talk) 03:38, 17 July 2024 (PDT)
'}}' in page
there is a '}}' at the bottom of the page cpp/language/while
--Zyctree (talk) 05:10, 17 July 2024 (PDT)
cpp/thread/jthread/stop suggested code change
I found the existing example somewhat misleading. I believe this change would better convey the intent.
--- before.cpp 2024-04-22 13:31:41.118514403 -0600 +++ after.cpp 2024-04-22 13:33:05.353596405 -0600 @@ -29,13 +29,9 @@ { std::mutex mutex; std::unique_lock lock(mutex); - std::condition_variable_any().wait(lock, stoken, - [&stoken] { return false; }); - if (stoken.stop_requested()) - { - std::cout << "Waiting worker is requested to stop\n"; - return; - } + std::condition_variable_any().wait(lock, stoken, [] { return false; }); + std::cout << "Waiting worker is requested to stop\n"; + return; }); // std::jthread::request_stop() can be called explicitly:
— Preceding unsigned comment added by 73.229.98.126 (talk • contribs) 2024-04-22 13:31.
- ✔ Done, updated.) --Space Mission (talk) 14:47, 22 April 2024 (PDT)
wrong comment in example
In https://en.cppreference.com/w/c/language/operator_logical, in the first example, the comment says
int n = isspace('a'); // zero if 'a' is a space, nonzero otherwise
Cvttsd2si (talk) 02:20, 23 April 2024 (PDT)
Add code example for std::chrono::hh_mm_ss constructor
Add code example for https://en.cppreference.com/w/cpp/chrono/hh_mm_ss/hh_mm_ss
#include <chrono> #include <iostream> int main() { auto now = std::chrono::system_clock::now(); std::chrono::hh_mm_ss time_of_days{now - std::chrono::floor<std::chrono::days>(now)}; std::cout << "The time of day is: " << time_of_days; }
Possible output:
The time of the day is: 10:43:52.265396171
- ✔ Added, thanks.) --Space Mission (talk) 05:28, 24 April 2024 (PDT)
Update the libc++ URL with the current one
The current URL https://github.com/llvm-mirror/libcxx/blob/a12cb9d211019d99b5875b6d8034617cbc24c2cc/include/algorithm#L4219 for libc++ seems like quite a bit old. LLVM has moved their development tree from SVN to git about 5 years ago. Even though the logic is basically the same, it seems rather a good idea to link the current development tree.
Thanks.
range_error copy constructor noexcept is since c++11
In range_error page,
THIS:
3) Copy constructor. If *this and other both have dynamic type std::range_error then std::strcmp(what(), other.what()) == 0. No exception can be thrown from the copy constructor.(until C++11)
SHOULD BE:
3) Copy constructor. If *this and other both have dynamic type std::range_error then std::strcmp(what(), other.what()) == 0. No exception can be thrown from the copy constructor.(since C++11)
replace "until C++11" with "since C++11". noexept is added in C++11
64.125.32.42 13:48, 24 April 2024 (PDT)
- I'm actually not sure where this copy constructor comes from in the first place, noexcept or not, it doesn't seem to appear in the standard, at least not in the
[diagnostics]
section... If it's the implicitly generated one, then I suppose we should add the move ctor too? But even then I don't see where the noexcept comes from --Ybab321 (talk) 14:41, 24 April 2024 (PDT)- It comes from [exception]/2: "Except where explicitly specified otherwise, each standard library class T that derives from class exception has the following publicly accessible member functions, each of them having a non-throwing exception specification: [...] copy constructor." --D41D8CD98F (talk) 05:23, 26 April 2024 (PDT)
✔ Done I removed the "until C++11" mark. For the record, the non-throwing requirement was introduced by LWG 471. --D41D8CD98F (talk) 05:34, 26 April 2024 (PDT)
Typo/small error in Class template argument deduction (CTAD)
In
Class template argument deduction (CTAD) > Deduction for class templates > Implicitly-generated deduction guides > 1st bullet point > 2nd bullet point,
there is a missing word "Fi". The sentence should read "the associated constraints of Fi are the conjunction of the associated constraints of C and the associated constraints of Ci"
174.138.232.125 06:06, 26 April 2024 (PDT)
- ✔ Fixed here. Thank you indeed.) --Space Mission (talk) 12:00, 26 April 2024 (PDT)
Replace the part about multiple subscripts for operator[] with correct `rev begin/end` and `rev|until/since` block
operator[] can only take one subscript. In order to provide multidimensional array access semantics, e.g. to implement a 3D array access a[i][j][k] = x;, operator[] has to return a reference to a 2D plane, which has to have its own operator[] which returns a reference to a 1D row, which has to have operator[] which returns a reference to the element. To avoid this complexity, some libraries opt for overloading operator() instead, so that 3D access expressions have the Fortran-like syntax a(i, j, k) = x;. |
(until C++23) |
operator[] can take any number of subscripts. For example, an operator[] of a 3D array class declared as T& operator[](std::size_t x, std::size_t y, std::size_t z); can directly access the elements. |
(since C++23) |
- ✔ Done. OK, applied, thanks.) --Space Mission (talk) 12:26, 26 April 2024 (PDT)
cpp/container/map/try_emplace:
Under "Return value", replace "that was inserted or updated" with "whose key is equivalent to `k`".
Elements are never updated. The suggested replacement matches one in the standard wording.
cpp/types/byte
Page: cpp/types/byte
Please add:
std::byte can only compared with other std::byte value.
Not possible:
std::byte x = 2; // Can't be assigned if (x == 3) { // Can't be compared int A[] = { 1, 2, 4, 8 }; int b = A[x]; // Can't be used as an index }
- Done ✔ Done --Ybab321 (talk) 07:15, 30 April 2024 (PDT)
- ✔ Added. --Space Mission (talk) 17:07, 1 May 2024 (PDT)
in owner_hash in the member function the title is owner_less instead of owner_hash
just change the owner_less to owner_hash — Preceding unsigned comment added by Shar-yashuv (talk • contribs) 12:55, 30 April 2024
✔ Done thx --Cubbi (talk) 06:13, 30 April 2024 (PDT)
Add external links to Windows/Linux locales to the (std::)setlocale pages
The `std::locale` constructor page (https://en.cppreference.com/w/cpp/locale/locale/locale) has some seemingly useful external links to lists of locale names for Windows and Linux. I suggest adding these same links to the pages for `setlocale` (https://en.cppreference.com/w/c/locale/setlocale) and `std::setlocale` (https://en.cppreference.com/w/cpp/locale/setlocale).
External links
1. | List of Windows locale names. |
2. | List of Linux locale names. |
- ✔ Done as you suggested.) --Space Mission (talk) 10:27, 3 May 2024 (PDT)
Allocator-aware copy constructor in AllocatorAwareContainer has wrong postcondition
Hi,
I have the feeling, that there is a mistake in [[1]]
The postcondition of
X u(t, m);
claims that
u.get_allocator() == A() must be true.
All C++ standards that I checked mention as postcondition that
u.get_allocator() == m must be true.
I therefore propose, that the postcondition of X u(t, m); is changed to:
u == t and u.get_allocator() == m are both true.
LittleHuba (talk) 08:10, 3 May 2024 (PDT)
- ✔ Fixed (per container.alloc.reqmts). Good catch, thanks.) --Space Mission (talk) 14:21, 3 May 2024 (PDT)