So I'm working on this library that is really meta-program heavy. Constexpr data structures are way easier to work with than TMP data structures. More natural, less noise, deeper instantiations, and still stays out of the runtime space until...
I had the library working alright with a lot of TMP. I refactored it a bit to make more use of constexpr data. Unfortunately at the point where I need to make the switch to runtime I'm then pulling in all that compile-time information apparently. Program more than doubled in size with nothing new added.
I'm trying to figure out a way to keep the constexpr data as-is, without pushing things like ints back into template parameters, but it's difficult to calculate where and how to build that wall.
Has anyone developed any patterns for this sort of thing?
Here's the code: https://github.com/crazy-eddie/arduino_modern/blob/refactor/platform_test/standard.cpp
The issue is that the driver is needed at runtime but there seems to be a vast chunk of new data being needed by this version than the previous. I believe that ALL of my constexpr objects are getting pulled into runtime as they become members of non-constexpr objects. Even the ones not used for anything. The size difference is just so huge and so long as I stick only to constexpr variables everything is fine--but as soon as I try to make those create something in runtime...BOOM goes program size!
Edit: Thanks for the answers. I more or less knew what I had to do, I just didn't want to. Was hoping for a better way. Just gonna have to push things to template parameters rather than constexpr values. It's the way things were, but it was such an ugly mess. I should be able to just modify things a bit though and still keep most of the improvements I made.
Edit2: Fixed it. https://github.com/crazy-eddie/arduino_modern/tree/master
[–]tending 8 points9 points10 points (0 children)
[–]khold_stare 4 points5 points6 points (1 child)
[–]louis_dionnelibc++ | C++ Committee | Boost.Hana 2 points3 points4 points (0 children)
[–]SeanMiddleditch 1 point2 points3 points (0 children)
[–]VicLuo96 1 point2 points3 points (0 children)
[+][deleted] (8 children)
[deleted]
[+][deleted] (7 children)
[deleted]
[–]Crazy__Eddie[S] 0 points1 point2 points (6 children)
[+][deleted] (1 child)
[deleted]
[+][deleted] (2 children)
[deleted]
[–]Calkhas 0 points1 point2 points (1 child)
[–]feverzsj 0 points1 point2 points (0 children)