{"id":20199590,"url":"https://github.com/max0x7ba/const_string","last_synced_at":"2026-03-09T04:05:47.833Z","repository":{"id":23776610,"uuid":"27151768","full_name":"max0x7ba/const_string","owner":"max0x7ba","description":"C++98 string class that provides functionality of both std::string and std::string_view.","archived":false,"fork":false,"pushed_at":"2020-09-04T16:22:54.000Z","size":27,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T11:34:46.951Z","etag":null,"topics":["cplusplus","cpp","cxx","string"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/max0x7ba.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-25T23:56:22.000Z","updated_at":"2024-10-19T23:19:02.000Z","dependencies_parsed_at":"2022-08-22T04:50:34.437Z","dependency_job_id":null,"html_url":"https://github.com/max0x7ba/const_string","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/max0x7ba/const_string","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max0x7ba%2Fconst_string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max0x7ba%2Fconst_string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max0x7ba%2Fconst_string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max0x7ba%2Fconst_string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/max0x7ba","download_url":"https://codeload.github.com/max0x7ba/const_string/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/max0x7ba%2Fconst_string/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30282628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T02:57:19.223Z","status":"ssl_error","status_checked_at":"2026-03-09T02:56:26.373Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cplusplus","cpp","cxx","string"],"created_at":"2024-11-14T04:38:12.168Z","updated_at":"2026-03-09T04:05:46.146Z","avatar_url":"https://github.com/max0x7ba.png","language":"C++","readme":"# Overview \nC++98 immutable string class that provides functionality of both `std::string` and `std::string_view`. \n\nThe main purpose of `const_string` is to allow functions that take/return immutable strings (most of functions) to use only `const_string` for all kinds of strings and not require memory allocation.\n\nThe class is called `const_string` because it doesn't allow modification of individual characters of the string. This restriction allows for cheap copying with thread-safe reference counting. The library is inteded for inclusion into boost library, but lacks documentation required for library acceptance review.\n\nGNU C++98 `std::string` was reference-counted, but a C++ standard compliant `std::string` cannot be both reference-counted and fully standard compliant, so that GNU C++11 `std::string` is no longer reference-counted. The mutability of individual characters of `std::string` is the main reason it cannot be reference-counted. \n\n`const_string` doesn't allow modification of individual characters in order to provide cheap/shallow copies and also provides `std::string_view` functionality to allow for no memory allocation usage.\n\n## Main features\n\n* Optional memory allocation, unlike functions taking `std::string` argument.\n* No extra overloads for `std::string_view` to avoid `std::string` memory allocation.\n* Customizable small string optimization buffer size. On a 64-bit platform, the minimum size of a `const_string` is 16 bytes, which allows for 8-byte small string optimization. The small string buffer size is controlled by the template argument, should you need to change the default.\n* Longer strings are reference-counted, so that copies are cheap and thread-safe. \n\n# Examples\n\n```\nusing boost::const_string;\n\n// No memory allocation due to small string optimization.\nconst_string a(\"abc\");\n\n// Memory allocation because the string is long.\nconst_string b0(\"abcdefghijklmnoprstqvwxyz\"); \n\n// No memory allocation, reference counter increment.\nconst_string b1 = b0; \n\n// No memory allocation, the string literal is referred to.\n// Equivalent to using std::string_view.\nconst_string c(boost::cref(\"abcdefghijklmnoprstqvwxyz\")); \n\n// Refer to std::string with no memory allocation or copy.\n// Equivalent to using std::string_view.\nstd::string d0(\"abcdefghijklmnoprstqvwxyz\");\nconst_string d1(boost::cref(d0)); \n```\n\n# TODO\n\n* Documentation.\n* Update with C++11.\n* Use Facebook small string optimization to allow for 7 more characters with no memory allocation.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmax0x7ba%2Fconst_string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmax0x7ba%2Fconst_string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmax0x7ba%2Fconst_string/lists"}