c++23 Questions
1
Solved
I stumbled upon a problem with ambiguous overload for operator<< when using std::views::enumerate with size_t range.
More specifically using this code:
#include <iostream>
#include <...
Mideast asked 21/5, 2023 at 10:29
3
I understand that iota can be complex(e.g. infinite), so this can not be done easily in general case, but in some cases it should be possible to do find/contains operation in O(1).
For example
int ...
Leighton asked 3/5, 2023 at 9:34
1
Solved
In the following example, we have two objects that are of different types but happen to be located right next to each other in memory.
struct X {
alignas(long) int val = 1;
};
struct Y {
long va...
Octillion asked 26/4, 2023 at 17:1
1
CMake already supports the most basic use of module, which is good, but the module itself doesn't seem to be ready, or rather the large number of libraries consisting of header files + source files...
Pampuch asked 9/3, 2023 at 8:29
1
Solved
Currently only MSVC supports the nifty helper ranges::to, so I am unable to validate this in another compiler. Basically I have a type alias for a STL container and as soon as I attempt to pass it ...
Silvanus asked 19/4, 2023 at 12:22
1
The convenient initializer_list syntax seems to come at a price of not being able to move members of the list, creating unnecessary copies.
struct A
{
// some members which are dynamic resources.....
Rectangular asked 20/3, 2023 at 22:55
1
Solved
c++23 introduced static versions of the operator () and operator []:
#include <iostream>
#include <format>
struct S
{
static int operator()(int a, int b) { return a + b; }
static int...
Guesthouse asked 28/3, 2023 at 16:6
2
So, I decided I want to use an mdspan rather than a combination of plain span + element access function. But - one obvious thing I want to do with my mdspan is iterate its elements. This is how I w...
Elena asked 18/3, 2023 at 22:21
1
Solved
C++23 introduces std::move_only_function which has support for const and l/r-value-reference on the implicit this parameter and noexcept(true/false) on the function itself.
The old std::function is...
2
Solved
std::begin can call the .begin member function if the argument has it. Also std::ranges::begin seems to do the same.
However, at the page for std::ranges::contains I see no mention of the word memb...
Divorce asked 9/3, 2023 at 17:0
1
The latest standard draft N4910 has this example in [temp.over.link] regarding functional equivalence:
template<int I> concept C = true;
template<typename T> struct A {
void f() require...
Dees asked 29/3, 2022 at 18:39
3
Prior to C++ 23, when using std::cout to send output to stdout, there is a distinction between the following two ways of adding a new line at the end of the printed string:
std::cout << &quo...
1
Although P2321 zip provides the common_reference specialization for pair, and P2165 Compatibility between tuple, pair and tuple-like objects makes tuple and pair interconvertible, the comparison fu...
Organotherapy asked 28/1, 2023 at 13:31
2
std::transform from the <algorithm> header applies to ranges, and it is what "enables" us to use ranges as the functors they are (in the sense of category theory(¹)). std::transform...
Igloo asked 9/1, 2022 at 9:58
1
Solved
The keyword constexpr enforced pretty tight restrictions on functions on its introduction into the C++11 standard. These restrictions were loosened with C++14 and C++20 (most noteworthy):
C++14 al...
Greatnephew asked 23/1, 2023 at 15:37
2
Solved
Unlike fundamental types – float, double and long double – are the new floatN_t types in <stdfloat> introduced in C++23 going to be always IEEE standard binary floating point types?
The cppre...
Reclinate asked 23/1, 2023 at 9:29
1
I am currently playing with C++ modules, trying to modernize our company's code C++ base to use modules for the core features. In particular there is the upcoming C++23 std module which seems very ...
Amphora asked 7/1, 2023 at 16:19
2
Solved
Assuming X and Y are suitable types for such usage, is it UB to use std::start_lifetime_as<X> on an area of memory in one thread as one type and use std::start_lifetime_as<Y> on the exa...
Payroll asked 20/12, 2022 at 4:48
1
Solved
Facing issue
std::ranges::to
I am executing the below example from https://en.cppreference.com/w/cpp/ranges/to
#include <algorithm>
#include <concepts>
#include <iostream>
#includ...
3
Solved
There is a rather typical task of sorting two arrays simultaneously, assuming that same indexed elements of the arrays form virtual pairs, which are sorted. Such questions appear at least 10 years ...
Besiege asked 27/11, 2022 at 8:15
3
Solved
C++23 adds some "monadic-style" functionality regarding optionals, as methods of optional<T>:
optional<T>::and_then() (and ignoring qualifiers of this):
template<class F&g...
Exigible asked 26/11, 2022 at 9:30
2
Solved
When std::views::split() gets an unnamed string literal as a pattern, it will not split the string but works just fine with an unnamed character literal.
#include <iomanip>
#include <iostr...
Thitherto asked 31/10, 2022 at 7:43
0
I am wondering how efficient the std::generator added in cpp23 standard, is going to compare with views. For example:
std::generator<int> f()
{
int i = 10;
while(true} {
co_yield i; ++i;
...
1
Solved
Cppreference documents that stdfloat includes 5 new types: float16_t, float32_t, float64_t, float128_t and bfloat16_t. While the first 4 types are self-explanatory (a float with 16, 32, 64, and 128...
Ezechiel asked 7/10, 2022 at 2:37
1
Solved
C++23 introduced the very powerful ranges::to for constructing an object (usually a container) from a range, with the following definition ([range.utility.conv.to]):
template<class C, input_ran...
Actuary asked 19/9, 2022 at 4:6
© 2022 - 2024 — McMap. All rights reserved.