Here is a hack that is close:
#define _return_constexpr(x) static_assert(((void)x, true), ""); return x
template <uint8_t which>
constexpr Device& get_device() {
_return_constexpr(get_device(which));
}
What passes tests like:
constexpr Device& cD1 = get_device(1);
constexpr Device& cD1 = get_device<1>();
constexpr Device& cD10 = get_device(10);
constexpr Device& cD10 = get_device<10>();
Device& cD1 = get_device(1);
Device& cD1 = get_device<1>();
Device& cD10 = get_device(10);
Device& cD10 = get_device<10>();
Device& D1 = get_device(id1);
Device& D10 = get_device(id10);
, static_assert - , constexpr , :
?
, constexpr, :
template <uint8_t which>
Device& get_device() {
constexpr auto& ret = get_device(which);
return ret;
}