18-03-2022, 01:27 PM
When using UDLs like the ones provided by std::chrono, for example, we get a violation of rule M7-3-4 when including the UDL namespace:
Naturally, this rule was written before UDLs were a thing and so it's inevitably not designed for this use case.
We have discussed two options for this:
The second option requires writing code similar to:
which is a little cumbersome, especially for developers unfamiliar with how a UDL is written.
What I would like to know is how MISRA intends to handle UDLs in the upcoming guidelines? If they are allowed, how should they be imported for convenient use? Will M7-3-4 be updated to include an exception for namespaces that define UDLs?
Thank you in advance for you time.
/Dave
Code:
using namespace std::chrono_literals; // <- violation here
Naturally, this rule was written before UDLs were a thing and so it's inevitably not designed for this use case.
We have discussed two options for this:
- Partially deviate for this use case only
- Explicitly import the required UDL(s)
The second option requires writing code similar to:
Code:
using std::chrono_literals::operator""s;
using std::chrono_literals::operator""ms;
What I would like to know is how MISRA intends to handle UDLs in the upcoming guidelines? If they are allowed, how should they be imported for convenient use? Will M7-3-4 be updated to include an exception for namespaces that define UDLs?
Thank you in advance for you time.
/Dave