c++functionparametersdefinitionros2

C++: What does the (-1) mean at the end of the parameter list in this function?


I don't understand the definition of a function below: What does the (-1) mean at the end of the parameter list?

template<typename RatioT = std::milli>                
bool rclcpp::client::ClientBase::wait_for_service (std::chrono::duration< int64_t, RatioT > timeout = std::chrono::duration< int64_t, RatioT >(-1) )

Source:

From this tutorial:


Solution

  • It means that the default value for the parameter is -1 (of whatever duration type, by default milliseconds). This value (or probably any negative value) is presumably used to denote "no timeout", however the documentation for this class is entirely silent on the meanings of any of the parameters to any of the member functions.