diff --git a/rules/S6010/cfamily/rule.adoc b/rules/S6010/cfamily/rule.adoc index f4beb57939..87f572b7e8 100644 --- a/rules/S6010/cfamily/rule.adoc +++ b/rules/S6010/cfamily/rule.adoc @@ -1,18 +1,18 @@ == Why is this an issue? -Since {cpp}17, the class ``++std::filesystem::path++`` can be used to store a file path. Compared to a regular string, it offers several advantages: +Introduced in {cpp}17, the class ``++std::filesystem::path++`` can store a file path. Compared to a regular string, it offers several advantages: * Having a dedicated type makes the intention clear * This class stores the path with an encoding that is appropriate to the OS where the program runs -* It provides several functions that make it more convenient to manipulate than a ``++string++`` (for instance ``++operator/++`` for concatenations) +* It provides several functions that make it more convenient to manipulate than a ``++string++`` (for instance, ``++operator/++`` for concatenations) * It provides a normalized way to specify the path, easing the portability of the code (on Windows and Linux, the native way is equivalent to the normalized way, which reduces overhead). -This rule raises an issue when the same ``++string++`` is converted several times to a ``++path++`` because it indicates that a single path object could have been used in all occurrences. Additionally, it can also be more efficient, since a conversion from ``++string++`` to ``++path++`` may require a change of encoding and a memory allocation. +This rule raises an issue when the same ``++string++`` is converted several times to a ``++path++`` because it indicates that a single path object could have been used in all occurrences. It can also be more efficient since conversion from ``++string++`` to ``++path++`` may require a change of encoding and memory allocation. === Noncompliant code example -[source,cpp] +[source,cpp,diff-id=1,diff-type=noncompliant] ---- std::string getUserData(); namespace fs = std::filesystem; @@ -27,7 +27,7 @@ void f() { === Compliant solution -[source,cpp] +[source,cpp,diff-id=1,diff-type=compliant] ---- std::string getUserData(); namespace fs = std::filesystem; @@ -39,3 +39,7 @@ void f() { } ---- +== Resources + +* {cpp} reference - https://en.cppreference.com/w/cpp/filesystem/path[std::filesystem::path] +