- 176 名前:デフォルトの名無しさん [2008/01/17(木) 18:02:56 ]
- 配列の先頭を指すポインタと末尾を指すポインタのペアを返す
テンプレート関数を作成したいのですが、うまくいきません。 以下のコードはVC++6.0でもBCC5.5でもコンパイルエラーです。 正しい方法を教えてください。 #include <utility> #include <algorithm> template <class T, int n> std::pair<T*, T*> iseq(T a[n]) { return std::pair<T*, T*>(a, a + n); } int main() { int x[] = {6, 1, 3, 4, 2}; std::sort(iseq(x).first, iseq(x).second); return 0; }
|

|