What is the difference between path::string() and path::generic_string() in boost?

前端 未结 2 1890
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 00:08

What is the difference between boost::path::string() and boost::path::generic_string(), and when should I use each of them?

2条回答
  •  不知归路
    2021-01-19 00:57

    This is clearly stated in the documentation; you need only read the documentation to gain knowledge and understanding. Please get into the habit of doing that, starting from now.

    boost::path::string

    Returns a std::string in the native pathname format.

    boost::path::generic_string

    Returns a std::string in the generic pathname format.

    When to use each of them

    Well, that's up to you, and depends on your needs! The following quotation, again from the documentation, may help…

    [Note: For ISO/IEC 9945, no conversion occurs, since the native format and generic format are the same. For Windows, backslashes are converted to slashes --end note]

    In day-to-day use, you can effectively say:

    • On Windows, native format has backslashes and generic format has slashes;
    • On Linux, both formats have slashes.

提交回复
热议问题