#ifndef SOIL_MOISTURE_MISC_SUPPORT_H #define SOIL_MOISTURE_MISC_SUPPORT_H #include #include #include #include namespace trygvis { namespace misc_support { using namespace std; using namespace std::chrono; using timestamp_t = time_point; using namespace boost; using namespace std; namespace po = boost::program_options; template static boost::optional map(boost::optional &a, std::function f) { if (!a.is_initialized()) { return boost::none; } return make_optional(f(a)); } template static boost::optional flat_map(boost::optional &a, boost::optional (&f)(Source)) { if (!a.is_initialized()) { return boost::none; } return f(a.get()); } template static boost::optional l_c(const Source source) { try { return boost::lexical_cast(source); } catch (bad_lexical_cast &e) { return boost::none; } }; } } #endif