Skip to content

Commit

Permalink
Added comments to new WidgetInfo::Append() cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
mercere99 committed Feb 14, 2019
1 parent a05ece9 commit 6290c2b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions source/web/Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,25 @@ namespace web {
return ForwardAppend(cmd); // Otherwise pass the Close to parent!
}

// Convert arbitrary inputs to a string or string function and try again!
// If overloaded versions of Append don't resolve properly, collect everything else
// with this generic version and try to collect more information about it.
template <typename T>
Widget Append(const T & val) {
// First, test if we are working with a Widget command.
if constexpr ( std::is_base_of<WidgetCommand,T>() ) {
const WidgetCommand & cmd = val;
return Append(cmd);
} else if constexpr ( std::is_invocable<T>() ) {
}

// Next, test if this if an invoable function
// @CAO: We should make sure it returns a string when called with no arguments.
else if constexpr ( std::is_invocable<T>() ) {
std::function<std::string()> fun_val( val );
return Append(fun_val);
} else {
}

// Anything else we should just try to convert to a string, and used that.
else {
return Append(emp::to_string(val));
}
}
Expand Down

0 comments on commit 6290c2b

Please sign in to comment.