Questions tagged [constant-expression]

Use this whenever compile-time expression is implemented (currently exists in C++ and D). Do not use this tag if the compile-time evaluation property is achieved through template metaprogramming in C++ (in which case use the [template-meta-programming] tag).

Filter by
Sorted by
Tagged with
2
votes
1answer
37 views

type erased pointer to member function callable and SFINAE [closed]

I'm implementing a std::function like class that uses type erasure. So far it can be used with function objects (functions/function pointers, functors, lamdas) and pointer to member function. But to ...
3
votes
1answer
71 views

Flatten 2d-array at compiletime

In my code, I need to flatten a two-dimensional std::array into a one-dimensional one at compile time. While writing the code I realized, that I am unsure about ...
2
votes
1answer
137 views

C++ ring buffer using some C++ 17 and coming C++ 20 std::span

When I heard about the new Linux I/O interface io_uring I searched about the ring buffer. I then thought I may replace my safe queue which is base on C++ 11 ...
5
votes
1answer
318 views

A cartesian product of tuples in C++17

I would like to write a function that computes a cartesian product of two tuples in C++17 (the tuples can be of type std::tuple or ...
3
votes
1answer
90 views

Simple DP problem solved in compile time

The problem is taken from one of recent SO questions: Finding max sum of matrix elements with following constraints: Exactly one row element has to be included in the sum If element at (i, j) is ...
3
votes
0answers
305 views

C++ compile time counter/accumulator [closed]

I could not find a compile time counter/accumulator to achieve something like the following: ...
3
votes
1answer
489 views

Check array contains element at compile time

We have a modifyCoefficient(const char* name, int value) function that updates the value of a coefficient in a container. The names are known at compile time, they ...
6
votes
1answer
890 views

Constexpr unit tests and asserts

I'm trying out some different programming styles to experiment with the new C++ concepts. Within the experiment I was looking into how constexpr could be helpful ...
1
vote
0answers
528 views

constexpr hashtable string to user type

This creates something like constexpr mar<String, T> using C++14. Collision resolution is with static_assert and manually ...
11
votes
1answer
2k views

User defined literal for std::integral_constant

I created a user defined literal _c to convert an "integer" literal into an std::integral_constant. Basically, the goal is to ...