Skip to content

Commit b479cda

Browse files
committed
refactor: update Converter constructor signature for consistency
1 parent c0f54ae commit b479cda

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

cucumber_cpp/library/cucumber_expression/ParameterRegistry.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ namespace cucumber_cpp::library::cucumber_expression
5555
return *std::next(begin(), index);
5656
}
5757

58-
Converter::Converter(std::size_t matches,
59-
std::function<std::any(MatchRange)> converter)
58+
Converter::Converter(std::size_t matches, std::function<std::any(MatchRange)> converter)
6059
: matches{ matches }
6160
, converter{ std::move(converter) }
6261
{}

cucumber_cpp/library/cucumber_expression/ParameterRegistry.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace cucumber_cpp::library::cucumber_expression
2121
using namespace std::literals;
2222

2323
template<class To>
24-
inline To StringTo(std::string s)
24+
inline To StringTo(const std::string& s)
2525
{
2626
if (s.empty())
2727
return {};
@@ -36,21 +36,21 @@ namespace cucumber_cpp::library::cucumber_expression
3636
}
3737

3838
template<>
39-
inline std::string StringTo<std::string>(std::string s)
39+
inline std::string StringTo<std::string>(const std::string& s)
4040
{
4141
return std::move(s);
4242
}
4343

4444
template<>
45-
inline float StringTo<float>(std::string s)
45+
inline float StringTo<float>(const std::string& s)
4646
{
47-
return std::atof(s.c_str());
47+
return std::stof(s);
4848
}
4949

5050
template<>
51-
inline double StringTo<double>(std::string s)
51+
inline double StringTo<double>(const std::string& s)
5252
{
53-
return std::atof(s.c_str());
53+
return std::stod(s);
5454
}
5555

5656
namespace details
@@ -68,7 +68,7 @@ namespace cucumber_cpp::library::cucumber_expression
6868
}
6969

7070
template<>
71-
inline bool StringTo<bool>(std::string s)
71+
inline bool StringTo<bool>(const std::string& s)
7272
{
7373
using details::iequals;
7474

@@ -87,8 +87,7 @@ namespace cucumber_cpp::library::cucumber_expression
8787

8888
struct Converter
8989
{
90-
Converter(std::size_t matches,
91-
std::function<std::any(MatchRange)> converter);
90+
Converter(std::size_t matches, std::function<std::any(MatchRange)> converter);
9291

9392
std::size_t matches;
9493
std::function<std::any(MatchRange)> converter;
@@ -109,7 +108,7 @@ namespace cucumber_cpp::library::cucumber_expression
109108
void AddParameter(std::string name, std::vector<std::string> regex, std::function<std::any(MatchRange)> converter);
110109

111110
private:
112-
std::map<std::string, Parameter> parameters{};
111+
std::map<std::string, Parameter, std::less<>> parameters{};
113112
};
114113
}
115114

0 commit comments

Comments
 (0)