icemanpro
V2EX  ›  C++

c++中, char* 如何转换成 std::shared_ptr<std::iostream>?

  •  
  •   icemanpro · Jul 21, 2021 · 2282 views
    This topic created in 1761 days ago, the information mentioned may be changed or developed.
    用 aliyun 的 oss sdk 上传 buff 内容,aliyun 用的是智能指针。
    5 replies    2021-07-22 08:36:02 +08:00
    ipwx
        1
    ipwx  
       Jul 21, 2021
    这里的问题不在于智能指针啊大哥。char* 和 std::iostream 八竿子打不上边

    你大概需要一个 std::istringstream 或者 std::ostringstream
    jmc891205
        2
    jmc891205  
       Jul 21, 2021
    你应该是想要用“<<"把 char*往 stream 里 insert 吧
    l00t
        3
    l00t  
       Jul 21, 2021
    智能指针 std::make_shared<std::iostream>(xxxxxxxxx)
    char* 到 iostream, 你可以找一下网上常见的那个从 char* => streambuf => istream 的转换方法,或许能用。
    然后拼起来,试试。
    nannanziyu
        4
    nannanziyu  
       Jul 21, 2021
    std::shared_ptr<std::iostream> iosp = std::make_shared<std::stringstream>("you chars");
    byaiu
        5
    byaiu  
       Jul 22, 2021 via iPhone
    这 sdk 是 header only 的吗?居然用智能指针做接口?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   951 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 22:51 · PVG 06:51 · LAX 15:51 · JFK 18:51
    ♥ Do have faith in what you're doing.