{"action":"created","comment":{"url":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/comments/62984812","id":62984812,"diff_hunk":"@@ -1,6 +1,64 @@\n #pragma once\n \n+#include <cstring>\n+#include <memory>\n+\n class MyString\n {\n-\t// TODO\n+private:\n+\tstd::unique_ptr<char[]> mBuffer;\n+\n+public:\n+\tMyString(): mBuffer(new char[1]) {}\n+\n+\tMyString(const char* str): mBuffer(new char[std::strlen(str)])","path":"course3/homework-string/my_string.h","position":15,"original_position":15,"commit_id":"0de57ebc4f666ab3debe4bc0643e35e0c7d914f2","original_commit_id":"0de57ebc4f666ab3debe4bc0643e35e0c7d914f2","user":{"login":"maciekgajewski","id":1903794,"avatar_url":"https://avatars.githubusercontent.com/u/1903794?v=3","gravatar_id":"","url":"https://api.github.com/users/maciekgajewski","html_url":"https://github.com/maciekgajewski","followers_url":"https://api.github.com/users/maciekgajewski/followers","following_url":"https://api.github.com/users/maciekgajewski/following{/other_user}","gists_url":"https://api.github.com/users/maciekgajewski/gists{/gist_id}","starred_url":"https://api.github.com/users/maciekgajewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maciekgajewski/subscriptions","organizations_url":"https://api.github.com/users/maciekgajewski/orgs","repos_url":"https://api.github.com/users/maciekgajewski/repos","events_url":"https://api.github.com/users/maciekgajewski/events{/privacy}","received_events_url":"https://api.github.com/users/maciekgajewski/received_events","type":"User","site_admin":false},"body":"Question: what would ```std::strlen(\"abc\")``` return? How many bytes do you need to store ```\"abc\"``` ?","created_at":"2016-05-12T08:50:12Z","updated_at":"2016-05-12T08:50:12Z","html_url":"https://github.com/maciekgajewski/c-excercises/pull/16#discussion_r62984812","pull_request_url":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/comments/62984812"},"html":{"href":"https://github.com/maciekgajewski/c-excercises/pull/16#discussion_r62984812"},"pull_request":{"href":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/16","id":69456091,"html_url":"https://github.com/maciekgajewski/c-excercises/pull/16","diff_url":"https://github.com/maciekgajewski/c-excercises/pull/16.diff","patch_url":"https://github.com/maciekgajewski/c-excercises/pull/16.patch","issue_url":"https://api.github.com/repos/maciekgajewski/c-excercises/issues/16","number":16,"state":"open","locked":false,"title":"string and vector homeworks","user":{"login":"karunrao97","id":16673637,"avatar_url":"https://avatars.githubusercontent.com/u/16673637?v=3","gravatar_id":"","url":"https://api.github.com/users/karunrao97","html_url":"https://github.com/karunrao97","followers_url":"https://api.github.com/users/karunrao97/followers","following_url":"https://api.github.com/users/karunrao97/following{/other_user}","gists_url":"https://api.github.com/users/karunrao97/gists{/gist_id}","starred_url":"https://api.github.com/users/karunrao97/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karunrao97/subscriptions","organizations_url":"https://api.github.com/users/karunrao97/orgs","repos_url":"https://api.github.com/users/karunrao97/repos","events_url":"https://api.github.com/users/karunrao97/events{/privacy}","received_events_url":"https://api.github.com/users/karunrao97/received_events","type":"User","site_admin":false},"body":"Some questions on const:\r\n1. The code passes all tests whether or not I use const in function arguments. For example, both \"char& operator\\[\\](const int idx)\" and \"char& operator\\[\\](int idx)\" work fine, as do \"MyString(const MyString& str)\" and \"MyString(MyString& str)\". Any reason to prefer one over the other in either case?\r\n2. Similar to above, the code passes all tests whether or not I use const in return types. For example, both \"const bool empty() const\" and \"bool empty() const\" work fine, as do \"const char& operator\\[\\](const int idx) const\" and \"char& operator\\[\\](const int idx) const\". Again, any reason to prefer one over the other in either case?","created_at":"2016-05-10T06:45:46Z","updated_at":"2016-05-12T08:50:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7956fd4b91f80199c7100a50764dc9b91df2aef8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/16/commits","review_comments_url":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/16/comments","review_comment_url":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/comments{/number}","comments_url":"https://api.github.com/repos/maciekgajewski/c-excercises/issues/16/comments","statuses_url":"https://api.github.com/repos/maciekgajewski/c-excercises/statuses/0de57ebc4f666ab3debe4bc0643e35e0c7d914f2","head":{"label":"karunrao97:master","ref":"master","sha":"0de57ebc4f666ab3debe4bc0643e35e0c7d914f2","user":{"login":"karunrao97","id":16673637,"avatar_url":"https://avatars.githubusercontent.com/u/16673637?v=3","gravatar_id":"","url":"https://api.github.com/users/karunrao97","html_url":"https://github.com/karunrao97","followers_url":"https://api.github.com/users/karunrao97/followers","following_url":"https://api.github.com/users/karunrao97/following{/other_user}","gists_url":"https://api.github.com/users/karunrao97/gists{/gist_id}","starred_url":"https://api.github.com/users/karunrao97/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karunrao97/subscriptions","organizations_url":"https://api.github.com/users/karunrao97/orgs","repos_url":"https://api.github.com/users/karunrao97/repos","events_url":"https://api.github.com/users/karunrao97/events{/privacy}","received_events_url":"https://api.github.com/users/karunrao97/received_events","type":"User","site_admin":false},"repo":{"id":58401932,"name":"c-excercises","full_name":"karunrao97/c-excercises","owner":{"login":"karunrao97","id":16673637,"avatar_url":"https://avatars.githubusercontent.com/u/16673637?v=3","gravatar_id":"","url":"https://api.github.com/users/karunrao97","html_url":"https://github.com/karunrao97","followers_url":"https://api.github.com/users/karunrao97/followers","following_url":"https://api.github.com/users/karunrao97/following{/other_user}","gists_url":"https://api.github.com/users/karunrao97/gists{/gist_id}","starred_url":"https://api.github.com/users/karunrao97/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karunrao97/subscriptions","organizations_url":"https://api.github.com/users/karunrao97/orgs","repos_url":"https://api.github.com/users/karunrao97/repos","events_url":"https://api.github.com/users/karunrao97/events{/privacy}","received_events_url":"https://api.github.com/users/karunrao97/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/karunrao97/c-excercises","description":"\"C++ for Python developers\"","fork":true,"url":"https://api.github.com/repos/karunrao97/c-excercises","forks_url":"https://api.github.com/repos/karunrao97/c-excercises/forks","keys_url":"https://api.github.com/repos/karunrao97/c-excercises/keys{/key_id}","collaborators_url":"https://api.github.com/repos/karunrao97/c-excercises/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/karunrao97/c-excercises/teams","hooks_url":"https://api.github.com/repos/karunrao97/c-excercises/hooks","issue_events_url":"https://api.github.com/repos/karunrao97/c-excercises/issues/events{/number}","events_url":"https://api.github.com/repos/karunrao97/c-excercises/events","assignees_url":"https://api.github.com/repos/karunrao97/c-excercises/assignees{/user}","branches_url":"https://api.github.com/repos/karunrao97/c-excercises/branches{/branch}","tags_url":"https://api.github.com/repos/karunrao97/c-excercises/tags","blobs_url":"https://api.github.com/repos/karunrao97/c-excercises/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/karunrao97/c-excercises/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/karunrao97/c-excercises/git/refs{/sha}","trees_url":"https://api.github.com/repos/karunrao97/c-excercises/git/trees{/sha}","statuses_url":"https://api.github.com/repos/karunrao97/c-excercises/statuses/{sha}","languages_url":"https://api.github.com/repos/karunrao97/c-excercises/languages","stargazers_url":"https://api.github.com/repos/karunrao97/c-excercises/stargazers","contributors_url":"https://api.github.com/repos/karunrao97/c-excercises/contributors","subscribers_url":"https://api.github.com/repos/karunrao97/c-excercises/subscribers","subscription_url":"https://api.github.com/repos/karunrao97/c-excercises/subscription","commits_url":"https://api.github.com/repos/karunrao97/c-excercises/commits{/sha}","git_commits_url":"https://api.github.com/repos/karunrao97/c-excercises/git/commits{/sha}","comments_url":"https://api.github.com/repos/karunrao97/c-excercises/comments{/number}","issue_comment_url":"https://api.github.com/repos/karunrao97/c-excercises/issues/comments{/number}","contents_url":"https://api.github.com/repos/karunrao97/c-excercises/contents/{+path}","compare_url":"https://api.github.com/repos/karunrao97/c-excercises/compare/{base}...{head}","merges_url":"https://api.github.com/repos/karunrao97/c-excercises/merges","archive_url":"https://api.github.com/repos/karunrao97/c-excercises/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/karunrao97/c-excercises/downloads","issues_url":"https://api.github.com/repos/karunrao97/c-excercises/issues{/number}","pulls_url":"https://api.github.com/repos/karunrao97/c-excercises/pulls{/number}","milestones_url":"https://api.github.com/repos/karunrao97/c-excercises/milestones{/number}","notifications_url":"https://api.github.com/repos/karunrao97/c-excercises/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/karunrao97/c-excercises/labels{/name}","releases_url":"https://api.github.com/repos/karunrao97/c-excercises/releases{/id}","deployments_url":"https://api.github.com/repos/karunrao97/c-excercises/deployments","created_at":"2016-05-09T19:20:51Z","updated_at":"2016-05-09T19:20:52Z","pushed_at":"2016-05-10T20:30:38Z","git_url":"git://github.com/karunrao97/c-excercises.git","ssh_url":"git@github.com:karunrao97/c-excercises.git","clone_url":"https://github.com/karunrao97/c-excercises.git","svn_url":"https://github.com/karunrao97/c-excercises","homepage":null,"size":242,"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":"maciekgajewski:master","ref":"master","sha":"e2b898a8938ace3f7803bef874099c6cb496afff","user":{"login":"maciekgajewski","id":1903794,"avatar_url":"https://avatars.githubusercontent.com/u/1903794?v=3","gravatar_id":"","url":"https://api.github.com/users/maciekgajewski","html_url":"https://github.com/maciekgajewski","followers_url":"https://api.github.com/users/maciekgajewski/followers","following_url":"https://api.github.com/users/maciekgajewski/following{/other_user}","gists_url":"https://api.github.com/users/maciekgajewski/gists{/gist_id}","starred_url":"https://api.github.com/users/maciekgajewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maciekgajewski/subscriptions","organizations_url":"https://api.github.com/users/maciekgajewski/orgs","repos_url":"https://api.github.com/users/maciekgajewski/repos","events_url":"https://api.github.com/users/maciekgajewski/events{/privacy}","received_events_url":"https://api.github.com/users/maciekgajewski/received_events","type":"User","site_admin":false},"repo":{"id":31058584,"name":"c-excercises","full_name":"maciekgajewski/c-excercises","owner":{"login":"maciekgajewski","id":1903794,"avatar_url":"https://avatars.githubusercontent.com/u/1903794?v=3","gravatar_id":"","url":"https://api.github.com/users/maciekgajewski","html_url":"https://github.com/maciekgajewski","followers_url":"https://api.github.com/users/maciekgajewski/followers","following_url":"https://api.github.com/users/maciekgajewski/following{/other_user}","gists_url":"https://api.github.com/users/maciekgajewski/gists{/gist_id}","starred_url":"https://api.github.com/users/maciekgajewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maciekgajewski/subscriptions","organizations_url":"https://api.github.com/users/maciekgajewski/orgs","repos_url":"https://api.github.com/users/maciekgajewski/repos","events_url":"https://api.github.com/users/maciekgajewski/events{/privacy}","received_events_url":"https://api.github.com/users/maciekgajewski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maciekgajewski/c-excercises","description":"\"C++ for Python developers\"","fork":false,"url":"https://api.github.com/repos/maciekgajewski/c-excercises","forks_url":"https://api.github.com/repos/maciekgajewski/c-excercises/forks","keys_url":"https://api.github.com/repos/maciekgajewski/c-excercises/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maciekgajewski/c-excercises/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maciekgajewski/c-excercises/teams","hooks_url":"https://api.github.com/repos/maciekgajewski/c-excercises/hooks","issue_events_url":"https://api.github.com/repos/maciekgajewski/c-excercises/issues/events{/number}","events_url":"https://api.github.com/repos/maciekgajewski/c-excercises/events","assignees_url":"https://api.github.com/repos/maciekgajewski/c-excercises/assignees{/user}","branches_url":"https://api.github.com/repos/maciekgajewski/c-excercises/branches{/branch}","tags_url":"https://api.github.com/repos/maciekgajewski/c-excercises/tags","blobs_url":"https://api.github.com/repos/maciekgajewski/c-excercises/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maciekgajewski/c-excercises/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maciekgajewski/c-excercises/git/refs{/sha}","trees_url":"https://api.github.com/repos/maciekgajewski/c-excercises/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maciekgajewski/c-excercises/statuses/{sha}","languages_url":"https://api.github.com/repos/maciekgajewski/c-excercises/languages","stargazers_url":"https://api.github.com/repos/maciekgajewski/c-excercises/stargazers","contributors_url":"https://api.github.com/repos/maciekgajewski/c-excercises/contributors","subscribers_url":"https://api.github.com/repos/maciekgajewski/c-excercises/subscribers","subscription_url":"https://api.github.com/repos/maciekgajewski/c-excercises/subscription","commits_url":"https://api.github.com/repos/maciekgajewski/c-excercises/commits{/sha}","git_commits_url":"https://api.github.com/repos/maciekgajewski/c-excercises/git/commits{/sha}","comments_url":"https://api.github.com/repos/maciekgajewski/c-excercises/comments{/number}","issue_comment_url":"https://api.github.com/repos/maciekgajewski/c-excercises/issues/comments{/number}","contents_url":"https://api.github.com/repos/maciekgajewski/c-excercises/contents/{+path}","compare_url":"https://api.github.com/repos/maciekgajewski/c-excercises/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maciekgajewski/c-excercises/merges","archive_url":"https://api.github.com/repos/maciekgajewski/c-excercises/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maciekgajewski/c-excercises/downloads","issues_url":"https://api.github.com/repos/maciekgajewski/c-excercises/issues{/number}","pulls_url":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls{/number}","milestones_url":"https://api.github.com/repos/maciekgajewski/c-excercises/milestones{/number}","notifications_url":"https://api.github.com/repos/maciekgajewski/c-excercises/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maciekgajewski/c-excercises/labels{/name}","releases_url":"https://api.github.com/repos/maciekgajewski/c-excercises/releases{/id}","deployments_url":"https://api.github.com/repos/maciekgajewski/c-excercises/deployments","created_at":"2015-02-20T09:39:26Z","updated_at":"2016-04-24T09:31:49Z","pushed_at":"2016-05-11T20:40:49Z","git_url":"git://github.com/maciekgajewski/c-excercises.git","ssh_url":"git@github.com:maciekgajewski/c-excercises.git","clone_url":"https://github.com/maciekgajewski/c-excercises.git","svn_url":"https://github.com/maciekgajewski/c-excercises","homepage":null,"size":275,"stargazers_count":4,"watchers_count":4,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":14,"forks":17,"open_issues":14,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/16"},"html":{"href":"https://github.com/maciekgajewski/c-excercises/pull/16"},"issue":{"href":"https://api.github.com/repos/maciekgajewski/c-excercises/issues/16"},"comments":{"href":"https://api.github.com/repos/maciekgajewski/c-excercises/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/maciekgajewski/c-excercises/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/maciekgajewski/c-excercises/statuses/0de57ebc4f666ab3debe4bc0643e35e0c7d914f2"}}}}