{"id":16242632,"url":"https://github.com/facontidavide/safecppany","last_synced_at":"2025-03-19T17:31:47.162Z","repository":{"id":50025686,"uuid":"45026907","full_name":"facontidavide/SafeCppAny","owner":"facontidavide","description":"Extension of std::any with small object optmization and safe numeric conversion.","archived":false,"fork":false,"pushed_at":"2018-12-12T10:29:55.000Z","size":200,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-11T14:11:32.703Z","etag":null,"topics":["any","cpp","safe"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/facontidavide.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}},"created_at":"2015-10-27T08:27:53.000Z","updated_at":"2022-08-16T18:43:31.000Z","dependencies_parsed_at":"2022-09-22T19:42:21.185Z","dependency_job_id":null,"html_url":"https://github.com/facontidavide/SafeCppAny","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facontidavide%2FSafeCppAny","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facontidavide%2FSafeCppAny/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facontidavide%2FSafeCppAny/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facontidavide%2FSafeCppAny/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/facontidavide","download_url":"https://codeload.github.com/facontidavide/SafeCppAny/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221729474,"owners_count":16871030,"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","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":["any","cpp","safe"],"created_at":"2024-10-10T14:11:53.803Z","updated_at":"2024-10-27T20:27:03.950Z","avatar_url":"https://github.com/facontidavide.png","language":"C++","readme":"# std::any with small object optimization and safe numerical conversion\n\nThe purpose of this tiny header-only library is to provide a type called SafeAny::Any which can hold any \ntype, just like std::any or boost::any.\nBut it has few importants features:\n\n- It has small object optimization for objects smaller than two words (16 bytes on a 64bits platform), thanks to this 3rdparty implementation [thelink2012/any](https://github.com/thelink2012/any).\n\n- it is less pedantic than usual when an arithmetic value (integer, floating point, enum, etc.) is casted into another one. The library will check for narrowing, signedness conversions and numerical cancellation. \n\n## Example\n\n```c++\nusing SafeAny::Any;\n\n{\n  Any val( int(-1000) );\n\n  int    int_val = val.cast\u003cint\u003e(); //OK\n  double real_val = val.cast\u003cdouble\u003e(); //OK\n  double long_val = val.cast\u003clong\u003e(); //OK\n\n  int8_t small_val      = val.cast\u003cuint8_t\u003e(); // throws exception\n  uint16_t unsigned_val = val.cast\u003cuint16_t\u003e(); // throws exception\n}\n\n{\n  Any val( float(3.1) );\n\n  float  f_val = val.cast\u003cfloat\u003e(); //OK\n  double d_val = val.cast\u003cdouble\u003e(); //OK\n  \n  int i_val = val.cast\u003cint\u003e(); // throws exception. \n}\n``` \n\n## Implementation \n\nSafeAny extends std::any with few ideas from [Poco::DynamicAny](http://pocoproject.org/docs-1.4.6/Poco.DynamicAny.html).\n \nThe main drawback of Poco::DynamicAny is that it requires heap allocation, something that is slow and not very cache-friendly.\n\n\n\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacontidavide%2Fsafecppany","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffacontidavide%2Fsafecppany","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacontidavide%2Fsafecppany/lists"}