Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
5 votes
1 answer
213 views

I have a function that takes some input data that's an arbitrary range and a variant. If both the variant type and the input data are strings I want to call a function that process the string. The ...
1 vote
1 answer
222 views

I am designing a new embedded c++23 library that will have a few hundreds of optional features. the global idea is like this: I would expect that if constexpr(...) would remove code when flag is false....
0 votes
0 answers
89 views

Is a debug_log written entirely as a if constexpr an appropriate (recommended) substitute for a traditional macro implementation of a debug log? Consider the following code compiled with -O3 and -...
1 vote
1 answer
455 views

Consider the following code: enum { a = 1, b = 2 - a}; void foo() { if constexpr(a == 1) { } else { static_assert(b != 1, "fail :-("); } } naively, one might expect the ...
3 votes
0 answers
63 views

Here is the test code: #include <type_traits> enum class ShaderType:unsigned{ Vertex = 0, Fragment = 1, }; template<ShaderType type> struct ShaderTypeHolder{ static constexpr ...
2 votes
0 answers
88 views

There seems to be a lot of confusion out there about if constexpr and the difference between dependent- and non-dependent expressions, particularly in the context of static_assert. Before CWG2518, ...
1 vote
2 answers
142 views

I have an expensive operation that I want to call conditionally depending on the template type. The naive function looks basically like this. template <typename T> void FooNaive( const std::...
Blabba's user avatar
  • 414
3 votes
1 answer
149 views

Why doesn't the static_assert inside Foo get triggered in the following code ? Doesn't the type trait inside if constexpr need to instantiate Foo<float> & Foo<char> ? https://godbolt....
aep's user avatar
  • 1,737
0 votes
0 answers
49 views

I need a templated function which, at compile time, has some behavior inside of it specialized depending on the template arguments. I attempted to approach this using an if constexpr, checking for ...
2 votes
1 answer
100 views

In the Modern C++ Design book by Andrei Alexandrescu, there is a section on enriched policies which shows a class that implements a policy can provide optional member functions for an enriched policy. ...
8 votes
1 answer
217 views

The code below behaves incorrectly. When f<0> or f<5> is called, it prints as if k = true, but the if statement behaves as if k = false. When f<1> is called, it does the opposite. ...
0 votes
0 answers
68 views

I'm working on a bigger project which involves multiple libraries statically linked against each other. E.g.: I have a Library A and Library B. Library B statically links against Lib A. The problem I'...
3 votes
1 answer
150 views

I have a code using "classic" SFINAE. template<class M> auto power(M const& elem) -> decltype(std::norm(elem)) { return std::norm(elem); } template<class M, class = std::...
alfC's user avatar
  • 16.8k
3 votes
1 answer
149 views

From my understanding, dependent name lookup doesn't take place until template instantiation, and template invocations in a discarded if-constexpr statement are not instantiated. As such, I would ...
0 votes
2 answers
137 views

Consider having a simple class, that writes integers to cout depending on its state: #include <iostream> class NotAWriter{ public: NotAWriter& operator<<(const int& arg) { ...

15 30 50 per page
1
2 3 4 5
...
13

AltStyle によって変換されたページ (->オリジナル) /