cmdopt2/arg: add bind support to more string types
This commit is contained in:
parent
6ed70a4839
commit
cd2b6be6e8
@ -8,9 +8,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cruft/util/cast.hpp>
|
||||||
|
#include <cruft/util/concepts/string.hpp>
|
||||||
#include <cruft/util/debug/assert.hpp>
|
#include <cruft/util/debug/assert.hpp>
|
||||||
#include <cruft/util/parse/value.hpp>
|
#include <cruft/util/parse/value.hpp>
|
||||||
#include <cruft/util/cast.hpp>
|
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -38,7 +39,7 @@ namespace cruft::cmdopt2 {
|
|||||||
bind (ValueT &ref)
|
bind (ValueT &ref)
|
||||||
{
|
{
|
||||||
CHECK (!acceptor1);
|
CHECK (!acceptor1);
|
||||||
if constexpr (std::is_same_v<ValueT, std::string> or std::is_same_v<ValueT, char const*>) {
|
if constexpr (cruft::concepts::stringy<ValueT>) {
|
||||||
acceptor1 = [&ref] (std::string_view str) { ref = str; };
|
acceptor1 = [&ref] (std::string_view str) { ref = str; };
|
||||||
} else {
|
} else {
|
||||||
acceptor1 = [&ref] (std::string_view str) { ref = parse::from_string<ValueT> (str); };
|
acceptor1 = [&ref] (std::string_view str) { ref = parse::from_string<ValueT> (str); };
|
||||||
|
Loading…
Reference in New Issue
Block a user