Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [constrained-templates]

For code that defines concepts to describe types' supported operations or makes heavy use of them in generic programming.

Filter by
Sorted by
Tagged with
3 votes
1 answer
49 views

A recursive_flatten_view Template Function Implementation in C++

This is a follow-up question for A recursive_flatten Template Function Implementation in C++. I am trying to follow G. Sliepen's answer to create ...
JimmyHu's user avatar
  • 5,444
2 votes
1 answer
60 views

A recursive_flatten Template Function Implementation in C++

This is a follow-up question for A Summation Function For Boost.MultiArray in C++, A recursive_minmax Template Function Implementation in C++ and A recursive_reduce_all Template Function ...
JimmyHu's user avatar
  • 5,444
1 vote
0 answers
39 views

recursive_remove_copy_if and recursive_remove_copy Template Functions Implementation with Execution Policy in C++

This is a follow-up question for recursive_remove and recursive_remove_if Template Function with Unwrap Level Implementation in C++. I am trying to implement ...
JimmyHu's user avatar
  • 5,444
1 vote
1 answer
35 views

recursive_remove and recursive_remove_if Template Function with Unwrap Level Implementation in C++

This is a follow-up question for recursive_find and recursive_find_if_not Template Functions Implementation in C++ and A recursive_copy_if Template Function Implementation with Unwrap Level ...
JimmyHu's user avatar
  • 5,444
4 votes
1 answer
100 views

A recursive_copy_if Template Function Implementation with Unwrap Level Implementation in C++

This is a follow-up question for A recursive_copy_if Template Function Implementation in C++ and recursive_invocable and recursive_project_invocable Concept Implementation in C++. I am trying to ...
JimmyHu's user avatar
  • 5,444
5 votes
2 answers
551 views

Function templates for serializing/deserializing POD types

Are the two function templates below well-formed for serializing/deserializing POD types? Will they work for all the different types that satisfy the constraint pod?...
digito_evo's user avatar
2 votes
1 answer
59 views

recursive_find and recursive_find_if_not Template Functions Implementation in C++

This is a follow-up question for A recursive_find_if Template Function with Unwrap Level Implementation in C++ and recursive_invocable and recursive_project_invocable Concept Implementation in C++. I ...
JimmyHu's user avatar
  • 5,444
2 votes
1 answer
54 views

recursive_invocable and recursive_project_invocable Concept Implementation in C++

This is a follow-up question for A recursive_find_if Template Function with Unwrap Level Implementation in C++. I am trying to make some constrains on Proj and <...
JimmyHu's user avatar
  • 5,444
3 votes
1 answer
43 views

A recursive_all_of Template Function with Unwrap Level Implementation in C++

This is a follow-up question for A recursive_find_if_all Template Function Implementation in C++ and A recursive_all_of Template Function Implementation in C++. To support ...
JimmyHu's user avatar
  • 5,444
1 vote
1 answer
59 views

A recursive_find_if_all Template Function Implementation in C++

This is a follow-up question for recursive_any_of and recursive_none_of Template Functions Implementation in C++. I am trying to follow the suggestion of G. Sliepen's answer to implement ...
JimmyHu's user avatar
  • 5,444
2 votes
2 answers
84 views

A recursive_all_of Template Function Implementation in C++

This is a follow-up question for A recursive_foreach_all Template Function Implementation in C++. I am trying to implement recursive_all_of template function in ...
JimmyHu's user avatar
  • 5,444
5 votes
2 answers
534 views

Three dimensional gaussian image generator in C++

This is a follow-up question for Two dimensional gaussian image generator in C++. Besides the two dimensional case, I am trying to implement three dimensional gaussian image generator which with ...
JimmyHu's user avatar
  • 5,444
2 votes
2 answers
99 views

A recursive_minmax Template Function Implementation in C++

This is a follow-up question for A Maximum Function For Various Type Arbitrary Nested Iterable Implementation in C++. Besides the function for finding maximum, I am trying to implement ...
JimmyHu's user avatar
  • 5,444
2 votes
0 answers
46 views

A recursive_fold_right_all Template Function Implementation in C++

This is a follow-up question for A recursive_fold_left_all Template Function Implementation in C++. Besides recursive_fold_left_all function, I am trying to ...
JimmyHu's user avatar
  • 5,444
1 vote
1 answer
99 views

An Updated recursive_reduce_string Template Function Implementation in C++

This is a follow-up question for A recursive_reduce Template Function with Unwrap Level Implementation in C++ and A recursive_reduce_string Template Function Implementation in C++. Considering the ...
JimmyHu's user avatar
  • 5,444
1 vote
1 answer
110 views

A recursive_reduce_string Template Function Implementation in C++

This is a follow-up question for A recursive_sum Template Function Implementation with Unwrap Level in C++, A recursive_reduce_all Template Function Implementation ...
JimmyHu's user avatar
  • 5,444
1 vote
0 answers
88 views

An Updated recursive_transform Template Function Implementation in C++

This is a follow-up question for A recursive_transform_view Template Function Implementation and A recursive_transform_view Template Function which returns a view in C++. In those implementations ...
JimmyHu's user avatar
  • 5,444
3 votes
1 answer
130 views

A recursive_foreach_all Template Function Implementation in C++

This is a follow-up question for A recursive_fold_left_all Template Function Implementation in C++. As mentioned in G. Sliepen's answer, I am trying to implement <...
JimmyHu's user avatar
  • 5,444
2 votes
1 answer
65 views

A recursive_fold_left_all Template Function Implementation in C++

This is a follow-up question for A recursive_sum Template Function Implementation with Unwrap Level in C++. I am trying to implement a recursive version fold_left ...
JimmyHu's user avatar
  • 5,444
2 votes
0 answers
54 views

A recursive_depth Function Implementation with Target Type Parameter in C++

This is a follow-up question for A recursive_depth function for calculating depth of nested types implementation in C++. I am rethinking about the proposed ...
JimmyHu's user avatar
  • 5,444
1 vote
2 answers
93 views

An arithmeticable Concept Implementation in C++

This is a follow-up question for A recursive_reduce_all Template Function Implementation in C++. As G. Sliepen's answer mentioned: ...
JimmyHu's user avatar
  • 5,444
1 vote
1 answer
126 views

Improved Component-Entity-System Using C++

Introduction I am a newbie, so please take me easy :). I am writing a low-level game engine using C++, GLFW and also OpenGL. This is a continuation of Entity Component System Using C++ I've ...
Andrei Rost's user avatar
2 votes
1 answer
347 views

Entity Component System Using C++

Introduction I'm a new to C++ so please take me easy :) I am currently working on a low-level game engine using C++, OpenGL, and GLFW; I've implemented the Event System and the Input Manager, which ...
Andrei Rost's user avatar
5 votes
1 answer
207 views

Is there a more idiomatic way than this to use template-generic C++23 multidimensional array subscripts?

C++23 is going to add multidimensional array subscript operators to the language, yippee! Alas, I have not yet come across a way to adapt them to types where the number of dimensions is templated, so ...
saxbophone's user avatar
1 vote
0 answers
73 views

A recursive_reduce Template Function with Unwrap Level Implementation in C++

This is a follow-up question for A recursive_sum Template Function Implementation with Unwrap Level in C++ and A recursive_reduce_all Template Function ...
JimmyHu's user avatar
  • 5,444
2 votes
1 answer
149 views

A recursive_reduce_all Template Function Implementation in C++

This is a follow-up question for A recursive_sum Template Function Implementation with Unwrap Level in C++ and A recursive_unwrap_type_t Struct Implementation in C++. Considering the answer provided ...
JimmyHu's user avatar
  • 5,444
1 vote
0 answers
86 views

A recursive_unwrap_type_t Struct Implementation in C++

This is a follow-up question for A recursive_sum Template Function Implementation with Unwrap Level in C++. As G. Sliepen's answer mentioned, I am trying to implement a recursive struct for retrieve ...
JimmyHu's user avatar
  • 5,444
2 votes
1 answer
138 views

A recursive_sum Template Function Implementation with Unwrap Level in C++

This is a follow-up question for A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++ and A recursive_transform_view Template Function Implementation. In the previous ...
JimmyHu's user avatar
  • 5,444
4 votes
2 answers
201 views

Transpose types variadicly

I want to do template metaprogramming to compute the conversion from std::variant<Ts...> to ...
Tom Huntington's user avatar
0 votes
1 answer
118 views

The usages of make_view Template Function in C++

This is a follow-up question for A recursive_transform_view Template Function which returns a view in C++. I am trying to revise the structure of recursive_transform...
JimmyHu's user avatar
  • 5,444
2 votes
2 answers
158 views

A recursive_transform_view Template Function which returns a view in C++

This is a follow-up question for A recursive_transform_view Template Function Implementation. Following the suggestions mentioned in G. Sliepen's answer: Of course, it might be interesting in itself ...
JimmyHu's user avatar
  • 5,444
3 votes
2 answers
164 views

A recursive_transform_view Template Function Implementation

This is a follow-up question for A recursive_transform Template Function with Unwrap Level for std::array Implementation in C++. Considering the suggestion mentioned in Davislor's answer, I am trying ...
JimmyHu's user avatar
  • 5,444
1 vote
1 answer
54 views

A recursive_transform Template Function with Calling reserve for Performance Improvement

This is a follow-up question for A recursive_transform Template Function with Unwrap Level for std::array Implementation in C++. Following the suggestion mentioned in G. Sliepen's answer, the function ...
JimmyHu's user avatar
  • 5,444
3 votes
2 answers
266 views

A recursive_transform Template Function with Unwrap Level for std::array Implementation in C++

This is a follow-up question for A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++. I am following the suggestions proposed by ...
JimmyHu's user avatar
  • 5,444
5 votes
2 answers
182 views

Basic scoped timer struct (extensively redesigned)

Here is the original question. I have extensively revised and redesigned my custom scoped timer for my needs using the feedback I got from two helpful members of this community. However I was told to ...
digito_evo's user avatar
7 votes
2 answers
802 views

Basic scoped timer struct design

I have written the following simple scoped timer struct in order to help me measure the execution time of arbitrary scopes. Here is the code (live): ...
digito_evo's user avatar
5 votes
1 answer
847 views

Implement scope_exit

I want to use the scope_exit class but my compiler/standard library (clang++-16 with libc++) don't support it. Until they do I wanted an implementation. I found a ...
nebuch's user avatar
  • 155
3 votes
1 answer
164 views

Constraining a templated method to accept any integral std::chrono::time_point

Recently I was writing a class that had overloaded read methods for various data types. One of the sets of types I wanted to handle were integral ...
md5i's user avatar
  • 133
6 votes
2 answers
66 views

Flexible median evaluator

I recently posted an externally-evaluating median algorithm (i.e. not requiring move or copy of elements), and the feedback encouraged me to develop it further. One simple suggestion was to handle NaN ...
Toby Speight's user avatar
  • 77.3k
3 votes
2 answers
218 views

Generic implementation of median #2: Follow up

Follow on from this codereview: generic implementation of median As before the vector2 class is just for illustrative purposes and not the focus. I have ...
Oliver Schönrock's user avatar
5 votes
1 answer
218 views

A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++ and A recursive_transform Template Function Implementation with ...
JimmyHu's user avatar
  • 5,444
3 votes
0 answers
159 views

An element_wise_multiplication and an element_wise_division Function For Boost.MultiArray in C++

This is a follow-up question for An element_wise_add Function For Boost.MultiArray in C++ and An Add/Minus Operator For Boost.MultiArray in C++. Besides the basic element-wise add / minus operations, ...
JimmyHu's user avatar
  • 5,444
4 votes
1 answer
146 views

An Add/Minus Operator For Boost.MultiArray in C++

This is a follow-up question for An element_wise_add Function For Boost.MultiArray in C++. The following code is the improved version based on G. Sliepen's answer. On the other hand, the built-in ...
JimmyHu's user avatar
  • 5,444
4 votes
1 answer
149 views

A Maximum Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is the follow-up question for A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++. Besides the summation case, I am trying to implement a ...
JimmyHu's user avatar
  • 5,444
6 votes
1 answer
2k views

C++20 concepts for container and allocator

I implemented concepts for container and allocator types. I referenced type requirements from here for container and here for allocator. For the sake of simplicity, there are a lot of type aliases ...
PHD's user avatar
  • 161
12 votes
1 answer
204 views

Composable by-member comparison

Motivation Quite often, I find myself creating types that must be compared memberwise. For example, consider this simple Person: ...
Toby Speight's user avatar
  • 77.3k