Vowpal Wabbit
Functions
options_boost_po.cc File Reference
#include "options_boost_po.h"
#include "parse_primitives.h"
#include <sstream>
#include <algorithm>
#include <iterator>
#include <utility>

Go to the source code of this file.

Functions

bool is_number (const std::string &s)
 

Function Documentation

◆ is_number()

bool is_number ( const std::string &  s)

Definition at line 12 of file options_boost_po.cc.

References substring::begin, substring::end, f, and parseFloat().

Referenced by VW::config::options_boost_po::add_and_parse().

13 {
14  substring ss = {const_cast<char*>(s.c_str()), const_cast<char*>(s.c_str()) + s.size()};
15  auto endptr = ss.end;
16  auto f = parseFloat(ss.begin, &endptr);
17  if ((endptr == ss.begin && ss.begin != ss.end) || std::isnan(f))
18  {
19  return false;
20  }
21 
22  return true;
23 }
char * end
Definition: hashstring.h:10
char * begin
Definition: hashstring.h:9
float parseFloat(char *p, char **end, char *endLine=nullptr)
float f
Definition: cache.cc:40