{"action":"created","comment":{"url":"https://api.github.com/repos/dealii/dealii/pulls/comments/48169489","id":48169489,"diff_hunk":"@@ -0,0 +1,219 @@\n+// ---------------------------------------------------------------------\n+//\n+// Copyright (C) 2004 - 2015 by the deal.II authors\n+//\n+// This file is part of the deal.II library.\n+//\n+// The deal.II library is free software; you can use it, redistribute\n+// it, and/or modify it under the terms of the GNU Lesser General\n+// Public License as published by the Free Software Foundation; either\n+// version 2.1 of the License, or (at your option) any later version.\n+// The full text of the license can be found in the file LICENSE at\n+// the top level of the deal.II distribution.\n+//\n+// ---------------------------------------------------------------------\n+\n+#ifndef dealii__array_view_h\n+#define dealii__array_view_h\n+\n+#include <deal.II/base/config.h>\n+#include <deal.II/base/exceptions.h>\n+#include <boost/type_traits/remove_cv.hpp>\n+#include <boost/type_traits/is_same.hpp>\n+#include <boost/utility/enable_if.hpp>\n+\n+#include <vector>\n+\n+DEAL_II_NAMESPACE_OPEN\n+\n+\n+/**\n+ * A class that represents a window of memory locations of type\n+ * @p ElementType and presents it as if it was an array that\n+ * can be accessed via an <code>operator[]</code>. In essence,\n+ * this class is nothing more than just a pointer to the first\n+ * location and an integer that represents the length of the array\n+ * in elements.\n+ *\n+ * The advantage of using this class is that you don't have to pass\n+ * around pairs of pointers and that <code>operator[]</code> checks\n+ * for the validity of the index with which you subscript this\n+ * array view.\n+ *\n+ * This class can handle views to both non-constant and constant memory\n+ * locations. If you want to represent a view of a constant array,\n+ * then the template argument type of this class needs to be\n+ * @p const as well. The following code snippet gives an example:\n+ * @code\n+ *   std::vector<int>       array       = get_data();  // a writable array\n+ *\n+ *   ArrayView<int> view (&array[5], 5);               // a view of elements 5..9 (inclusive)\n+ *   view[2] = 42;                                     // array[7] is set to 42\n+ *\n+ *   ArrayView<const int> const_view (&array[5], 5);   // same view, but read-only\n+ *   int element_7 = const_view[2];                    // returns 42\n+ *   const_view[2] = 42;                               // error, can't write into this view\n+ * @endcode\n+ *\n+ * @ingroup data\n+ * @author Wolfgang Bangerth, 2015\n+ */\n+template <typename ElementType>\n+class ArrayView\n+{\n+public:\n+  /**\n+   * A typedef that denotes the \"value_type\" of this container-like\n+   * class, i.e., the type of the element it \"stores\" or points to.\n+   */\n+  typedef ElementType value_type;\n+\n+  /**\n+   * Constructor.\n+   * @param[in] starting_element A pointer to the first element of the array\n+   *   this object should represent.\n+   * @param[in] n_elements The length (in elements) of the chunk of memory\n+   *   this object should represent.\n+   */\n+  ArrayView (value_type       *starting_element,\n+             const std::size_t n_elements);\n+\n+  /**\n+   * Copy constructor from array views that point to non-@p const elements. If\n+   * the current object will point to non-@p const elements, then this is a\n+   * straight forward copy constructor. On the other hand, if the current type's\n+   * @p ElementType template argument is a @p const qualified type, then the\n+   * current constructor is a conversion constructor that converts a\n+   * non-@p const view to a @p const view, akin to converting a non-@p const\n+   * pointer to a @p const pointer.\n+   */\n+  ArrayView (const ArrayView<typename boost::remove_cv<value_type>::type> &view);\n+\n+  ArrayView (std::vector<typename boost::remove_cv<value_type>::type> &view);\n+\n+  /**\n+   * Return the size (in elements) of the view of memory this object\n+   * represents.\n+   */\n+  std::size_t size() const;\n+\n+  /**\n+   * Access an element of a constant slice using the same interface as","path":"include/deal.II/base/array_view.h","position":101,"original_position":101,"commit_id":"6856ff002fe0f283c1645d16c45b68ab4f9d1059","original_commit_id":"6856ff002fe0f283c1645d16c45b68ab4f9d1059","user":{"login":"bangerth","id":7504421,"avatar_url":"https://avatars.githubusercontent.com/u/7504421?v=3","gravatar_id":"","url":"https://api.github.com/users/bangerth","html_url":"https://github.com/bangerth","followers_url":"https://api.github.com/users/bangerth/followers","following_url":"https://api.github.com/users/bangerth/following{/other_user}","gists_url":"https://api.github.com/users/bangerth/gists{/gist_id}","starred_url":"https://api.github.com/users/bangerth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bangerth/subscriptions","organizations_url":"https://api.github.com/users/bangerth/orgs","repos_url":"https://api.github.com/users/bangerth/repos","events_url":"https://api.github.com/users/bangerth/events{/privacy}","received_events_url":"https://api.github.com/users/bangerth/received_events","type":"User","site_admin":false},"body":"Yes, copy-paste from the `VectorSlice` class. I'll fix it there as well.","created_at":"2015-12-21T17:36:24Z","updated_at":"2015-12-21T17:36:24Z","html_url":"https://github.com/dealii/dealii/pull/1998#discussion_r48169489","pull_request_url":"https://api.github.com/repos/dealii/dealii/pulls/1998","_links":{"self":{"href":"https://api.github.com/repos/dealii/dealii/pulls/comments/48169489"},"html":{"href":"https://github.com/dealii/dealii/pull/1998#discussion_r48169489"},"pull_request":{"href":"https://api.github.com/repos/dealii/dealii/pulls/1998"}}},"pull_request":{"url":"https://api.github.com/repos/dealii/dealii/pulls/1998","id":54219376,"html_url":"https://github.com/dealii/dealii/pull/1998","diff_url":"https://github.com/dealii/dealii/pull/1998.diff","patch_url":"https://github.com/dealii/dealii/pull/1998.patch","issue_url":"https://api.github.com/repos/dealii/dealii/issues/1998","number":1998,"state":"open","locked":false,"title":"Add an ArrayView class.","user":{"login":"bangerth","id":7504421,"avatar_url":"https://avatars.githubusercontent.com/u/7504421?v=3","gravatar_id":"","url":"https://api.github.com/users/bangerth","html_url":"https://github.com/bangerth","followers_url":"https://api.github.com/users/bangerth/followers","following_url":"https://api.github.com/users/bangerth/following{/other_user}","gists_url":"https://api.github.com/users/bangerth/gists{/gist_id}","starred_url":"https://api.github.com/users/bangerth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bangerth/subscriptions","organizations_url":"https://api.github.com/users/bangerth/orgs","repos_url":"https://api.github.com/users/bangerth/repos","events_url":"https://api.github.com/users/bangerth/events{/privacy}","received_events_url":"https://api.github.com/users/bangerth/received_events","type":"User","site_admin":false},"body":"As mentioned in #1241, the current VectorSlice class has the significant\nflaw that it uses the type of the underlying container as its template\nargument. Consequently, wherever it is used as a function argument, the\nfunction can only be called with a very particular container to which we\ncreate a view. This is the case even if the underlying class doesn't\nactually care about the underlying type at all. An example would be if\nyou wanted to call a function with a view into an array as opposed to a\nview into a std::vector -- which currently doesn't work.\n\nThis patch adds a class ArrayView that does not suffer from this\nlimitation. I've looked around in BOOST to see whether they have\nsuch a class, but they don't seem to. There's also nothing in C++14,\nso I wrote a simple class of this kind myself.\n\nI have a follow-up patch once this is accepted to convert the\nargument type of the various Mapping::transform() functions\nto ArrayView, and this should then make it easy to address\n#1241.\n\nIn partial reference to #1198.","created_at":"2015-12-21T04:16:23Z","updated_at":"2015-12-21T17:36:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dealii/dealii/pulls/1998/commits","review_comments_url":"https://api.github.com/repos/dealii/dealii/pulls/1998/comments","review_comment_url":"https://api.github.com/repos/dealii/dealii/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dealii/dealii/issues/1998/comments","statuses_url":"https://api.github.com/repos/dealii/dealii/statuses/6856ff002fe0f283c1645d16c45b68ab4f9d1059","head":{"label":"bangerth:add-array-view","ref":"add-array-view","sha":"6856ff002fe0f283c1645d16c45b68ab4f9d1059","user":{"login":"bangerth","id":7504421,"avatar_url":"https://avatars.githubusercontent.com/u/7504421?v=3","gravatar_id":"","url":"https://api.github.com/users/bangerth","html_url":"https://github.com/bangerth","followers_url":"https://api.github.com/users/bangerth/followers","following_url":"https://api.github.com/users/bangerth/following{/other_user}","gists_url":"https://api.github.com/users/bangerth/gists{/gist_id}","starred_url":"https://api.github.com/users/bangerth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bangerth/subscriptions","organizations_url":"https://api.github.com/users/bangerth/orgs","repos_url":"https://api.github.com/users/bangerth/repos","events_url":"https://api.github.com/users/bangerth/events{/privacy}","received_events_url":"https://api.github.com/users/bangerth/received_events","type":"User","site_admin":false},"repo":{"id":22048720,"name":"dealii","full_name":"bangerth/dealii","owner":{"login":"bangerth","id":7504421,"avatar_url":"https://avatars.githubusercontent.com/u/7504421?v=3","gravatar_id":"","url":"https://api.github.com/users/bangerth","html_url":"https://github.com/bangerth","followers_url":"https://api.github.com/users/bangerth/followers","following_url":"https://api.github.com/users/bangerth/following{/other_user}","gists_url":"https://api.github.com/users/bangerth/gists{/gist_id}","starred_url":"https://api.github.com/users/bangerth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bangerth/subscriptions","organizations_url":"https://api.github.com/users/bangerth/orgs","repos_url":"https://api.github.com/users/bangerth/repos","events_url":"https://api.github.com/users/bangerth/events{/privacy}","received_events_url":"https://api.github.com/users/bangerth/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bangerth/dealii","description":"","fork":true,"url":"https://api.github.com/repos/bangerth/dealii","forks_url":"https://api.github.com/repos/bangerth/dealii/forks","keys_url":"https://api.github.com/repos/bangerth/dealii/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bangerth/dealii/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bangerth/dealii/teams","hooks_url":"https://api.github.com/repos/bangerth/dealii/hooks","issue_events_url":"https://api.github.com/repos/bangerth/dealii/issues/events{/number}","events_url":"https://api.github.com/repos/bangerth/dealii/events","assignees_url":"https://api.github.com/repos/bangerth/dealii/assignees{/user}","branches_url":"https://api.github.com/repos/bangerth/dealii/branches{/branch}","tags_url":"https://api.github.com/repos/bangerth/dealii/tags","blobs_url":"https://api.github.com/repos/bangerth/dealii/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bangerth/dealii/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bangerth/dealii/git/refs{/sha}","trees_url":"https://api.github.com/repos/bangerth/dealii/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bangerth/dealii/statuses/{sha}","languages_url":"https://api.github.com/repos/bangerth/dealii/languages","stargazers_url":"https://api.github.com/repos/bangerth/dealii/stargazers","contributors_url":"https://api.github.com/repos/bangerth/dealii/contributors","subscribers_url":"https://api.github.com/repos/bangerth/dealii/subscribers","subscription_url":"https://api.github.com/repos/bangerth/dealii/subscription","commits_url":"https://api.github.com/repos/bangerth/dealii/commits{/sha}","git_commits_url":"https://api.github.com/repos/bangerth/dealii/git/commits{/sha}","comments_url":"https://api.github.com/repos/bangerth/dealii/comments{/number}","issue_comment_url":"https://api.github.com/repos/bangerth/dealii/issues/comments{/number}","contents_url":"https://api.github.com/repos/bangerth/dealii/contents/{+path}","compare_url":"https://api.github.com/repos/bangerth/dealii/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bangerth/dealii/merges","archive_url":"https://api.github.com/repos/bangerth/dealii/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bangerth/dealii/downloads","issues_url":"https://api.github.com/repos/bangerth/dealii/issues{/number}","pulls_url":"https://api.github.com/repos/bangerth/dealii/pulls{/number}","milestones_url":"https://api.github.com/repos/bangerth/dealii/milestones{/number}","notifications_url":"https://api.github.com/repos/bangerth/dealii/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bangerth/dealii/labels{/name}","releases_url":"https://api.github.com/repos/bangerth/dealii/releases{/id}","created_at":"2014-07-21T02:07:57Z","updated_at":"2015-05-08T16:15:38Z","pushed_at":"2015-12-21T04:32:54Z","git_url":"git://github.com/bangerth/dealii.git","ssh_url":"git@github.com:bangerth/dealii.git","clone_url":"https://github.com/bangerth/dealii.git","svn_url":"https://github.com/bangerth/dealii","homepage":null,"size":129530,"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":"dealii:master","ref":"master","sha":"a04bbac094b363c23b8e24af9656ffb89aa55efc","user":{"login":"dealii","id":7506070,"avatar_url":"https://avatars.githubusercontent.com/u/7506070?v=3","gravatar_id":"","url":"https://api.github.com/users/dealii","html_url":"https://github.com/dealii","followers_url":"https://api.github.com/users/dealii/followers","following_url":"https://api.github.com/users/dealii/following{/other_user}","gists_url":"https://api.github.com/users/dealii/gists{/gist_id}","starred_url":"https://api.github.com/users/dealii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dealii/subscriptions","organizations_url":"https://api.github.com/users/dealii/orgs","repos_url":"https://api.github.com/users/dealii/repos","events_url":"https://api.github.com/users/dealii/events{/privacy}","received_events_url":"https://api.github.com/users/dealii/received_events","type":"Organization","site_admin":false},"repo":{"id":21943980,"name":"dealii","full_name":"dealii/dealii","owner":{"login":"dealii","id":7506070,"avatar_url":"https://avatars.githubusercontent.com/u/7506070?v=3","gravatar_id":"","url":"https://api.github.com/users/dealii","html_url":"https://github.com/dealii","followers_url":"https://api.github.com/users/dealii/followers","following_url":"https://api.github.com/users/dealii/following{/other_user}","gists_url":"https://api.github.com/users/dealii/gists{/gist_id}","starred_url":"https://api.github.com/users/dealii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dealii/subscriptions","organizations_url":"https://api.github.com/users/dealii/orgs","repos_url":"https://api.github.com/users/dealii/repos","events_url":"https://api.github.com/users/dealii/events{/privacy}","received_events_url":"https://api.github.com/users/dealii/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dealii/dealii","description":"The development repository for the deal.II finite element library.","fork":false,"url":"https://api.github.com/repos/dealii/dealii","forks_url":"https://api.github.com/repos/dealii/dealii/forks","keys_url":"https://api.github.com/repos/dealii/dealii/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dealii/dealii/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dealii/dealii/teams","hooks_url":"https://api.github.com/repos/dealii/dealii/hooks","issue_events_url":"https://api.github.com/repos/dealii/dealii/issues/events{/number}","events_url":"https://api.github.com/repos/dealii/dealii/events","assignees_url":"https://api.github.com/repos/dealii/dealii/assignees{/user}","branches_url":"https://api.github.com/repos/dealii/dealii/branches{/branch}","tags_url":"https://api.github.com/repos/dealii/dealii/tags","blobs_url":"https://api.github.com/repos/dealii/dealii/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dealii/dealii/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dealii/dealii/git/refs{/sha}","trees_url":"https://api.github.com/repos/dealii/dealii/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dealii/dealii/statuses/{sha}","languages_url":"https://api.github.com/repos/dealii/dealii/languages","stargazers_url":"https://api.github.com/repos/dealii/dealii/stargazers","contributors_url":"https://api.github.com/repos/dealii/dealii/contributors","subscribers_url":"https://api.github.com/repos/dealii/dealii/subscribers","subscription_url":"https://api.github.com/repos/dealii/dealii/subscription","commits_url":"https://api.github.com/repos/dealii/dealii/commits{/sha}","git_commits_url":"https://api.github.com/repos/dealii/dealii/git/commits{/sha}","comments_url":"https://api.github.com/repos/dealii/dealii/comments{/number}","issue_comment_url":"https://api.github.com/repos/dealii/dealii/issues/comments{/number}","contents_url":"https://api.github.com/repos/dealii/dealii/contents/{+path}","compare_url":"https://api.github.com/repos/dealii/dealii/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dealii/dealii/merges","archive_url":"https://api.github.com/repos/dealii/dealii/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dealii/dealii/downloads","issues_url":"https://api.github.com/repos/dealii/dealii/issues{/number}","pulls_url":"https://api.github.com/repos/dealii/dealii/pulls{/number}","milestones_url":"https://api.github.com/repos/dealii/dealii/milestones{/number}","notifications_url":"https://api.github.com/repos/dealii/dealii/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dealii/dealii/labels{/name}","releases_url":"https://api.github.com/repos/dealii/dealii/releases{/id}","created_at":"2014-07-17T14:00:26Z","updated_at":"2015-12-20T11:38:55Z","pushed_at":"2015-12-21T17:35:08Z","git_url":"git://github.com/dealii/dealii.git","ssh_url":"git@github.com:dealii/dealii.git","clone_url":"https://github.com/dealii/dealii.git","svn_url":"https://github.com/dealii/dealii","homepage":"http://www.dealii.org/","size":137354,"stargazers_count":116,"watchers_count":116,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":135,"mirror_url":null,"open_issues_count":141,"forks":135,"open_issues":141,"watchers":116,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dealii/dealii/pulls/1998"},"html":{"href":"https://github.com/dealii/dealii/pull/1998"},"issue":{"href":"https://api.github.com/repos/dealii/dealii/issues/1998"},"comments":{"href":"https://api.github.com/repos/dealii/dealii/issues/1998/comments"},"review_comments":{"href":"https://api.github.com/repos/dealii/dealii/pulls/1998/comments"},"review_comment":{"href":"https://api.github.com/repos/dealii/dealii/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dealii/dealii/pulls/1998/commits"},"statuses":{"href":"https://api.github.com/repos/dealii/dealii/statuses/6856ff002fe0f283c1645d16c45b68ab4f9d1059"}}}}