if and switch with Initialization

if with initialization

qqq/
├── aaa
│   └── bbb
├── ccc
│   └── bbb
└── xxx
#include <iostream>
#include <filesystem>
#include <string>

int main() {
   namespace fs = std::filesystem;

   std::string name{"qqq"};

   switch( fs::path p{name}; status(p).type() ) {

      case fs::file_type::not_found:
         std::cout << p << " not found\n";
         break;
      case fs::file_type::directory:
         std::cout << p << ": \n";
         for ( const auto& e : std::filesystem::directory_iterator{p} ) {
            std::cout  << "- " << e.path() << "\n";
         }
         break;
      default:
         std::cout << p << " is found but not a directory\n";
         break;
   }
}

Result:

"qqq":
- "qqq/aaa"
- "qqq/ccc"
- "qqq/xxx"