Skip to main content

Questions tagged [c++20]

C++20 is the version of C++ after C++17. This tag should be used (along with the [C++] tag) for questions about C++ features specific to C++20.

1 vote
0 answers
51 views

Should std::span be passed by value or const reference? [duplicate]

Should std::span be passed by value or const reference? What are the implications of either? void MyFunction(std::span s); // or void MyFunction(const std::span& s); Technically the const ...
Panda's user avatar
  • 937
0 votes
0 answers
54 views

Is it legal to pass two views to ranges::views::concat such that iterating on the first view will shrink the range backing up the second view?

Here's a small (ok, maybe not minimal) example #include <range/v3/view/concat.hpp> #include <range/v3/view/transform.hpp> #include <unordered_set> #include <vector> #include &...
Enlico's user avatar
  • 26.7k
0 votes
0 answers
31 views

Boost.Asio how does io_context poll work and how to poll in a tight loop?

I have been playing around with Boost.Asio and I want to be able to busy poll rather than simply perform an io_context.run(). My application currently consists of 2 io_context object each running on a ...
IvanYanakiev's user avatar
3 votes
1 answer
51 views

Coroutine return_void; difference between co_return; and falling off the end

On cppreference I read the following (emphasis mine): Falling off the end of the coroutine is equivalent to co_return;, except that the behavior is undefined if no declarations of return_void can be ...
Wutz's user avatar
  • 2,700
-1 votes
0 answers
26 views

Template-template parameters cause linking errors when specializing `std::formatter` [duplicate]

Note: This is a follow-up to my previous question, where I figured out how to properly separate the interface and implementation of a std::formatter specialization for a non-templated custom type (TL;...
Christopher Miller's user avatar
1 vote
0 answers
130 views

Why is the arrow operator not generated?

I'm trying to write an iterator Iter such that std::iterator_traits<Iter> deduces a maximum amount of information from it. To this end, if I understood correctly, Iter needs to "satisfy the ...
igel's user avatar
  • 379
4 votes
1 answer
124 views

How would std::optional need to be modified in order to make it a monad via coroutines?

There's not really much when searching for c++coroutine "optional", but from the final part of this answer I'd deduce that std::optional can't be made to work with the coroutine below non-...
Enlico's user avatar
  • 26.7k
1 vote
1 answer
65 views

Why does separating the interface and implementation of a `std::formatter` specialization cause constraints to fail?

I was trying to specialize std::formatter<T> for a basic custom type Vector3D, but I'm receiving a compiler error. Here is a minimal reproducible example: vector.h defines the Vector3D class and ...
Christopher Miller's user avatar
2 votes
1 answer
80 views

Can you call a static constexpr member function at compile time? [duplicate]

g++ and clang++ disagree on whether I can call a static constexpr method at compile time. Here is a small program to illustrate the difference: #include <print> struct foo { static constexpr ...
user3188445's user avatar
  • 4,352
0 votes
3 answers
95 views

Can we call the respective original function with parameters automatically from proxy class in C++?

I have a class and a proxy class which holds pointer to original class to call its functions in C++. I am using proxy class for logging purpose . From each function of proxy class , In addition to ...
suresh kumar's user avatar
2 votes
1 answer
113 views

In GCC, inside a lambda, I can get constexpr variable from a non-constexpr template lambda, but not in Visual C++

This code compiles fine in gcc, but fail in Visual C++. MCVE = https://godbolt.org/z/K7d5PEs65 int main(){ int localVariable=0; //some local variable auto lamb=[&]<int s>() { ...
cppBeginner's user avatar
  • 1,116
1 vote
2 answers
60 views

get constexpr variable from a lambda function is fine , but compile fail (Visual C++) and fine (gcc) when such statement is in a new lambda

This code compiles fine in gcc, but fail in Visual C++. MCVE = https://wandbox.org/permlink/SqNI85EospSrwm5T int main() { auto func_do1Pass2=[&]() { return 8; }; constexpr int ...
cppBeginner's user avatar
  • 1,116
3 votes
2 answers
89 views

Count matching elements after splitting

I want to combine std::views::split or std::views::lazy_split with std::ranges::count but I cannot get it to work. This is what I currently have: std::string setting; std::string extension; const ...
Holt's user avatar
  • 37.3k
-1 votes
1 answer
57 views

Need help designing a constexpr lookup [closed]

I am developing a library to run pipelines defined at compile time. This is done for some stricter compile-time checks and works fairly well in the scenarios tried so far. Now I want to add a new kind ...
Eugene's user avatar
  • 9,392
0 votes
0 answers
50 views

Suspending coroutine and resuming later in boost.Asio

In my application, I use Asio for asynchronous websockets and coroutines (custom websocket server). It works in a way that I have callback which is called when data is received and by interacting with ...
Bolderaysky's user avatar

15 30 50 per page
1
2 3 4 5
373