How do I use fstream::open_ostream?

Jan 7, 2017 at 8:59pm
I'm learning how to use Microsoft's cpprest sdk and no matter what I do, Visual Studio can't seem to find open_ostream. Is there a specific namespace I need to add before using open_ostream? I've never used open_ostream before.

Thanks!

Btw, I searched for open_ostream and found this explanation: https://msdn.microsoft.com/en-us/library/jj948512.aspx
...but I still don't know how to use it and Visual Studio still can't find it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

// What I'm including.

#include <fstream>
#include <opencv2\core\core.hpp>

#include <cpprest\http_client.h>
#include <cpprest\filestream.h>
#include <cpprest/http_listener.h>            
#include <cpprest/json.h>                     
#include <cpprest/uri.h>                    
#include <cpprest/ws_client.h>              
#include <cpprest/containerstream.h>            
#include <cpprest/interopstream.h>            
#include <cpprest/rawptrstream.h>          
#include <cpprest/producerconsumerstream.h> 

// in the main function, this is where I run into the open_ostream issue...
pplx::task<void> requestTask = std::fstream::open_ostream(U("results.html")).then([=](ostream outFile) 
// removed the rest of the code in order to make this message shorter 
Last edited on Jan 7, 2017 at 9:20pm
Jan 7, 2017 at 10:20pm
There is no such thing as std::fstream::open_ostream() in standard C++.

Don't confuse the Rest SDK stuff with the stuff in the standard namespace.

The bottom of the reference page you linked suggests the name of the function is ::concurrency::streams::open_ostream().
Last edited on Jan 7, 2017 at 10:27pm
Jan 7, 2017 at 10:38pm
Ahhh I feel stupid. I went back to the MS article after reading your post and noticed the namespace. I'll make sure to look more carefully next time. Thanks mbozzi!
Topic archived. No new replies allowed.