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
1 vote
0 answers
33 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
  • 4,708
1 vote
1 answer
32 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
  • 4,708
4 votes
1 answer
96 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
  • 4,708
5 votes
2 answers
532 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
54 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
  • 4,708
2 votes
1 answer
49 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
  • 4,708
3 votes
1 answer
39 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
  • 4,708
1 vote
1 answer
56 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
  • 4,708
2 votes
2 answers
79 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
  • 4,708
5 votes
2 answers
518 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
  • 4,708
2 votes
2 answers
72 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
  • 4,708
2 votes
0 answers
44 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
  • 4,708
1 vote
1 answer
94 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
  • 4,708
1 vote
1 answer
104 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
  • 4,708
1 vote
0 answers
85 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
  • 4,708
3 votes
1 answer
117 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
  • 4,708
2 votes
1 answer
62 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
  • 4,708
2 votes
0 answers
53 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
  • 4,708
1 vote
2 answers
87 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
  • 4,708
1 vote
1 answer
115 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
294 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
176 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
69 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
  • 4,708
2 votes
1 answer
145 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
  • 4,708
1 vote
0 answers
79 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
  • 4,708
2 votes
1 answer
135 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
  • 4,708
4 votes
2 answers
192 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
112 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
  • 4,708
2 votes
2 answers
148 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
  • 4,708
3 votes
2 answers
157 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
  • 4,708
1 vote
1 answer
53 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
  • 4,708
3 votes
2 answers
248 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
  • 4,708
5 votes
2 answers
168 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
762 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
687 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
147 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
3 votes
2 answers
217 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
214 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
  • 4,708
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
  • 4,708
4 votes
1 answer
145 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
  • 4,708
4 votes
1 answer
147 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
  • 4,708
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
198 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