{"action":"created","comment":{"url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/comments/56848813","id":56848813,"diff_hunk":"@@ -0,0 +1,106 @@\n+// Copyright 2016 MongoDB Inc.\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+#include <map>\n+#include <vector>\n+\n+#include <bsoncxx/builder/stream/document.hpp>\n+#include <bsoncxx/builder/stream/array.hpp>\n+#include <bsoncxx/json.hpp>\n+\n+using namespace bsoncxx;\n+\n+// concatenates arbitrary ranges into an array context\n+template <typename begin_t, typename end_t>\n+class range_array_appender {\n+   public:\n+    range_array_appender(begin_t begin, end_t end) : _begin(begin), _end(end) {\n+    }\n+\n+    void operator()(bsoncxx::builder::stream::array_context<> ac) const {\n+        for (auto iter = _begin; iter != _end; ++iter) {\n+            ac << *iter;\n+        }\n+    }\n+\n+   private:\n+    begin_t _begin;\n+    end_t _end;\n+};\n+\n+template <typename begin_t, typename end_t>\n+range_array_appender<begin_t, end_t> make_range_array_appender(begin_t&& begin, end_t&& end) {\n+    return range_array_appender<begin_t, end_t>(std::forward<begin_t>(begin),\n+                                                std::forward<end_t>(end));\n+}\n+\n+// concatenates arbitrary ranges into an key context\n+template <typename begin_t, typename end_t>\n+class range_kvp_appender {\n+   public:\n+    range_kvp_appender(begin_t begin, end_t end) : _begin(begin), _end(end) {\n+    }\n+\n+    void operator()(bsoncxx::builder::stream::key_context<> ac) const {\n+        for (auto iter = _begin; iter != _end; ++iter) {\n+            ac << iter->first << iter->second;","path":"examples/bsoncxx/builder_stream_fancy.cpp","position":57,"original_position":57,"commit_id":"d9a435df41e321ea3c046be2fa69156d7262b49b","original_commit_id":"d9a435df41e321ea3c046be2fa69156d7262b49b","user":{"login":"acmorrow","id":268253,"avatar_url":"https://avatars.githubusercontent.com/u/268253?v=3","gravatar_id":"","url":"https://api.github.com/users/acmorrow","html_url":"https://github.com/acmorrow","followers_url":"https://api.github.com/users/acmorrow/followers","following_url":"https://api.github.com/users/acmorrow/following{/other_user}","gists_url":"https://api.github.com/users/acmorrow/gists{/gist_id}","starred_url":"https://api.github.com/users/acmorrow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acmorrow/subscriptions","organizations_url":"https://api.github.com/users/acmorrow/orgs","repos_url":"https://api.github.com/users/acmorrow/repos","events_url":"https://api.github.com/users/acmorrow/events{/privacy}","received_events_url":"https://api.github.com/users/acmorrow/received_events","type":"User","site_admin":false},"body":"So, the requirements on *begin_t and _end_t is that they offer members `first` and `second`, so this would only work with things that dereferce to `std::pair`. I guess that is fine. It wouldn't work with a `vector<bsoncxx::builder::basic::kvp>` or `vector<std::tuple<std::string, int>>`, but you could write a different callable for that, right?","created_at":"2016-03-21T16:08:53Z","updated_at":"2016-03-21T16:08:53Z","html_url":"https://github.com/mongodb/mongo-cxx-driver/pull/464#discussion_r56848813","pull_request_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/464","_links":{"self":{"href":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/comments/56848813"},"html":{"href":"https://github.com/mongodb/mongo-cxx-driver/pull/464#discussion_r56848813"},"pull_request":{"href":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/464"}}},"pull_request":{"url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/464","id":63122666,"html_url":"https://github.com/mongodb/mongo-cxx-driver/pull/464","diff_url":"https://github.com/mongodb/mongo-cxx-driver/pull/464.diff","patch_url":"https://github.com/mongodb/mongo-cxx-driver/pull/464.patch","issue_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/issues/464","number":464,"state":"open","locked":false,"title":"fancy stream example","user":{"login":"hanumantmk","id":150922,"avatar_url":"https://avatars.githubusercontent.com/u/150922?v=3","gravatar_id":"","url":"https://api.github.com/users/hanumantmk","html_url":"https://github.com/hanumantmk","followers_url":"https://api.github.com/users/hanumantmk/followers","following_url":"https://api.github.com/users/hanumantmk/following{/other_user}","gists_url":"https://api.github.com/users/hanumantmk/gists{/gist_id}","starred_url":"https://api.github.com/users/hanumantmk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanumantmk/subscriptions","organizations_url":"https://api.github.com/users/hanumantmk/orgs","repos_url":"https://api.github.com/users/hanumantmk/repos","events_url":"https://api.github.com/users/hanumantmk/events{/privacy}","received_events_url":"https://api.github.com/users/hanumantmk/received_events","type":"User","site_admin":false},"body":"Adds an example for adapting iterator pairs to the stream api","created_at":"2016-03-16T19:33:06Z","updated_at":"2016-03-21T16:08:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a4f6da70c269871de4809723586bf77dae9e6dd8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/464/commits","review_comments_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/464/comments","review_comment_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/issues/464/comments","statuses_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/statuses/d9a435df41e321ea3c046be2fa69156d7262b49b","head":{"label":"hanumantmk:fancy_stream_example","ref":"fancy_stream_example","sha":"d9a435df41e321ea3c046be2fa69156d7262b49b","user":{"login":"hanumantmk","id":150922,"avatar_url":"https://avatars.githubusercontent.com/u/150922?v=3","gravatar_id":"","url":"https://api.github.com/users/hanumantmk","html_url":"https://github.com/hanumantmk","followers_url":"https://api.github.com/users/hanumantmk/followers","following_url":"https://api.github.com/users/hanumantmk/following{/other_user}","gists_url":"https://api.github.com/users/hanumantmk/gists{/gist_id}","starred_url":"https://api.github.com/users/hanumantmk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanumantmk/subscriptions","organizations_url":"https://api.github.com/users/hanumantmk/orgs","repos_url":"https://api.github.com/users/hanumantmk/repos","events_url":"https://api.github.com/users/hanumantmk/events{/privacy}","received_events_url":"https://api.github.com/users/hanumantmk/received_events","type":"User","site_admin":false},"repo":{"id":17493688,"name":"mongo-cxx-driver","full_name":"hanumantmk/mongo-cxx-driver","owner":{"login":"hanumantmk","id":150922,"avatar_url":"https://avatars.githubusercontent.com/u/150922?v=3","gravatar_id":"","url":"https://api.github.com/users/hanumantmk","html_url":"https://github.com/hanumantmk","followers_url":"https://api.github.com/users/hanumantmk/followers","following_url":"https://api.github.com/users/hanumantmk/following{/other_user}","gists_url":"https://api.github.com/users/hanumantmk/gists{/gist_id}","starred_url":"https://api.github.com/users/hanumantmk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hanumantmk/subscriptions","organizations_url":"https://api.github.com/users/hanumantmk/orgs","repos_url":"https://api.github.com/users/hanumantmk/repos","events_url":"https://api.github.com/users/hanumantmk/events{/privacy}","received_events_url":"https://api.github.com/users/hanumantmk/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hanumantmk/mongo-cxx-driver","description":"C++ Driver for MongoDB","fork":true,"url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver","forks_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/forks","keys_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/teams","hooks_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/hooks","issue_events_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/issues/events{/number}","events_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/events","assignees_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/assignees{/user}","branches_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/branches{/branch}","tags_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/tags","blobs_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/languages","stargazers_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/stargazers","contributors_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/contributors","subscribers_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/subscribers","subscription_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/subscription","commits_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/contents/{+path}","compare_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/merges","archive_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/downloads","issues_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/issues{/number}","pulls_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/labels{/name}","releases_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/releases{/id}","deployments_url":"https://api.github.com/repos/hanumantmk/mongo-cxx-driver/deployments","created_at":"2014-03-06T21:43:18Z","updated_at":"2014-07-24T16:20:26Z","pushed_at":"2016-03-16T19:31:59Z","git_url":"git://github.com/hanumantmk/mongo-cxx-driver.git","ssh_url":"git@github.com:hanumantmk/mongo-cxx-driver.git","clone_url":"https://github.com/hanumantmk/mongo-cxx-driver.git","svn_url":"https://github.com/hanumantmk/mongo-cxx-driver","homepage":null,"size":4582,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mongodb:master","ref":"master","sha":"30297d4c33f3a681844751fd337e9f4a333131a8","user":{"login":"mongodb","id":45120,"avatar_url":"https://avatars.githubusercontent.com/u/45120?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"repo":{"id":15881868,"name":"mongo-cxx-driver","full_name":"mongodb/mongo-cxx-driver","owner":{"login":"mongodb","id":45120,"avatar_url":"https://avatars.githubusercontent.com/u/45120?v=3","gravatar_id":"","url":"https://api.github.com/users/mongodb","html_url":"https://github.com/mongodb","followers_url":"https://api.github.com/users/mongodb/followers","following_url":"https://api.github.com/users/mongodb/following{/other_user}","gists_url":"https://api.github.com/users/mongodb/gists{/gist_id}","starred_url":"https://api.github.com/users/mongodb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mongodb/subscriptions","organizations_url":"https://api.github.com/users/mongodb/orgs","repos_url":"https://api.github.com/users/mongodb/repos","events_url":"https://api.github.com/users/mongodb/events{/privacy}","received_events_url":"https://api.github.com/users/mongodb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mongodb/mongo-cxx-driver","description":"C++ Driver for MongoDB","fork":false,"url":"https://api.github.com/repos/mongodb/mongo-cxx-driver","forks_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/forks","keys_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/teams","hooks_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/hooks","issue_events_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/issues/events{/number}","events_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/events","assignees_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/assignees{/user}","branches_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/branches{/branch}","tags_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/tags","blobs_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/git/refs{/sha}","trees_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/statuses/{sha}","languages_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/languages","stargazers_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/stargazers","contributors_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/contributors","subscribers_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/subscribers","subscription_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/subscription","commits_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/commits{/sha}","git_commits_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/git/commits{/sha}","comments_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/comments{/number}","issue_comment_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/issues/comments{/number}","contents_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/contents/{+path}","compare_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/merges","archive_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/downloads","issues_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/issues{/number}","pulls_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls{/number}","milestones_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/milestones{/number}","notifications_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/labels{/name}","releases_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/releases{/id}","deployments_url":"https://api.github.com/repos/mongodb/mongo-cxx-driver/deployments","created_at":"2014-01-13T21:08:36Z","updated_at":"2016-03-18T14:22:07Z","pushed_at":"2016-03-18T18:48:32Z","git_url":"git://github.com/mongodb/mongo-cxx-driver.git","ssh_url":"git@github.com:mongodb/mongo-cxx-driver.git","clone_url":"https://github.com/mongodb/mongo-cxx-driver.git","svn_url":"https://github.com/mongodb/mongo-cxx-driver","homepage":null,"size":8190,"stargazers_count":247,"watchers_count":247,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":206,"mirror_url":null,"open_issues_count":6,"forks":206,"open_issues":6,"watchers":247,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/464"},"html":{"href":"https://github.com/mongodb/mongo-cxx-driver/pull/464"},"issue":{"href":"https://api.github.com/repos/mongodb/mongo-cxx-driver/issues/464"},"comments":{"href":"https://api.github.com/repos/mongodb/mongo-cxx-driver/issues/464/comments"},"review_comments":{"href":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/464/comments"},"review_comment":{"href":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mongodb/mongo-cxx-driver/pulls/464/commits"},"statuses":{"href":"https://api.github.com/repos/mongodb/mongo-cxx-driver/statuses/d9a435df41e321ea3c046be2fa69156d7262b49b"}}}}