Those files have so many "std::" references. Would this not be a good case to utilize "using namespace std"?
It's a header-only class[0], and "using namespace" in headers is discouraged. [0] https://github.com/sol-prog/cpp17-filewatcher/blob/master/Fi...
C++17 Filesystem – Writing a simple file watcher
11–16 of 16 posts
Re: C++17 Filesystem – Writing a simple file watcher
#12Re: C++17 Filesystem – Writing a simple file watcher
#13Earlier quoted context omitted.
It's a header-only class[0], and "using namespace" in headers is discouraged. [0] https://github.com/sol-prog/cpp17-filewatcher/blob/master/Fi...
But one could use it scoped to the FileWatcher class or to each member function, or is my C++ too rusty?
Re: C++17 Filesystem – Writing a simple file watcher
#14Earlier quoted context omitted.
It's a header-only class[0], and "using namespace" in headers is discouraged. [0] https://github.com/sol-prog/cpp17-filewatcher/blob/master/Fi...
But one could use it scoped to the FileWatcher class or to each member function, or is my C++ too rusty?
The vast majority of C++ users think that the using-directive is injecting names into the scope where it’s declared. ... In reality, the names are injected into the nearest common ancestor of the target namespace (::testing) and the usage namespace (::totw::example::anomymous). In our example, that’s the global namespace!
Re: C++17 Filesystem – Writing a simple file watcher
#15Earlier quoted context omitted.
But one could use it scoped to the FileWatcher class or to each member function, or is my C++ too rusty?
I think it's too rusty, unless I'm misunderstanding https://abseil.io/tips/153 . It says, The vast majority of C++ users think that the using-directive is injecting names into the scope where it’s declared. ... In reality, the names are injected into the nearest common ancestor of the target namespace (::testing) and the usage namespace (::totw::example::anomymous). In our example, that’s the global namespace!
Re: C++17 Filesystem – Writing a simple file watcher
#16Guys, don't do this. There are OS-specific APIs to do this stuff efficiently. No, that's not portable. No, those APIs aren't "nice to use". But it's the "right" way to do it. When you do that kind of stuff, keep in mind that many programs modify files by writing to a temp file and then renaming that file. On a secondary note, "modern C++" needs to be stopped. This is absurd: std::chrono::duration Just say no. Don't i…