東方算程譚

Oriental Code Talk ── επιστημηが与太をこく、弾幕とは無縁のシロモノ。

目次

Blog 利用状況

ニュース

著作とお薦めの品々は

著作とお薦めの品々は
東方熱帯林へ。

あわせて読みたい

わんくま

  1. 東京勉強会#2
    C++/CLI カクテル・レシピ
  2. 東京勉強会#3
    template vs. generics
  3. 大阪勉強会#6
    C++むかしばなし
  4. 東京勉強会#7
    C++むかしばなし
  5. 東京勉強会#8
    STL/CLRによるGeneric Programming
  6. TechEd 2007 @YOKOHAMA
    C++・C++/CLI・C# 適材適所
  7. 東京勉強会#14
    Making of BOF
  8. 東京勉強会#15
    状態遷移
  9. 名古屋勉強会#2
    WinUnit - お気楽お手軽UnitTest

CodeZine

  1. Cで実現する「ぷちオブジェクト指向」
  2. CUnitによるテスト駆動開発
  3. SQLiteで組み込みDB体験(2007年版)
  4. C++/CLIによるCライブラリの.NET化
  5. C# 1.1からC# 3.0まで~言語仕様の進化
  6. BoostでC++0xのライブラリ「TR1」を先取りしよう (1)
  7. BoostでC++0xのライブラリ「TR1」を先取りしよう (2)
  8. BoostでC++0xのライブラリ「TR1」を先取りしよう (3)
  9. BoostでC++0xのライブラリ「TR1」を先取りしよう (4)
  10. BoostでC++0xのライブラリ「TR1」を先取りしよう (5)
  11. C/C++に対応した、もうひとつのUnitTestFramework ─ WinUnit
  12. SQLiteで"おこづかいちょう"
  13. STL/CLRツアーガイド
  14. マージ・ソート : 巨大データのソート法
  15. ヒープソートのアルゴリズム
  16. C++0xの新機能「ラムダ式」を次期Visual Studioでいち早く試す
  17. .NETでマンデルブロ集合を描く
  18. .NETでマンデルブロ集合を描く(後日談)
  19. C++/CLI : とある文字列の相互変換(コンバージョン)
  20. インテルTBBによる選択ソートの高速化
  21. インテルTBB3.0 によるパイプライン処理
  22. Visual C++ 2010に追加されたSTLアルゴリズム
  23. Visual C++ 2010に追加されたSTLコンテナ「forward_list」
  24. shared_ptrによるObserverパターンの実装
  25. .NETでマンデルブロ集合を描く(番外編) ── OpenCLで超並列コンピューティング
  26. StateパターンでCSVを読む
  27. 状態遷移表からStateパターンを自動生成する
  28. 「ソートも、サーチも、あるんだよ」~標準C++ライブラリにみるアルゴリズムの面白さ
  29. インテルTBBの同期メカニズム
  30. なぜsetを使っちゃいけないの?
  31. WPFアプリケーションで腕試し ~C++でもWPFアプリを
  32. C++11 : スレッド・ライブラリひとめぐり
  33. Google製のC++ Unit Test Framework「Google Test」を使ってみる
  34. メールでデータベースを更新するココロミ
  35. Visitorパターンで遊んでみたよ
  36. Collection 2題:「WPFにバインドできる辞書」と「重複を許す検索set」
  37. Visual C++ 2012:stateless-lambdaとSQLiteのぷち拡張
  38. 「Visual C++ Compiler November 2012 CTP」で追加された6つの新機能

@IT

  1. Vista時代のVisual C++の流儀(前編)Vista到来。既存C/C++資産の.NET化を始めよう!
  2. Vista時代のVisual C++の流儀(中編)MFCから.NETへの実践的移行計画
  3. Vista時代のVisual C++の流儀(後編) STL/CLRによるDocument/Viewアーキテクチャ
  4. C++開発者のための単体テスト入門 第1回 C++開発者の皆さん。テスト、ちゃんとしていますか?
  5. C++開発者のための単体テスト入門 第2回 C++アプリケーションの効率的なテスト手法(CppUnit編)
  6. C++開発者のための単体テスト入門 第3回 C++アプリケーションの効率的なテスト手法(NUnit編)

AWARDS


Microsoft MVP
for Visual Developer - Visual C++


Wankuma MVP
for いぢわる C++


Nyantora MVP
for こくまろ中国茶

Xbox

Links

記事カテゴリ

書庫

日記カテゴリ

うっそぉ~ん! (そのに)

ネタ元 → うっそぉ~ん!

microsoftのぶっとび独自拡張:「STLコンテナにfor eachできる」件、
気になってごにょごにょ調べてました。
debugモードで実行し、アセンブラ・コードを眺めたところ、

for each ( type item in container ) { ... }
ってなコードを↓に内部的に置き換えてるみたい。

iterator first = container.begin();
iterator last = container.end();
while ( first != last ) {
  type item = *first;
  …
  ++first;
}

ならばこいつを逆手に取って、STLコンテナじゃなくても for each できっかもしんね。
ダメ元でやってみた:

#include <iostream>

class loop {
 int* array_;
 int size_;
public:
 int* begin() const { return array_; } // こっから
 int* end() const { return array_+size_; } // ここまで
 loop(int s) : size_(s) {
   array_ = new int[s];
   for ( int i = 0 ; i < size_; ++i ) {
    array_[i] =i;
   }
 }
 ~loop() { delete[] array_; }
};

int main() {
  for each ( int item in loop(5) ) {
    std::cout << item << std::endl;
  }
}

きゃっほー 動きやがんの。
containerがbegin()/end()を持ってて、
そいつらがiterator的なものを返せばなんだっていいみたいだぉ

投稿日時 : 2007年8月26日 1:46

コメントを追加

# re: うっそぉ~ん! (そのに) 2007/08/26 21:06 tyato

おおお!いいこと聞いちゃった!

# re: うっそぉ~ん! (そのに) 2007/08/27 0:05 アキラ

iterator/const_iteratorを持ってる必要はなかったんですね

VC++9.0では配列もfor eachできますが、そのへんはどうなってるんでしょうね

# re: うっそぉ~ん! (そのに) 2007/08/27 0:22 επιστημη

配列のfor eachは、与えた配列の大きさがわかっている場合に限られるみたいす(当然ながら

// これはおっけ。
void print(int data[4]) {
  for each ( int item in data ) {
   std::cout << item << std::endl;
  }
}

// これはコンパイル・エラー。
void print(int data[]) {
  for each ( int item in data ) {
   std::cout << item << std::endl;
  }
}

# re: うっそぉ~ん! (そのに) 2007/08/27 7:50 ゆーち

まったく違うあたりにコメント。(^◇^;

>debugモードで実行し、アセンブラ・コードを眺めたところ、

そんなことしなくなりました(笑

# re: うっそぉ~ん! (そのに) 2007/08/27 11:45 επιστημη

ぁぃ、そんなことしたのは5年ぶりくらいでしょうか(枯藁

# [C++]for each 2007/09/06 11:57 melt日記

[C++]for each

# [C++]for each 2007/09/06 12:03 melt日記

[C++]for each

# re: うっそぉ~ん! (そのに) 2007/09/06 22:50 渋木宏明(ひどり)

配列も列挙出ちゃうのはすごいな。。。(いろんな意味で)

せめてキーワードを __foreach にしておけばいいのに (^^; > ms

# Your method of describing the whole thing in this article is truly good, every one be capable of effortlessly be aware of it, Thanks a lot. 2017/08/02 14:06 Your method of describing the whole thing in this

Your method of describing the whole thing in this
article is truly good, every one be capable of effortlessly be aware of it, Thanks a lot.

# Hello there! I know this is kind of off topic but I was wondering if you knew where I could locate a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having difficulty finding one? Thanks a lot! 2017/08/10 4:31 Hello there! I know this is kind of off topic but

Hello there! I know this is kind of off topic but I was wondering if you knew where I could locate
a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having difficulty finding
one? Thanks a lot!

# Hi there, I wish for to subscribe for this blog to get hottest updates, thus where can i do it please help out. 2017/08/10 14:16 Hi there, I wish for to subscribe for this blog to

Hi there, I wish for to subscribe for this blog to get hottest
updates, thus where can i do it please help out.

# fantastic publish, very informative. I wonder why the opposite experts of this sector don't notice this. You should continue your writing. I am confident, you've a huge readers' base already! 2017/08/10 18:39 fantastic publish, very informative. I wonder why

fantastic publish, very informative. I wonder why the opposite
experts of this sector don't notice this. You
should continue your writing. I am confident, you've a huge readers' base already!

# Great article. I will be going through some of these issues as well.. 2017/08/10 23:39 Great article. I will be going through some of the

Great article. I will be going through some of these issues as well..

# What's up, just wanted to say, I liked this post. It was funny. Keep on posting! 2017/08/14 19:52 What's up, just wanted to say, I liked this post.

What's up, just wanted to say, I liked this post. It was funny.

Keep on posting!

# Hi colleagues, how is the whole thing, and what you want to say regarding this post, in my view its in fact remarkable in support of me. 2017/08/14 23:33 Hi colleagues, how is the whole thing, and what yo

Hi colleagues, how is the whole thing, and what you want to say
regarding this post, in my view its in fact remarkable in support of me.

# I am genuinely grateful to the owner of this site who has shared this enormous post at at this time. 2017/08/16 11:21 I am genuinely grateful to the owner of this site

I am genuinely grateful to the owner of this site who has shared
this enormous post at at this time.

# This piece of writing will assist the internet visitors for creating new webpage or even a blog from start to end. 2017/08/16 15:06 This piece of writing will assist the internet vis

This piece of writing will assist the internet visitors
for creating new webpage or even a blog from start
to end.

# Wonderful beat ! I wish to apprentice even as you amend your website, how can i subscribe for a weblog website? The account aided me a appropriate deal. I had been tiny bit familiar of this your broadcast provided bright clear idea 2017/08/17 13:17 Wonderful beat ! I wish to apprentice even as you

Wonderful beat ! I wish to apprentice even as you amend your website, how can i subscribe for a weblog website?
The account aided me a appropriate deal. I had been tiny bit familiar
of this your broadcast provided bright clear idea

# I like the valuable info you provide in your articles. I will bookmark your weblog and check again here regularly. I am quite sure I'll learn lots of new stuff right here! Good luck for the next! 2017/08/24 18:16 I like the valuable info you provide in your artic

I like the valuable info you provide in your articles.

I will bookmark your weblog and check again here regularly.

I am quite sure I'll learn lots of new stuff right here!
Good luck for the next!

# I am not sure where you're getting your info, but good topic. I needs to spend some time learning much more or understanding more. Thanks for great info I was looking for this information for my mission. 2017/10/30 20:33 I am not sure where you're getting your info, but

I am not sure where you're getting your info, but good topic.
I needs to spend some time learning much more or understanding more.
Thanks for great info I was looking for this information for my mission.

# I am really loving the theme/design of your website. Do you ever run into any internet browser compatibility problems? A small number of my blog audience have complained about my site not working correctly in Explorer but looks great in Safari. Do you ha 2017/11/06 14:30 I am really loving the theme/design of your websit

I am really loving the theme/design of your website.

Do you ever run into any internet browser compatibility problems?

A small number of my blog audience have complained about my site not working
correctly in Explorer but looks great in Safari. Do you have any suggestions to help
fix this issue?

# My spouse and I stumbled over here from a different website and thought I may as well check things out. I like what I see so now i am following you. Look forward to exploring your web page again. 2017/11/16 15:52 My spouse and I stumbled over here from a differe

My spouse and I stumbled over here from a different website and
thought I may as well check things out. I like what I see so now
i am following you. Look forward to exploring your web page again.

# Very good write-up. I certainly love this website. Keep it up! 2017/12/04 7:28 Very good write-up. I certainly love this website.

Very good write-up. I certainly love this website.
Keep it up!

# Greetings! Very useful advice in this particular article! It is the little changes that will make the biggest changes. Thanks for sharing! 2018/04/17 9:06 Greetings! Very useful advice in this particular a

Greetings! Very useful advice in this particular article!
It is the little changes that will make the biggest changes.
Thanks for sharing!

# I'd like to find out more? I'd love to find out some additional information. 2018/09/17 23:22 I'd like to find out more? I'd love to find out so

I'd like to find out more? I'd love to find out some additional information.

# Hello everyone, it's my first pay a quick visit at this site, and article is in fact fruitful in support of me, keep up posting these posts. 2018/10/01 13:01 Hello everyone, it's my first pay a quick visit at

Hello everyone, it's my first pay a quick visit at this site,
and article is in fact fruitful in support of me, keep up posting these
posts.

# It is the best time to make some plans for the future and it is time to be happy. I've learn this post and if I could I wish to recommend you some fascinating things or tips. Perhaps you can write subsequent articles relating to this article. I desire t 2018/10/01 21:53 It is the best time to make some plans for the fut

It is the best time to make some plans for the future and it is time to be
happy. I've learn this post and if I could I wish to recommend you some fascinating things or tips.
Perhaps you can write subsequent articles relating to this
article. I desire to learn more things approximately it!

# Thanks for any other informative website. The place else may just I get that type of info written in such an ideal method? I have a mission that I am simply now working on, and I have been on the look out for such information. 2018/10/02 16:03 Thanks for any other informative website. The pla

Thanks for any other informative website. The place else may just
I get that type of info written in such an ideal method?
I have a mission that I am simply now working
on, and I have been on the look out for such information.

# Hey there! I realize this is kind of off-topic but I needed to ask. Does running a well-established blog like yours require a lot of work? I am brand new to writing a blog however I do write in my diary every day. I'd like to start a blog so I can share 2018/11/02 20:48 Hey there! I realize this is kind of off-topic but

Hey there! I realize this is kind of off-topic but I needed to ask.
Does running a well-established blog like yours require a lot
of work? I am brand new to writing a blog however I do write in my diary every
day. I'd like to start a blog so I can share my personal experience and thoughts
online. Please let me know if you have any recommendations or
tips for brand new aspiring bloggers. Thankyou!

# WOW just what I was searching for. Came here by searching for here 2021/08/01 7:08 WOW just what I was searching for. Came here by se

WOW just what I was searching for. Came here by searching for here

# Wow that was strange. I just wrote an really long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Regardless, just wanted to say excellent blog! 2021/08/03 14:43 Wow that was strange. I just wrote an really long

Wow that was strange. I just wrote an really long comment but after
I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over
again. Regardless, just wanted to say excellent blog!

# You could definitely see your enthusiasm in the work you write. The arena hopes for more passionate writers such as you who aren't afraid to mention how they believe. At all times go after your heart. 2021/08/23 19:21 You could definitely see your enthusiasm in the w

You could definitely see your enthusiasm in the work you write.
The arena hopes for more passionate writers such as you who aren't afraid to mention how they believe.
At all times go after your heart.

# You could definitely see your enthusiasm in the work you write. The arena hopes for more passionate writers such as you who aren't afraid to mention how they believe. At all times go after your heart. 2021/08/23 19:22 You could definitely see your enthusiasm in the w

You could definitely see your enthusiasm in the work you write.
The arena hopes for more passionate writers such as you who aren't afraid to mention how they believe.
At all times go after your heart.

# You could definitely see your enthusiasm in the work you write. The arena hopes for more passionate writers such as you who aren't afraid to mention how they believe. At all times go after your heart. 2021/08/23 19:23 You could definitely see your enthusiasm in the w

You could definitely see your enthusiasm in the work you write.
The arena hopes for more passionate writers such as you who aren't afraid to mention how they believe.
At all times go after your heart.

# You could definitely see your enthusiasm in the work you write. The arena hopes for more passionate writers such as you who aren't afraid to mention how they believe. At all times go after your heart. 2021/08/23 19:24 You could definitely see your enthusiasm in the w

You could definitely see your enthusiasm in the work you write.
The arena hopes for more passionate writers such as you who aren't afraid to mention how they believe.
At all times go after your heart.

# Spot on with this write-up, I seriously believe this web site needs much more attention. I'll probably be returning to read through more, thanks for the information! 2021/09/02 5:38 Spot on with this write-up, I seriously believe th

Spot on with this write-up, I seriously believe this web
site needs much more attention. I'll probably be returning to read through more, thanks for the information!

# Spot on with this write-up, I seriously believe this web site needs much more attention. I'll probably be returning to read through more, thanks for the information! 2021/09/02 5:39 Spot on with this write-up, I seriously believe th

Spot on with this write-up, I seriously believe this web
site needs much more attention. I'll probably be returning to read through more, thanks for the information!

# Spot on with this write-up, I seriously believe this web site needs much more attention. I'll probably be returning to read through more, thanks for the information! 2021/09/02 5:40 Spot on with this write-up, I seriously believe th

Spot on with this write-up, I seriously believe this web
site needs much more attention. I'll probably be returning to read through more, thanks for the information!

# Spot on with this write-up, I seriously believe this web site needs much more attention. I'll probably be returning to read through more, thanks for the information! 2021/09/02 5:41 Spot on with this write-up, I seriously believe th

Spot on with this write-up, I seriously believe this web
site needs much more attention. I'll probably be returning to read through more, thanks for the information!

# You've made some good points there. I looked on the web for more information about the issue and found most individuals will go along with your views on this website. 2021/09/04 11:34 You've made some good points there. I looked on th

You've made some good points there. I looked on the web for
more information about the issue and found most individuals will go along with your
views on this website.

# You've made some good points there. I looked on the web for more information about the issue and found most individuals will go along with your views on this website. 2021/09/04 11:35 You've made some good points there. I looked on th

You've made some good points there. I looked on the web for
more information about the issue and found most individuals will go along with your
views on this website.

# You've made some good points there. I looked on the web for more information about the issue and found most individuals will go along with your views on this website. 2021/09/04 11:36 You've made some good points there. I looked on th

You've made some good points there. I looked on the web for
more information about the issue and found most individuals will go along with your
views on this website.

# You've made some good points there. I looked on the web for more information about the issue and found most individuals will go along with your views on this website. 2021/09/04 11:37 You've made some good points there. I looked on th

You've made some good points there. I looked on the web for
more information about the issue and found most individuals will go along with your
views on this website.

# Wow! In the end I got a blog from where I know how to in fact take helpful data concerning my study and knowledge. scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery 2021/09/14 9:55 Wow! In the end I got a blog from where I know how

Wow! In the end I got a blog from where I know how to in fact take helpful data concerning my study and knowledge.
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis
surgery

# Wow! In the end I got a blog from where I know how to in fact take helpful data concerning my study and knowledge. scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery 2021/09/14 9:56 Wow! In the end I got a blog from where I know how

Wow! In the end I got a blog from where I know how to in fact take helpful data concerning my study and knowledge.
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis
surgery

# Wow! In the end I got a blog from where I know how to in fact take helpful data concerning my study and knowledge. scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery 2021/09/14 9:57 Wow! In the end I got a blog from where I know how

Wow! In the end I got a blog from where I know how to in fact take helpful data concerning my study and knowledge.
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis
surgery

# Wow! In the end I got a blog from where I know how to in fact take helpful data concerning my study and knowledge. scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery 2021/09/14 9:58 Wow! In the end I got a blog from where I know how

Wow! In the end I got a blog from where I know how to in fact take helpful data concerning my study and knowledge.
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis
surgery

# Wow that was odd. I just wrote an extremely long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Regardless, just wanted to say superb blog! 2021/10/25 13:53 Wow that was odd. I just wrote an extremely long c

Wow that was odd. I just wrote an extremely long comment but after
I clicked submit my comment didn't appear. Grrrr... well I'm not writing
all that over again. Regardless, just wanted to say superb blog!

# Your mode of explaining everything in this paragraph is actually good, all can without difficulty know it, Thanks a lot. 2021/11/12 9:43 Your mode of explaining everything in this paragra

Your mode of explaining everything in this paragraph is actually
good, all can without difficulty know it, Thanks a lot.

# Good day! I could have sworn I've been to this site before but after reading through some of the post I realized it's new to me. Anyways, I'm definitely glad I found it and I'll be bookmarking and checking back frequently! 2022/03/23 17:42 Good day! I could have sworn I've been to this sit

Good day! I could have sworn I've been to this site before but after reading through some of the post I realized it's new to me.
Anyways, I'm definitely glad I found it and I'll be bookmarking and checking back frequently!

# Good day! I could have sworn I've been to this site before but after reading through some of the post I realized it's new to me. Anyways, I'm definitely glad I found it and I'll be bookmarking and checking back frequently! 2022/03/23 17:43 Good day! I could have sworn I've been to this sit

Good day! I could have sworn I've been to this site before but after reading through some of the post I realized it's new to me.
Anyways, I'm definitely glad I found it and I'll be bookmarking and checking back frequently!

# Good day! I could have sworn I've been to this site before but after reading through some of the post I realized it's new to me. Anyways, I'm definitely glad I found it and I'll be bookmarking and checking back frequently! 2022/03/23 17:44 Good day! I could have sworn I've been to this sit

Good day! I could have sworn I've been to this site before but after reading through some of the post I realized it's new to me.
Anyways, I'm definitely glad I found it and I'll be bookmarking and checking back frequently!

# Good day! I could have sworn I've been to this site before but after reading through some of the post I realized it's new to me. Anyways, I'm definitely glad I found it and I'll be bookmarking and checking back frequently! 2022/03/23 17:45 Good day! I could have sworn I've been to this sit

Good day! I could have sworn I've been to this site before but after reading through some of the post I realized it's new to me.
Anyways, I'm definitely glad I found it and I'll be bookmarking and checking back frequently!

# It's an remarkable paragraph designed for all the online users; they will take benefit from it I am sure. 2022/03/27 10:43 It's an remarkable paragraph designed for all the

It's an remarkable paragraph designed for all the online users; they will take benefit from it I am sure.

タイトル
名前
URL
コメント