Skip to content
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

Support tuple #307

Merged
merged 23 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8bad281
add some tests with default capture on the two parameter template and…
phlptp Apr 29, 2019
0c024df
Fix some comments from Code review and add more description
phlptp May 29, 2019
ae41f36
start work on trying to clean up the type traits for which lexical ca…
phlptp May 29, 2019
b3c9b08
fix readme issue and make the condition tests a little clearer
phlptp May 30, 2019
397ce1e
add a check for out of range errors on boolean conversions
phlptp May 31, 2019
ebbeeca
Fix capitalization and some comments on option functions
phlptp Jun 3, 2019
603f01d
Allow immediate_callback on the main app to run the main app callback…
phlptp Jun 13, 2019
5a34ca3
add a is_tuple_like trait, and type_count structure for getting the n…
phlptp Jul 8, 2019
2e90d69
add lexical conversion functions for tuples and other types
phlptp Jul 10, 2019
fd990cc
remove the separate vector option and option function
phlptp Jul 11, 2019
69fd288
test out the type names for tuples
phlptp Jul 12, 2019
6831c63
add some more lexical conversion functions and test
phlptp Jul 15, 2019
b802b43
more work on tuples and tests
phlptp Jul 26, 2019
1ca0e19
Merge remote-tracking branch 'remotes/original/master' into support_t…
phlptp Jul 30, 2019
80eb779
fix some merge warnings
phlptp Jul 30, 2019
e0ad1c7
fix some typename usage and c++14 only constructs
phlptp Jul 31, 2019
a4bb051
tweak some of the template to remove undefined references
phlptp Jul 31, 2019
ceddc87
add extra static assert about is_tuple_like
phlptp Jul 31, 2019
196b66c
fix some undefined references in clang
phlptp Jul 31, 2019
e6c675e
move around some of the type_count templates to be used in the type_n…
phlptp Jul 31, 2019
490683b
move the type_count around and add some additional checks on the clas…
phlptp Jul 31, 2019
2560ea2
add some info to the readme
phlptp Aug 1, 2019
ff1679f
Merge remote-tracking branch 'remotes/original/master' into support_t…
phlptp Aug 10, 2019
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
Prev Previous commit
Next Next commit
fix some merge warnings
  • Loading branch information
phlptp committed Jul 30, 2019
commit 80eb779c9caa087146f241de06e4d1f6973477da
8 changes: 4 additions & 4 deletions include/CLI/TypeTools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ bool lexical_cast(const std::string &input, T &output) {

/// Assignable from double or int
template <typename T, enable_if_t<classify_object<T>::value == number_constructible, detail::enabler> = detail::dummy>
bool lexical_cast(std::string input, T &output) {
bool lexical_cast(const std::string &input, T &output) {
int val;
if(lexical_cast(input, val)) {
output = T(val);
Expand All @@ -647,7 +647,7 @@ bool lexical_cast(std::string input, T &output) {

/// Assignable from int
template <typename T, enable_if_t<classify_object<T>::value == integer_constructible, detail::enabler> = detail::dummy>
bool lexical_cast(std::string input, T &output) {
bool lexical_cast(const std::string &input, T &output) {
int val;
if(lexical_cast(input, val)) {
output = T(val);
Expand All @@ -658,7 +658,7 @@ bool lexical_cast(std::string input, T &output) {

/// Assignable from double
template <typename T, enable_if_t<classify_object<T>::value == double_constructible, detail::enabler> = detail::dummy>
bool lexical_cast(std::string input, T &output) {
bool lexical_cast(const std::string &input, T &output) {
double val;
if(lexical_cast(input, val)) {
output = T{val};
Expand All @@ -669,7 +669,7 @@ bool lexical_cast(std::string input, T &output) {

/// Non-string parsable by a stream
template <typename T, enable_if_t<classify_object<T>::value == other, detail::enabler> = detail::dummy>
bool lexical_cast(std::string input, T &output) {
bool lexical_cast(const std::string &input, T &output) {
static_assert(is_istreamable<T>::value,
"option object type must have a lexical cast overload or streaming input operator(>>) defined, if it "
"is convertible from another type use the add_option<T, XC>(...) with XC being the known type");
Expand Down
10 changes: 5 additions & 5 deletions tests/HelpersTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,11 +1041,11 @@ TEST(Types, LexicalConversionTuple5) {
std::array<unsigned int, 5> x;
bool res = CLI::detail::lexical_conversion<decltype(x), decltype(x)>(input, x);
EXPECT_TRUE(res);
EXPECT_EQ(std::get<1>(x), 19);
EXPECT_EQ(x[0], 9);
EXPECT_EQ(x[2], 18);
EXPECT_EQ(x[3], 5);
EXPECT_EQ(x[4], 235235);
EXPECT_EQ(std::get<1>(x), 19u);
EXPECT_EQ(x[0], 9u);
EXPECT_EQ(x[2], 18u);
EXPECT_EQ(x[3], 5u);
EXPECT_EQ(x[4], 235235u);

input = {"19", "9.12", "hippo"};
res = CLI::detail::lexical_conversion<decltype(x), decltype(x)>(input, x);
Expand Down
4 changes: 1 addition & 3 deletions tests/NewParseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ class spair {
namespace CLI {
namespace detail {

template <>
bool lexical_cast<std::pair<std::string, std::string>>(const std::string &input,
std::pair<std::string, std::string> &output) {
template <> bool lexical_cast<spair>(const std::string &input, spair &output) {

auto sep = input.find_first_of(':');
if((sep == std::string::npos) && (sep > 0)) {
Expand Down