将ptime转换为std::string
Convert ptime to std::string
如何将boost ptime转换为std字符串?我尝试了多种方法,我得到编译时错误。但根据boost的说法,这应该是可能的。
std::string function()
{
now = boost::posix_time::second_clock::local_time();
return std::string(now);
}
下面是一个简单的工作示例
查看Live On Coliru
#include "boost/date_time/posix_time/time_formatters_limited.hpp"
int main()
{
using namespace boost::posix_time;
ptime now = second_clock::local_time();
std::cout << to_simple_string(now) << std::endl;
}
相关文章:
- cppcheck在const std::string[]上引发警告
- 将std::string传递给WriteConsole API
- 为std::string的某个索引赋值
- std中有类似find_last_of的函数,而string中没有
- 使用 std::string () const 函数启动线程或未来
- 当我们进行一些操作时,应该使用什么'std::string'或'std::stringstream'?
- 如何更改大小(std::string)
- std::string 的对象真的可以移动吗?
- SegFault 同时使用 std::string::operator+= 和函数作为参数
- 无法从 std::string 中提取C++ Unicode 符号
- std::string 构造函数如何处理固定大小的 char[]?
- 确切地说,如何解释 std::getline(stream, string) 函数在C++中填充的字符串
- C++:考虑C++ std::string 中双引号 (") 的字面含义,而不使用反斜杠 (\)
- 'int main(int, int, std::__cxx11::string, std::__cxx11::string)'只需要零或两个参数 [-Wmain]
- C++ 在列表和列表之间选择返回类型<<string>std::p air<string,string>>
- std::string, std::wstring and UTF8
- uan inplace replacement of std::string/std::wstring?
- #define Glib::string std:wstring
- 从 std::string & std::wstring 中获取 char 整数值
- BSTR转换为std::string(std::wstring),反之亦然