Great question. I assumed when I looked at the RCL or RCLCPP API I'd find something direct to point you to, I was wrong. That sounds like a fabulous feature request for RCL if we are correct that there is indeed no straightforward way to determine that from C++.
Otherwise, there are other ways to easily find this information. https://github.com/ros2/rcl/blob/mast.... In particular, when you set an RMW, you set the environmental variable of RMW_IMPLEMENTATION
to the value. That should give you which implementation is in the environment.
I agree however that it would make alot of sense to get a "what is being used currently" rather than a "what is being set to use" in case of some failure or if the environment changed since launch.