Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. #include <map>
  5.  
  6.  
  7. static std::pair<std::string, std::string>
  8. get_env(const std::string &key, const std::string &def) {
  9.     const char *val = std::getenv(key.c_str());
  10.     return {key, val ? std::string(val) : def};
  11. }
  12.  
  13.  
  14. static std::map<std::string, std::string>
  15. get_environ() {
  16.     return std::map<std::string, std::string> {
  17.         get_env("DISTCC_VERBOSE", "1")
  18.     };
  19. }
  20.  
  21.  
  22. int
  23. main(int argc, char **argv) {
  24.     std::cout << "Hello world\n";
  25.  
  26.     auto ret = get_environ();
  27.  
  28.     for (auto &x: ret) {
  29.         std::cout << x.first << ',' << x.second << '\n';
  30.     }
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement