Add helper for converting designated initializers to C++
Unfortunately, C++ does not support designated initializers. Add a function that helps fill their place. Use example: -static struct netisr_handler ether_nh = { - .nh_name = "ether", - .nh_handler = ether_nh_input, - .nh_proto = NETISR_ETHER, - .nh_policy = NETISR_POLICY_SOURCE, - .nh_dispatch = NETISR_DISPATCH_DIRECT, -}; +static netisr_handler ether_nh = initialize_with([] (netisr_handler& x) { + x.nh_name = "ether"; + x.nh_handler = ether_nh_input; + x.nh_proto = NETISR_ETHER; + x.nh_policy = NETISR_POLICY_SOURCE; + x.nh_dispatch = NETISR_DISPATCH_DIRECT; +}); Signed-off-by:Avi Kivity <avi@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
include/osv/initialize.hh
0 → 100644
Please register or sign in to comment