Routes stream to specified buffer

Developer Command Prompt for VS 2019

  1. cl basic_ios_rdbuf.cpp /EHsc

MSDN Source Code

  1. #include <ios>
  2. #include <iostream>
  3. #include <fstream>
  4.  
  5. int main( ) 
  6. {
  7.    using namespace std;
  8.    ofstream file( "rdbuf.txt" );
  9.    streambuf *x = cout.rdbuf( file.rdbuf( ) );
  10.    cout << "test" << endl; // Goes to file
  11.    cout.rdbuf(x);
  12.    cout << "test2" << endl; //normal
  13. }

Some built-in macros inside CMakeSettings.json:

  • ${workspaceRoot} – provides the full path to the workspace folder
  • ${workspaceHash} – hash of workspace location; useful for creating a unique identifier for the current workspace (e.g. to use in folder paths)
  • ${projectFile} – the full path for the root CMakeLists.txt
  • ${projectDir} – the full path to the folder of the root CMakeLists.txt file
  • ${thisFile} – the full path to the CMakeSettings.json file
  • ${name} – the name of the configuration
  • ${generator} – the name of the CMake generator used in this configuration