{"id":19436348,"url":"https://github.com/beached/ostreams","last_synced_at":"2025-10-16T19:42:37.374Z","repository":{"id":149955376,"uuid":"146643872","full_name":"beached/ostreams","owner":"beached","description":"A constexpr output streams library","archived":false,"fork":false,"pushed_at":"2020-09-26T23:29:02.000Z","size":149,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T06:46:35.830Z","etag":null,"topics":["constexpr","cpp","cpp14","outputstream"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beached.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-29T18:45:22.000Z","updated_at":"2020-09-26T23:29:05.000Z","dependencies_parsed_at":"2023-05-05T06:20:09.883Z","dependency_job_id":null,"html_url":"https://github.com/beached/ostreams","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/beached/ostreams","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beached%2Fostreams","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beached%2Fostreams/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beached%2Fostreams/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beached%2Fostreams/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beached","download_url":"https://codeload.github.com/beached/ostreams/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beached%2Fostreams/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279230833,"owners_count":26130684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-16T02:00:06.019Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["constexpr","cpp","cpp14","outputstream"],"created_at":"2024-11-10T15:10:42.923Z","updated_at":"2025-10-16T19:42:37.359Z","avatar_url":"https://github.com/beached.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ostreams\nA constexpr output stream implementation.  See [tests](https://github.com/beached/ostreams/tree/master/tests) for example of usage\n\nTo create a formatted buffer\n\n```cpp\ndaw::static_string_t\u003cchar, 100\u003e buffer{};   // Uses a static string, but any contiguous memory area is fine\n\nbuffer.resize(buffer.size( ));  // makes static string marked as fully used\n\n\nauto buff_stream = daw::io::make_memory_buffer_stream( buffer.data( ), buffer.size( ) );    // create stream\n\nbuff_stream \u003c\u003c \"The meaning of life is \" \u003c\u003c 42 \u003c\u003c '\\n';\n\nbuffer.shrink_to_fit( );    // reclaim unused space in buffer\n```\nConsole output\n```cpp\ndaw::con_out \u003c\u003c \"The meaning of life is \" \u003c\u003c 42 \u003c\u003c '\\n';\n```\n\nFile output\n```cpp\nauto fs = daw::make_file_stream( \"file_name\" );\nif( !fs ) {\n    daw::con_err \u003c\u003c \"Error opening file\\n\";\n    exit( EXIT_FAILURE );\n}\nfs \u003c\u003c \"The meaining of life is \" \u003c\u003c 42 \u003c\u003c '\\n';\nfs.close( );    // or let it go out of scope\n```\n## Extending to your classes\nAdd a function ``` to_os_string\u003cCharT\u003e( ClassType ) ``` in your classes namespace that returns a type that is string like(has ``` data( ) ``` and ``` size( ) ```methods).  If you want constexpr formatting this function must be constexpr.  The provided ``` static_string_t\u003cCharT\u003e ``` can help or a ``` string_view ``` may work too.\n\nCustom streams must provide ``` operator() ``` for character and string like data.  They must also specialize ``` daw::io::supports_output_stream_interface\u003cT\u003e ``` to inherit from ``` std::true_type ```\n\nOtherwise, for composite classes you would overload ``` operator\u003c\u003c ``` like in C++ iostreams.  The requirement being that it is a template and uses SFINAE to only allow when ``` daw::io::is_output_stream_v\u003cOutputStream\u003e == true ```.\n## Benchmarks\nUsing a format string(or equivilent) of `\"The asnwer to the meaning of life is %d %f\\n\"` with a double of 42.0\n\nThe following are the results:\n#### Mac 2017 Macbook Air - 1.8 GHz Intel Core i5 \n\n| method             | count  | total time  | item time |\n|--------------------|--------|-------------|-----------|\n| daw::memory_stream | 100000 | 13.90ms     | 138.99ns  |\n| snprintf           | 100000 | 31.98ms     | 319.83ns  |\n| std::string_stream | 100000 | 77.30ms     | 772.96ns  |\n| printf             | 100000 | 170.57ms    |   1.71us  |\n| daw::con_err       | 100000 | 573.81ms    |   5.74us  |\n| std::cerr          | 100000 | 800.21ms    |   8.00us  |\n\n#### Windows Intel i7-7500U\t\n\n| method             | count  | total time  | item time |\n|--------------------|--------|-------------|-----------|\n| daw::memory_stream | 100000 |    21.70ms  | 217.00ns  |\n| snprintf           | 100000 |    96.02ms  | 960.96ns  |\n| std::string_stream | 100000 |   127.61ms  |   1.28us  |\n| daw::con_err       | 100000 |   326.27ms  |   3.26us  |\n| std::cerr          | 100000 |   842.78ms  |   8.43us  |\n| printf             | 100000 |      3.99s  |  39.86us  |\n\n# Round trip errors\nTested using strtod/strtof to return string to a double/float\n\n| type| value| output| difference                                                                                                                                                                                                                                                                                                                                              | \n|-----|------|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| \n| double| 0.1| 0.1| 0                                                                                                                                                                                                                                                                                                                                                          | \n| double| 0.12| 0.11999999999999998| -1.38778e-17                                                                                                                                                                                                                                                                                                                              | \n| double| 0.123| 0.12299999999999999| -1.38778e-17                                                                                                                                                                                                                                                                                                                             | \n| double| 0.1234| 0.12339999999999998| -1.38778e-17                                                                                                                                                                                                                                                                                                                            | \n| double| 1.2345| 1.23449999999999992| 0                                                                                                                                                                                                                                                                                                                                       | \n| double| 0.333333| 0.33333333333333332| 0                                                                                                                                                                                                                                                                                                                                     | \n| double| 0.666667| 0.66666666666666665| 0                                                                                                                                                                                                                                                                                                                                     | \n| double| 3.33333| 3.33333333333333349| 0                                                                                                                                                                                                                                                                                                                                      | \n| double| 6.66667| 6.66666666666666698| 0                                                                                                                                                                                                                                                                                                                                      | \n| double| 2.22507e-308| 0.0000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 0000000022250738585072009| -4.94066e-324  | \n| double| -2.22507e-308| -0.00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 000000022250738585072009| 4.94066e-324 | \n| double| 1.79769e+308| 17976931348623156600000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 000000000| 0                               | \n| double| 4.94066e-324| 0| -4.94066e-324                                                                                                                                                                                                                                                                                                                                       | \n| double| 4| 3.99999999999999953| 0                                                                                                                                                                                                                                                                                                                                            | \n| double| 8.98847e+307| 89884656743115786500000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 00000000| 0                                | \n| float| 0.1| 0.1| 0                                                                                                                                                                                                                                                                                                                                                           | \n| float| 0.12| 0.119999996| 0                                                                                                                                                                                                                                                                                                                                                  | \n| float| 0.123| 0.123000001| 0                                                                                                                                                                                                                                                                                                                                                 | \n| float| 0.1234| 0.123400000| 0                                                                                                                                                                                                                                                                                                                                                | \n| float| 1.2345| 1.234500046| 0                                                                                                                                                                                                                                                                                                                                                | \n| float| 0.333333| 0.333333330| 0                                                                                                                                                                                                                                                                                                                                              | \n| float| 0.666667| 0.666666660| 0                                                                                                                                                                                                                                                                                                                                              | \n| float| 3.33333| 3.333333240| 0                                                                                                                                                                                                                                                                                                                                               | \n| float| 6.66667| 6.666666481| 0                                                                                                                                                                                                                                                                                                                                               | \n| float| 1.17549e-38| 0.0000000000000000000000000000000000000117549440| 0                                                                                                                                                                                                                                                                                                      | \n| float| 3.40282e+38| 340282346300000000000000000000000000000| 0                                                                                                                                                                                                                                                                                                               | \n| float| 1.4013e-45| 0| -1.4013e-45                                                                                                                                                                                                                                                                                                                                            | \n| float| 4| 3.999999788| 0                                                                                                                                                                                                                                                                                                                                                     | \n| float| 1.70141e+38| 170141175700000000000000000000000000000| 0                                                                                                                                                                                                                                                                                                               | \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeached%2Fostreams","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeached%2Fostreams","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeached%2Fostreams/lists"}