Skip to main content
9 votes

Basic scoped timer struct design

I don't see why m_end is a member, as it's unassigned for the object's entire life, and only meaningful within the destructor. I would make it a local variable ...
Toby Speight's user avatar
  • 78.9k
7 votes
Accepted

Basic scoped timer struct design

Answers to your questions How do I put constraints on the template parameter Time just like I have done for Clock inside the <...
G. Sliepen's user avatar
7 votes
Accepted

Composable by-member comparison

You forgot to include <type_traits>. auto&& operator-() && { return sort; } The ...
T.C.'s user avatar
  • 568
6 votes
Accepted

Generic implementation of median #2: Follow up

Be as generic as possible Your median() and median_in_place() functions don't work on all things that are ranges, because you ...
G. Sliepen's user avatar
6 votes

Function templates for serializing/deserializing POD types

Personal opinion here (so take or leave as you like). Putting the bool here on a separate line to the function makes it harder to parse for me. I always look for ...
Loki Astari's user avatar
  • 95.7k
6 votes
Accepted

Function templates for serializing/deserializing POD types

This is not a good idea To answer your questions directly: Are the two function templates below well-formed for serializing/deserializing POD types? Yes, they are “well-formed”. Will they work for ...
indi's user avatar
  • 12.4k
5 votes
Accepted

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

Using the right concept Indeed, Summable is the wrong concept to use if you want to check if the value type is such that you can calculate the maximum of two values....
G. Sliepen's user avatar
4 votes
Accepted

Three dimensional gaussian image generator in C++

Structure of a 3D image Your 2D Image class is not storing a vector of vectors, rather it stores a single vector with all the pixels in the 2D image. But instead of ...
G. Sliepen's user avatar
4 votes

Three dimensional gaussian image generator in C++

I agree with everything G. Sliepen said in their answer. Especially the advice of creating an actual 3D image rather than an array of 2D images (ideally you'd create an image object that can have an ...
Cris Luengo's user avatar
  • 6,217
3 votes
Accepted

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

Yes, this is a perfectly fine way to do it, and it is very concise. It might be instructive to compare this to std::mdspan: its ...
G. Sliepen's user avatar
3 votes
Accepted

An arithmeticable Concept Implementation in C++

Naming The name arithmeticable sounds quite weird. arithmetic or is_arithmetic would be ...
G. Sliepen's user avatar
3 votes
Accepted

Basic scoped timer struct (extensively redesigned)

It's great to see the improvements you made! Almost all of them make sense and improve the quality and usability of the class. Using std::function to store the ...
G. Sliepen's user avatar
3 votes
Accepted

Transpose types variadicly

Is this the best way achieve this type computation? Is this the only way? For this case where there is template specialiation, yes, I think this is the only way. You could add the following ...
G. Sliepen's user avatar
3 votes

Generic implementation of median #2: Follow up

Instead of using std::midpoint(), it might be better to allow types to have their own midpoint() function (in their namespace), ...
Toby Speight's user avatar
  • 78.9k
3 votes
Accepted

Flexible median evaluator

This looks very watertight. Just a few minor remarks: Perhaps too much constraints? You constrain the template parameters inside the template parameter list, but also using a ...
G. Sliepen's user avatar
3 votes
Accepted

A recursive_flatten_view Template Function Implementation in C++

Copies everywhere I know that all unnecessary copy operations should be avoided, but I am not sure the way which I've done is correct. You haven't avoided unnecessary copies at all. In fact, you are ...
G. Sliepen's user avatar
2 votes
Accepted

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

if (input1.num_dimensions() != input2.num_dimensions()) { throw std::logic_error("Array dimensions are different"); } If I'm not mistaken, the ...
user673679's user avatar
  • 11.8k
2 votes

C++20 concepts for container and allocator

I think you're perhaps overdoing the constraints (and perhaps trying to catch out Machiavelli, rather than to help Murphy). I'd write the nullable pointer type much more simply: ...
Toby Speight's user avatar
  • 78.9k
2 votes

Flexible median evaluator

Even though I left the code overnight before posting (that always works; I wake up with improvements in my head) I still spotted a couple of improvements. Avoid misunderstanding of the builder ...
Toby Speight's user avatar
  • 78.9k
2 votes
Accepted

Implement scope_exit

Name it scope_exit If you want to have a drop-in replacement for std::experimental::scope_exit, give it the same name. You could ...
G. Sliepen's user avatar
2 votes

Transpose types variadicly

As stated by G. Sliepen, this seems to be the only way to achieve what you want. However, I can see a few places for improvement An std::vector<T&> makes ...
Ajinkya Kamat's user avatar
2 votes
Accepted

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

It's just getting better and better! Use a constraint instead of static_assert() You can trivially turn the static_assert() you ...
G. Sliepen's user avatar
2 votes
Accepted

Improved Component-Entity-System Using C++

Performance is important The goal of an ECS is to improve performance when handling large numbers of objects. It does that by separating the components from the entities and storing them separately. ...
G. Sliepen's user avatar
2 votes
Accepted

Entity Component System Using C++

About your concerns Question: Should I replace the simple Entity = size_t, with an Object Entity? This would improve type safety but would also reduce speed and increase complexity, since now every ...
G. Sliepen's user avatar
2 votes
Accepted

A recursive_reduce_all Template Function Implementation in C++

Be more precise with your type constraints By using incorrect constraints, you greatly reduced the number of types your recursive_reduce_all() works on. ...
G. Sliepen's user avatar
2 votes

An arithmeticable Concept Implementation in C++

The tests appear to do much more than simply test the concept definition. I would prefer a much simpler test suite that can easily direct me to the exact failing case, like this: ...
Toby Speight's user avatar
  • 78.9k
2 votes

A recursive_minmax Template Function Implementation in C++

Bug You iterate the range twice, once for each partial result, which is forbidden for a simple std::ranges::input_range. You need at least a ...
Deduplicator's user avatar
  • 19.3k
2 votes
Accepted

recursive_invocable and recursive_project_invocable Concept Implementation in C++

Your code is correct, however it can be simplified in a number of ways: Unnecessary if-statements Whenever you see ...
G. Sliepen's user avatar
2 votes
Accepted

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

Range is not just an input range This is something I missed in my reviews of your previous questions. The parameter input is ...
G. Sliepen's user avatar
1 vote
Accepted

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

Make it more generic Summing is a very specific operation. What if you want to calculate the product of all elements instead? Or get the minimum or maximum value? Instead of hardcoding the operation, ...
G. Sliepen's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible