1.5 KiB
Environment
The environment namespace provides all sorts of facilities to query and manipulate the environment of the current process.
The api should be straight forward, but one oddity that needs to be pointed out is, that environment names are not case sensitive on windows. The key_traits class implements the proper traits depending on the current system.
Additionally, environment can be lists separated by : or ;; environment::value and
environment::value_view can be used to iterate those.
Beyond that, the requirements on an environment are a low as possible; an environment is either a list of strings or a list of string-pairs. It is however recommended to use the environment types, as to have the right value comparisons.
To note is the find_executable functions, which searches in an environment for an executable.
Unresolved directive in <stdin> - include::../example/env.cpp[tag=current_env]
Subprocess environment
The subprocess environment assignment follows the same constraints:
Unresolved directive in <stdin> - include::../example/env.cpp[tag=subprocess_env]
Inheriting an environment
The current environment can be obtained by calling environment::current which returns
a forward range of environment::key_value_pair_view.
Unresolved directive in <stdin> - include::../example/env.cpp[tag=vector_env]
Alternatively you can use a map container for the environment.
Unresolved directive in <stdin> - include::../example/env.cpp[tag=map_env]