#include <iostream> /* C++ iostream C++98/11 */
#include <string> /* C++ strings C++98/11 */ /* RegEx Boost */
#include <boost/algorithm/string.hpp>
int main() {
std::string str = "\\dir\\dir2\\dir4\\dir4\\dir6";
auto itr = boost::find_nth(str, "\\", 4);
if(itr.empty()) std::cout << "empty";
}
I2luY2x1ZGUgPGlvc3RyZWFtPiAgICAgICAgICAgICAgICAvKiBDKysgaW9zdHJlYW0gICAgICAgICAgICBDKys5OC8xMSAqLwojaW5jbHVkZSA8c3RyaW5nPiAgICAgICAgICAgICAgICAgIC8qIEMrKyBzdHJpbmdzICAgICAgICAgICAgIEMrKzk4LzExICovICAgICAgICAgICAgICAgICAgIC8qIFJlZ0V4ICAgICAgICAgICAgICAgICAgIEJvb3N0ICAqLwojaW5jbHVkZSA8Ym9vc3QvYWxnb3JpdGhtL3N0cmluZy5ocHA+CmludCBtYWluKCkgewoJc3RkOjpzdHJpbmcgc3RyID0gIlxcZGlyXFxkaXIyXFxkaXI0XFxkaXI0XFxkaXI2IjsKYXV0byBpdHIgPSBib29zdDo6ZmluZF9udGgoc3RyLCAiXFwiLCA0KTsKaWYoaXRyLmVtcHR5KCkpIHN0ZDo6Y291dCA8PCAiZW1wdHkiOwoKCn0K