Skip to content

Commit

Permalink
Remove useless template.
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Sep 30, 2024
1 parent 2a0b262 commit fce146c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/codegen/codegen_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,12 @@ int CodegenCppVisitor::int_variables_size() const {
* representation (1e+20, 1E-15) then keep it as it is.
*/
std::string CodegenCppVisitor::format_double_string(const std::string& s_value) {
return utils::format_double_string<CodegenCppVisitor>(s_value);
return utils::format_double_string(s_value);
}


std::string CodegenCppVisitor::format_float_string(const std::string& s_value) {
return utils::format_float_string<CodegenCppVisitor>(s_value);
return utils::format_float_string(s_value);
}


Expand Down
6 changes: 2 additions & 4 deletions src/codegen/codegen_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ namespace utils {
* they are represented in the mod file by user. If the value is in scientific
* representation (1e+20, 1E-15) then keep it as it is.
*/
template <>
std::string format_double_string<CodegenCppVisitor>(const std::string& s_value) {
std::string format_double_string(const std::string& s_value) {
double value = std::stod(s_value);
if (std::ceil(value) == value && s_value.find_first_of("eE") == std::string::npos) {
return fmt::format("{:.1f}", value);
Expand All @@ -30,8 +29,7 @@ std::string format_double_string<CodegenCppVisitor>(const std::string& s_value)
}


template <>
std::string format_float_string<CodegenCppVisitor>(const std::string& s_value) {
std::string format_float_string(const std::string& s_value) {
float value = std::stof(s_value);
if (std::ceil(value) == value && s_value.find_first_of("eE") == std::string::npos) {
return fmt::format("{:.1f}", value);
Expand Down
2 changes: 0 additions & 2 deletions src/codegen/codegen_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ namespace utils {
* \param s_value The double constant as string
* \return The proper string to be printed in the generated file.
*/
template <typename T>
std::string format_double_string(const std::string& s_value);


Expand All @@ -43,7 +42,6 @@ std::string format_double_string(const std::string& s_value);
* \param s_value The double constant as string
* \return The proper string to be printed in the generated file.
*/
template <typename T>
std::string format_float_string(const std::string& s_value);

} // namespace utils
Expand Down
12 changes: 6 additions & 6 deletions test/unit/codegen/codegen_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SCENARIO("C codegen utility functions", "[codegen][util][c]") {
std::string double_constant = "0.012345678901234567";

THEN("Codegen C Visitor prints double with same precision") {
auto nmodl_constant_result = codegen::utils::format_double_string<CodegenCppVisitor>(
auto nmodl_constant_result = codegen::utils::format_double_string(
double_constant);
REQUIRE(nmodl_constant_result == double_constant);
}
Expand All @@ -33,7 +33,7 @@ SCENARIO("C codegen utility functions", "[codegen][util][c]") {
std::string codegen_output = "1.0";

THEN("Codegen C Visitor prints integer as double number") {
auto nmodl_constant_result = codegen::utils::format_double_string<CodegenCppVisitor>(
auto nmodl_constant_result = codegen::utils::format_double_string(
double_constant);
REQUIRE(nmodl_constant_result == codegen_output);
}
Expand All @@ -44,7 +44,7 @@ SCENARIO("C codegen utility functions", "[codegen][util][c]") {

THEN("Codegen C Visitor prints doubles with scientific notation") {
for (const auto& test: tests) {
REQUIRE(codegen::utils::format_double_string<CodegenCppVisitor>(test.first) ==
REQUIRE(codegen::utils::format_double_string(test.first) ==
test.second);
}
}
Expand All @@ -54,7 +54,7 @@ SCENARIO("C codegen utility functions", "[codegen][util][c]") {
std::string float_constant = "0.01234567";

THEN("Codegen C Visitor prints float with same precision") {
auto nmodl_constant_result = codegen::utils::format_float_string<CodegenCppVisitor>(
auto nmodl_constant_result = codegen::utils::format_float_string(
float_constant);
REQUIRE(nmodl_constant_result == float_constant);
}
Expand All @@ -66,7 +66,7 @@ SCENARIO("C codegen utility functions", "[codegen][util][c]") {
std::string codegen_output = "1.0";

THEN("Codegen C Visitor prints integer as double number") {
auto nmodl_constant_result = codegen::utils::format_float_string<CodegenCppVisitor>(
auto nmodl_constant_result = codegen::utils::format_float_string(
float_constant);
REQUIRE(nmodl_constant_result == codegen_output);
}
Expand All @@ -77,7 +77,7 @@ SCENARIO("C codegen utility functions", "[codegen][util][c]") {

THEN("Codegen C Visitor prints doubles with scientific notation") {
for (const auto& test: tests) {
REQUIRE(codegen::utils::format_float_string<CodegenCppVisitor>(test.first) ==
REQUIRE(codegen::utils::format_float_string(test.first) ==
test.second);
}
}
Expand Down

0 comments on commit fce146c

Please sign in to comment.