filesystem.h
Go to the documentation of this file.
1 /*
2 * ECVL - European Computer Vision Library
3 * Version: 0.3.4
4 * copyright (c) 2021, Università degli Studi di Modena e Reggio Emilia (UNIMORE), AImageLab
5 * Authors:
6 * Costantino Grana (costantino.grana@unimore.it)
7 * Federico Bolelli (federico.bolelli@unimore.it)
8 * Michele Cancilla (michele.cancilla@unimore.it)
9 * Laura Canalini (laura.canalini@unimore.it)
10 * Stefano Allegretti (stefano.allegretti@unimore.it)
11 * All rights reserved.
12 */
13 
14 // https://github.com/bugstop/vmware-macos-unlocker/blob/master/auto-unlocker/include/filesystem.hpp
15 
16 // We haven't checked which filesystem to include yet
17 #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
18 
19 // Check for feature test macro for <filesystem>
20 # if defined(__cpp_lib_filesystem)
21 # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0
22 
23 // Check for feature test macro for <experimental/filesystem>
24 # elif defined(__cpp_lib_experimental_filesystem)
25 # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
26 
27 // We can't check if headers exist...
28 // Let's assume experimental to be safe
29 # elif !defined(__has_include)
30 # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
31 
32 // Check if the header "<filesystem>" exists
33 # elif __has_include(<filesystem>)
34 
35 // If we're compiling on Visual Studio and are not compiling with C++17, we need to use experimental
36 # ifdef _MSC_VER
37 
38 // Check and include header that defines "_HAS_CXX17"
39 # if __has_include(<yvals_core.h>)
40 # include <yvals_core.h>
41 
42 // Check for enabled C++17 support
43 # if defined(_HAS_CXX17) && _HAS_CXX17
44 // We're using C++17, so let's use the normal version
45 # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0
46 # endif
47 # endif
48 
49 // If the macro isn't defined yet, that means any of the other VS specific checks failed, so we need to use experimental
50 # ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
51 # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
52 # endif
53 
54 // Not on Visual Studio. Let's use the normal version
55 # else // #ifdef _MSC_VER
56 # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0
57 # endif
58 
59 // Check if the header "<filesystem>" exists
60 # elif __has_include(<experimental/filesystem>)
61 # define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
62 
63 // Fail if neither header is available with a nice error message
64 # else
65 # error Could not find system header "<filesystem>" or "<experimental/filesystem>"
66 # endif
67 
68 // We previously determined that we need the experimental version
69 # if INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
70 # include <experimental/filesystem>
71 namespace ecvl
72 {
73 namespace filesystem = std::experimental::filesystem;
74 }
75 # else
76 # include <filesystem>
77 namespace ecvl
78 {
79 namespace filesystem = std::filesystem;
80 }
81 # endif
82 
83 #endif // #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL