Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Global args

boost::process::args

Synopsis

// In header: <boost/process/args.hpp>

unspecified args;

Description

The args property allows to explicitly set arguments for the execution. The name of the executable will always be the first element in the arg-vector.

Details

Operations

Setting values

To set a the argument vector the following syntax can be used.

args = value;
args(value);

std::initializer_list is among the allowed types, so the following syntax is also possible.

args = {value1, value2};
args({value1, value2});

Below the possible types for value are listed, with char_type being either char or wchar_t.

value
  • std::basic_string<char_type>

  • const char_type *

  • std::initializer_list<const char_type *>

  • std::vector<std::basic_string<char_type>>

Additionally any range of std::basic_string<char_type> can be passed.

Appending values

To append a the argument vector the following syntax can be used.

args += value;

std::initializer_list is among the allowed types, so the following syntax is also possible.

args += {value1, value2};

Below the possible types for value are listed, with char_type being either char or wchar_t.

value
  • std::basic_string<char_type>

  • const char_type *

  • std::initializer_list<const char_type *>

  • std::vector<std::basic_string<char_type>>

Additionally any range of std::basic_string<char_type> can be passed.

Example

The overload form is used when more than one string is passed, from the second one forward. I.e. the following expressions have the same results:

spawn("gcc", "--version");
spawn("gcc", args ="--version");
spawn("gcc", args+="--version");
spawn("gcc", args ={"--version"});
spawn("gcc", args+={"--version"});
[Note] Note

A string will be parsed and set in quotes if it has none and contains spaces.


PrevUpHomeNext