{"action":"created","issue":{"url":"https://api.github.com/repos/JACoders/OpenJK/issues/743","labels_url":"https://api.github.com/repos/JACoders/OpenJK/issues/743/labels{/name}","comments_url":"https://api.github.com/repos/JACoders/OpenJK/issues/743/comments","events_url":"https://api.github.com/repos/JACoders/OpenJK/issues/743/events","html_url":"https://github.com/JACoders/OpenJK/pull/743","id":114435302,"number":743,"title":"Add GSL","user":{"login":"mrwonko","id":220725,"avatar_url":"https://avatars.githubusercontent.com/u/220725?v=3","gravatar_id":"","url":"https://api.github.com/users/mrwonko","html_url":"https://github.com/mrwonko","followers_url":"https://api.github.com/users/mrwonko/followers","following_url":"https://api.github.com/users/mrwonko/following{/other_user}","gists_url":"https://api.github.com/users/mrwonko/gists{/gist_id}","starred_url":"https://api.github.com/users/mrwonko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrwonko/subscriptions","organizations_url":"https://api.github.com/users/mrwonko/orgs","repos_url":"https://api.github.com/users/mrwonko/repos","events_url":"https://api.github.com/users/mrwonko/events{/privacy}","received_events_url":"https://api.github.com/users/mrwonko/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-31T21:21:57Z","updated_at":"2015-11-02T18:09:16Z","closed_at":"2015-11-01T22:41:45Z","pull_request":{"url":"https://api.github.com/repos/JACoders/OpenJK/pulls/743","html_url":"https://github.com/JACoders/OpenJK/pull/743","diff_url":"https://github.com/JACoders/OpenJK/pull/743.diff","patch_url":"https://github.com/JACoders/OpenJK/pull/743.patch"},"body":"In some code I'm currently writing I make use of the Guideline Support Library (GSL), so I thought I'd start by discussing using that in OpenJK.\r\n\r\nThe [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines) are a set of rules for creating more robust software; to this end a couple of new classes such as `not_null<T*>` and `owner<T*>` are introduced as the GSL. (By way of an example: The point of `owner` is to clarify that this pointer needs to be freed (or handed off somewhere) to prevent leaks.)\r\n\r\nCritically these new types are made with legacy C ABIs in mind; as such e.g. `owner<T>`is really just `T` and its sole point is to aid automatic verification using tools; the first one, Microsoft's checker, will be released soon alongside Visual Studio Update 1, together with their reference implementation of the GSL.\r\n\r\nHowever Microsoft's GSL implementation (whose preliminary version [is on Github](https://github.com/Microsoft/GSL/)) only works in GCC 5.1+, and we still want to support 4.8. As such I've chosen to include [GSL Lite](https://github.com/martinmoene/gsl-lite), a backwards compatible implementation that is mostly identical feature-wise. Eventually the GSL implementation to use could be dynamically chosen in CMake; Microsoft's GSL checker may require usage of their implementation.\r\n\r\nBut even outside of automatic checking the GSL has some useful features; in particular it contains `array_view`/`string_view`, non-owning array views which consist of a start and end pointer, such that they know the array's size and prevent past-the-end access while providing constant-time length determination. I'm currently rewriting GenericParser2's `GetToken()` using them and it makes for much nicer code than null-terminated strings; for example I can just return a `string_view` into the source buffer instead of having to copy the current token so I can null-terminate it.\r\n\r\nSo we should totally start using it in OpenJK."},"comment":{"url":"https://api.github.com/repos/JACoders/OpenJK/issues/comments/153104802","html_url":"https://github.com/JACoders/OpenJK/pull/743#issuecomment-153104802","issue_url":"https://api.github.com/repos/JACoders/OpenJK/issues/743","id":153104802,"user":{"login":"ensiform","id":997399,"avatar_url":"https://avatars.githubusercontent.com/u/997399?v=3","gravatar_id":"","url":"https://api.github.com/users/ensiform","html_url":"https://github.com/ensiform","followers_url":"https://api.github.com/users/ensiform/followers","following_url":"https://api.github.com/users/ensiform/following{/other_user}","gists_url":"https://api.github.com/users/ensiform/gists{/gist_id}","starred_url":"https://api.github.com/users/ensiform/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ensiform/subscriptions","organizations_url":"https://api.github.com/users/ensiform/orgs","repos_url":"https://api.github.com/users/ensiform/repos","events_url":"https://api.github.com/users/ensiform/events{/privacy}","received_events_url":"https://api.github.com/users/ensiform/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T18:09:16Z","updated_at":"2015-11-02T18:09:16Z","body":"Its one of their classes used for places with std::map in the codebase so it says in the comments.  But its basically just a char[64] with some functions to be stl compat."}}