dlib icon indicating copy to clipboard operation
dlib copied to clipboard

Miscellaneous cleanup and refresh

Open pfeatherstone opened this issue 2 years ago • 3 comments

I'm currently working on a dnn2 API. As I'm working on it, I'm spotting things in the code base that could do with a refresh. This PR proposes some of these updates:

  • old type traits are now just aliases for standard library type traits
  • using is_detected and switch_() in dnn core. I think it makes things clearer and trivially update-able to if constexpr for when the time comes.
  • added an improved for_each_in_tuple(). It uses fold expression if possible otherwise the parameter pack expansion trick into dummy initializer list. This improves compile time.
  • Use generic lambdas where possible instead of struct helpers
  • auto deduced return types

pfeatherstone avatar Sep 03 '22 15:09 pfeatherstone

There's a whole bunch of stuff I could do to dnn/core.h, but given i'm rewriting all this stuff in dnn2, i don't see the point.

pfeatherstone avatar Sep 04 '22 12:09 pfeatherstone

I don't think windows likes me using std::isfinite for dlib::is_finite. It looks like MSVC has a bug where it doesn't support std::isfinite for integral types as per the standard. See https://godbolt.org/z/51q6x9Wh5 Windows is so dumb

pfeatherstone avatar Sep 06 '22 07:09 pfeatherstone

@davisking What do you think? Updated some things to use C++14. Re-organised some things. It was about time some of the type traits stuff just became c++11 aliases and were put in their own type_traits.h header. Changed bits to use C++11 type traits. Basically things should phase out using the dlib type traits if possible. And dnn stuff uses switch_() and is_detected in some places. I think it makes things simpler and easier to read.

pfeatherstone avatar Sep 10 '22 14:09 pfeatherstone

@davisking Do you mind having another look?

pfeatherstone avatar Sep 19 '22 10:09 pfeatherstone

@davisking Do you mind having another look?

Yeah nice, this is great :)

davisking avatar Sep 19 '22 12:09 davisking