私はマシンで使用Visual Studio 2010 Proしており、(ヘッダーから)でWindows 7 64bit使用したい:count<algorithm>valarray
int main()
{
valarray<bool> v(false,10);
for (int i(0);i<10;i+=3)
v[i]=true;
cout << count(&v[0],&v[10],true) << endl;
// how to define the return type of count properly?
// some_type Num=count(&v[0],&v[10],true);
}
上記のプログラムの出力は正しいです。
4
ただし、変数に値を代入したいのですが、使用するとint、精度が失われるというコンパイラの警告が表示されます。valarrayにはイテレータがないため、 の使用方法がわかりませんiterartor::difference_type。
これはどういうわけか可能ですか?