file - Simultaneously writing out an array while casting efficiently -


i have array of long doubles. want write out array of doubles, don't want create double array first (i don't have memory), , i'm worried performance.

my (naive) solution:

 file.open(filename.c_str(), std::ios::binary | std::ios::out);  if (file.is_open())  {     (auto& : out)     {         t2 ni = static_cast<t2>(i);         file.write(reinterpret_cast<const char*>(&ni), static_cast<size_t>(sizeof(t2)));     }     file.close();  } 

however, arrays i'm attempting write out, calling file.write 630,000,000 times (and since file.write creates sentry object on each instantiation, expensive). there more efficient way this?


Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -