fork download
  1. int main() {
  2. /*V1*/
  3. //this is what I want
  4. auto range = boost::filesystem::directory_iterator(...);
  5. //unfortunately that may throw an exception which I need to handle, so I cannot use it
  6.  
  7. /*V2*/
  8. //ugly code duplication
  9. decltype(boost::filesystem::directory_iterator(...)) range;
  10. try{
  11. range = boost::filesystem::directory_iterator(...);
  12. }catch{}
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:4:15: error: 'boost' has not been declared
  auto range = boost::filesystem::directory_iterator(...);
               ^
prog.cpp:4:53: error: expected primary-expression before '...' token
  auto range = boost::filesystem::directory_iterator(...);
                                                     ^
prog.cpp:9:11: error: 'boost' was not declared in this scope
  decltype(boost::filesystem::directory_iterator(...)) range;
           ^
prog.cpp:9:2: error: expected primary-expression before 'decltype'
  decltype(boost::filesystem::directory_iterator(...)) range;
  ^
prog.cpp:11:11: error: 'boost' is not a class, namespace, or enumeration
   range = boost::filesystem::directory_iterator(...);
           ^
prog.cpp:11:49: error: expected primary-expression before '...' token
   range = boost::filesystem::directory_iterator(...);
                                                 ^
prog.cpp:12:8: error: expected '(' before '{' token
  }catch{}
        ^
prog.cpp:12:8: error: expected type-specifier before '{' token
prog.cpp:12:8: error: expected ')' before '{' token
stdout
Standard output is empty