Stan  2.10.0
probability, sampling & optimization
validate_zero_buf.hpp
Go to the documentation of this file.
1 #ifndef STAN_IO_VALIDATE_ZERO_BUF_HPP
2 #define STAN_IO_VALIDATE_ZERO_BUF_HPP
3 
4 #include <boost/lexical_cast/bad_lexical_cast.hpp>
5 #include <string>
6 
7 namespace stan {
8  namespace io {
9 
20  template <typename B>
21  void validate_zero_buf(const B& buf) {
22  for (size_t i = 0; i < buf.size(); ++i) {
23  if (buf[i] == 'e' || buf[i] == 'E')
24  return;
25  if (buf[i] >= '1' && buf[i] <= '9')
26  boost::conversion::detail::throw_bad_cast<std::string, double>();
27  }
28  }
29 
30  }
31 }
32 #endif
Probability, optimization and sampling library.
void validate_zero_buf(const B &buf)
Throw an bad-cast exception if the specified buffer contains a digit other than 0 before an e or E...

     [ Stan Home Page ] © 2011–2016, Stan Development Team.