istream_iterator<T>は、operator >> でTを読むため、streamからcharを読み出すとき、
バイナリであろうとなかろうと空白文字(空白/タブ/改行etc)を読み飛ばす。
従って、バイナリで読み込みたい場合はistreambuf_iteratorを使う。
#include <string>
#include <fstream>
#include <iterator>
#include <algorithm>
#include <iostream>
using namespace std;

void copy( const string &in, const string &out )
{
    ifstream ifs(  in.c_str(), ios::binary );
    ofstream ofs( out.c_str(), ios::binary );
    
    copy( istreambuf_iterator<char>( ifs ),
          istreambuf_iterator<char>(),
          std::ostream_iterator<char>( ofs ) );
}

int main()
{
    copy( "A.dat", "B.dat" );
    
    return 0;
}
※試しに書いてみたらめっさ遅いのでたぶん使えない。
ファイルサイズが小さく、かつ簡潔にかきたいときだけ。
最終更新:2007年01月22日 15:59