MPQC  3.0.0-alpha
string.hpp
1 #ifndef MPQC_UTILITY_STRING_HPP
2 #define MPQC_UTILITY_STRING_HPP
3 
4 #include <string>
5 #include <boost/lexical_cast.hpp>
6 
7 namespace mpqc {
8 
11 
13  template <typename T>
14  std::string string_cast(const T& value) {
15  return boost::lexical_cast<std::string>(value);
16  }
17 
19  struct cstring {
20  template <typename T>
21  explicit cstring(const T& value)
22  : str_(string_cast(value)) {}
23  operator const char*() const {
24  return this->str();
25  }
26  const char* str() const {
27  return str_.c_str();
28  }
29  private:
30  std::string str_;
31  };
32 
34 
35 }
36 
37 #endif /* MPQC_UTILITY_STRING_HPP */
mpqc
Contains new MPQC code since version 3.
Definition: integralenginepool.hpp:37
mpqc::string_cast
std::string string_cast(const T &value)
cast type T to string
Definition: string.hpp:14
mpqc::cstring
cstring-like object to cast a value to const char*< > string.
Definition: string.hpp:19

Generated at Sun Jan 26 2020 23:24:01 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.8.16.