Skip to content

Use stringstream to format default values #1215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/cmdstan/arguments/arg_single_real_bounded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <cmdstan/arguments/singleton_argument.hpp>
#include <string>
#include <sstream>

/** Generic bounded real value argument */

Expand All @@ -21,7 +22,10 @@ class arg_single_real_bounded : public real_argument {
_validity
= std::to_string(lb).append(" <= ").append(name).append(" <= ").append(
std::to_string(ub));
_default = std::to_string(def);

std::stringstream def_ss;
def_ss << def;
_default = def_ss.str();
_default_value = def;
_value = _default_value;
_lb = lb;
Expand Down
6 changes: 5 additions & 1 deletion src/cmdstan/arguments/arg_single_real_pos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <cmdstan/arguments/singleton_argument.hpp>
#include <string>
#include <sstream>

/** Generic pos real value argument */

Expand All @@ -15,7 +16,10 @@ class arg_single_real_pos : public real_argument {
_name = name;
_description = desc;
_validity = std::string("0 < ").append(name);
_default = std::to_string(def);

std::stringstream def_ss;
def_ss << def;
_default = def_ss.str();
_default_value = def;
_value = _default_value;
}
Expand Down