Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 8.2.8 - why aren't aliases allowed?
#1
The rule provides this example as Non-Compliant:

Code:
    using hashPtr_t = std::uintptr_t;
    auto p2 = reinterpret_cast< hashPtr_t >( s );  // Non-compliant

However, there's nowhere in the Rule Text, Rationale or Amplification that explains why aliases are not allowed. Can you clarify?

Aliases are good for removing code duplication and ensuring the correct type is used in all contexts where it's needed; having to remove the alias and spell std::uintptr_t everywhere hurts code readability and maintainability, without any clear benefit.

Static analyzers can easily detect the usage of std::uintptr_t even if it's behind an alias.
Reply


Messages In This Thread
Rule 8.2.8 - why aren't aliases allowed? - by cgpzs - 18-03-2025, 01:19 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)