{"id":20614413,"url":"https://github.com/aryan-programmer/universal-cpp","last_synced_at":"2025-07-09T21:32:56.202Z","repository":{"id":162947919,"uuid":"170542981","full_name":"aryan-programmer/Universal-CPP","owner":"aryan-programmer","description":"Universal C++ language extensions","archived":false,"fork":false,"pushed_at":"2019-10-11T05:25:03.000Z","size":722,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-06T18:49:46.075Z","etag":null,"topics":["boost","boost-libraries","cpp","cpp-lib","cpp-library","cpp17"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aryan-programmer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-13T16:45:00.000Z","updated_at":"2022-11-22T11:46:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"aa42ffc5-0ab5-4ecc-b34a-1e87b1f6c3fc","html_url":"https://github.com/aryan-programmer/Universal-CPP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/aryan-programmer/Universal-CPP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aryan-programmer%2FUniversal-CPP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aryan-programmer%2FUniversal-CPP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aryan-programmer%2FUniversal-CPP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aryan-programmer%2FUniversal-CPP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aryan-programmer","download_url":"https://codeload.github.com/aryan-programmer/Universal-CPP/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aryan-programmer%2FUniversal-CPP/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264503951,"owners_count":23618762,"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":["boost","boost-libraries","cpp","cpp-lib","cpp-library","cpp17"],"created_at":"2024-11-16T11:12:41.118Z","updated_at":"2025-07-09T21:32:56.180Z","avatar_url":"https://github.com/aryan-programmer.png","language":"C++","readme":"![UC++ Logo in Iosevka SS03](Logo.png)\n\n# UC++(Universal C++)\n\n\n[TOC]\n\n## \u003cspan style=\"color:red\"\u003e× To implement\u003c/span\u003e || \u003cspan style=\"color:green\"\u003e√ Implemented\u003c/span\u003e Features ← From Languages\n\n### \u003cspan style=\"color:green\"\u003e√ Garbage Collection  ← Objective-C\u003c/span\u003e\nLike Objective-C, UC++ support s GC, but only ARC (Automatic Reference Counting) style GC is supported, like in Objective-C where ARC is the recommended method.\n\n### \u003cspan style=\"color:green\"\u003e√ Reflection ← ~~Most~~ \u003cu\u003e***All***\u003c/u\u003e languages with automatic garbage collection.\u003c/span\u003e\n\nUse `UC::P_Any` variables and `UC::Object::Call` as:\n\n```C++\n?variable?-\u003eCall(?function-name?, {?args?})\n```\n\nor use \u003cspan style=\"color:purple\"\u003eUCC\u003c/span\u003e as:\n\n```C++\nUCC(?variable?, ?function-name?, {?args?})\n```\n\nto call methods using reflection. And use\n\n```C++\nstatic UC::Object::CreateInstance\n```\nto create instances of \u003cspan style=\"color:purple\"\u003eUCInterfaces\u003c/span\u003e as\n\n```C++\nUC::Object::CreateInstance(?class-name?, {?args?})\n```\n\n### \u003cspan style=\"color:green\"\u003e√ Dynamic Typing ← Python\u003c/span\u003e\n\nUse `UC::P_Any` variables and `UC::Object::Call` as:\n\n```C++\n?variable?-\u003eCall(?function-name?, {?args?})\n```\n\nor use \u003cspan style=\"color:purple\"\u003eUCC\u003c/span\u003e as:\n\n```C++\nUCC(?variable?, ?function-name?, {?args?})\n```\n\nto call methods using ***Dynamic Typing***. Yes, the methods to use for reflection and dynamic typing are the same. \n\nFor casting to higher types use \n```C++\nUC::ObjCast\u003cT\u003e\n```\nas \n\n```C++\nUC::ObjCast\u003c?TypeToCastTo?\u003e(?variable?)\n```\n\n### \u003cspan style=\"color:green\"\u003e√ Delegates ← C#\u003c/span\u003e\n\nDelegates are from C#, but they aren't called delegates, they're called **\u003cu\u003e_Functors_\u003c/u\u003e**.\n\nFunctor = **\u003cu\u003e_Func_\u003c/u\u003e**tion + Opera**\u003cu\u003e_tor_\u003c/u\u003e**\n\nThere are 3 core things to 'delegates' or functors\n\n1. `UC::Function\u003cTReturn, TParameters...\u003e`\n\n   This template interface is abstract, it isn't directly instantiated, `UC::MakeFunc` is used for instantiating instances of this interface.\n\n   To call the stored function call `?functor?-\u003eEval(?parameters?...)` with the designated \u003cspan style=\"color:green\"\u003e?parameters?...\u003c/span\u003e\n\n2. Function type aliases and how to use them\n\n   They are defined as aliases for **\u003cu\u003e_function types_\u003c/u\u003e**, not **\u003cu\u003e_functor types_\u003c/u\u003e**. Define one as\n\n   ```C++\n   typedef ?return-type? ?name?(?parameter-types?...)\n   ```\n\n   Where \u003cspan style=\"color:green\"\u003e?name?\u003c/span\u003e \u0026 \u003cspan style=\"color:green\"\u003e?return-type?\u003c/span\u003e refer to the name of the alias \u0026 return type respectively, and \u003cspan style=\"color:green\"\u003e?parameter-types...?\u003c/span\u003e refers to 0 or more parameters.\n\n   To get a `UC::Function` from the alias use:\n\n   ```C++\n   UC::FuncFrom\u003c?name?\u003e\n   ```\n\n   To get a `UC::Event` from the alias use:\n\n   ```C++\n   UC::EventFrom\u003c?name?\u003e\n   ```\n\n3. `UC::MakeFunc\u003cTFunction, TRealFunction\u003e(TRealFunction\u0026\u0026 func)`\n\n   Use this function as\n\n   ```C++\n   UC::MakeFunc\u003c?function-type?\u003e(?function/function-object/lambda/closure to-make-from?)\n   ```\n\n   Where \u003cspan style=\"color:green\"\u003e?function-type?\u003c/span\u003e refers to the type of the function it can be `UC::Function\u003cTReturn, TParameters...\u003e` or a Function type alias. \u003cspan style=\"color:green\"\u003e?function/function-object/lambda/closure to-make-from?\u003c/span\u003e refers to exactly what the name says.\n\n### \u003cspan style=\"color:green\"\u003e√ Events ← Qt\u003c/span\u003e\n\nEvents are technically from C#. However they are also implemented in Qt (\u0026 Boost), but there they are called as signals and the functions which register to them are called slots. In C#, signals and slots are referred to as events and delegates. In UC++, signals and slots are referred to as events and functors (would you rather prefer \"Group of UC++ GC pointer to function object\" and \"UC++ GC pointer to function object\").\n\nThe template parameters for an event are the same as a functor `UC::Event\u003cTReturn, TParameters...\u003e`.\n\nTo create an event use `?event-type::Make()?` and assign it to a variable to class field.\n\nTo add a function, function-object, lambda or closure use `?event?-\u003eAdd(?function/function-object/lambda/closure to-add?)`. To add a `UC::Function` use `?event?-\u003eAddF(?functor?)`. The return value of these functions is the id of the functor added, hold onto it if you want to erase the functor later.\n\nTo remove a functor using it's id use `?event?-\u003eRemove(?id?)`.\n\nTo invoke the event use `?event?-\u003eEval(?parameters?...)` with the designated \u003cspan style=\"color:green\"\u003e?parameters?...\u003c/span\u003e. If the functor returns a value then `Eval` returns the return value of the last function, if there are no functors added then an error of type `UC::NoFunctorsAddedToEvent_Exception`, with the message\n\n```C++\n\"UC::Event\u003cTReturn, TParameters...\u003e has no added functors that can return a value that can be returned.\"\n```\n\nIf you want to get the return value of all the functions in a `UC::NatVector\u003cTReturn\u003e` use `?event?-\u003eEvalAll(?parameters?...)` with the designated \u003cspan style=\"color:green\"\u003e?parameters?...\u003c/span\u003e. Obviously, if the functors return `void` then `EvalAll` will not return a `UC::NatVector\u003cvoid\u003e`. In reality, `EvalAll` will call all the functions and return `void`. If there are no functors added then the returned vector will have size `0`.\n\nAn event is a functor, i.e. you can chain events, i.e. subscribe an event to an event.\n\n### \u003cspan style=\"color:gray\"\u003e√ Singleton ← Kotlin\u003c/span\u003e\n\nThe singleton pattern comes inbuilt with Kotlin, UC++ also provides an inbuilt singleton pattern. \n\nFor more information look to the documentation on the macro \u003cspan style=\"color:purple\"\u003eUC_IsSingleton\u003c/span\u003e.\n\n### \u003cspan style=\"color:green\"\u003e√ Generators ← C#\u003c/span\u003e\n\nFrom [Wikipedia:Generator (computer programming)](https://en.wikipedia.org/wiki/Generator_(computer_programming))\n\n\u003e In computer science, a generator is a special routine that can be used to control the iteration behaviour of a loop. In fact, all generators are iterators. A generator is very similar to a function that returns an array, in that a generator has parameters, can be called, and generates a sequence of values. However, instead of building an array containing all the values and returning them all at once, a generator yields the values one at a time, which requires less memory and allows the caller to get started processing the first few values immediately. In short, a generator looks like a function but behaves like an iterator.\n\nThe generators in UC++ do fulfil the above requirements but UC++ generators can do more, much. Look to the documentation for more info.\n\n### \u003cspan style=\"color:darkgreen\"\u003e√ Coroutines ← Unity\u003c/span\u003e\n\nA similar system to the one provided by Unity by UC++, though there are some differences.\n\nLook to the documentation for more info.\n\n### \u003cspan style=\"color:blue\"\u003e√ Multiple Class Inheritance ← C++\u003c/span\u003e\n\nFrom C++!!\n\n### \u003cspan style=\"color:blue\"\u003e√ Block Structured Programming ← Swift\u003c/span\u003e\nAlready in C++.\n\n\n\n# [Documentation](./DOCUMENTATION.md)\n\n\n\n\n# Conversion, Macro substitution\n\nThe pre-macro substitution state:\n\n```C++\n//Empty.hpp\nstruct NEmpty\n{\n\tvoid NativeBaseFunction( );\n};\n\nUCInterface( Empty ,\n\t\t\t UC_WhereTypenameIsRealName ,\n\t\t\t UC_InheritsUCClasses( UC::Object ) ,\n\t\t\t UC_InheritsNativeClasses( NEmpty )\n)\nUC_HasExplicitCtors( Empty , UC_AlsoHasEmptyMaker , ( _1 ) );\nUC_HasMethods(\n( Do ) ,\n( Do , ( _1 ) ) ,\n( Do , ( _1 , _2 ) )\n);\n\nvoid NativeFunction( );\n\nUCEndInterface;\n```\n\n\n```C++\n//Empty.cpp\n#include \u003ciostream\u003e\n#include \"Empty.hpp\"\n\nusing namespace std;\n\nUCRegister( Empty );\n\nUCCtor( Empty::Empty )\n{\n\tcout \u003c\u003c \"0 parameters for \" __FUNCTION__ \u003c\u003c endl;\n}\n\nUCCtor( Empty::Empty , ( _1 ) )\n{\n\tcout \u003c\u003c \"1 parameter for \" __FUNCTION__ \u003c\u003c endl;\n}\n\n\nUCMethod( Empty::Do )\n{\n\tcout \u003c\u003c \"0 parameters for \" __FUNCTION__ \u003c\u003c endl;\n\treturn nullptr;\n}\n\nUCMethod( Empty::Do , ( _1 ) )\n{\n\tcout \u003c\u003c \"1 parameter for \" __FUNCTION__ \u003c\u003c endl;\n\treturn nullptr;\n}\n\nUCMethod( Empty::Do , ( _1 , _2 ) )\n{\n\tcout \u003c\u003c \"2 parameter for \" __FUNCTION__ \u003c\u003c endl;\n\treturn nullptr;\n}\n\nvoid Empty::NativeFunction( ) { std::cout \u003c\u003c \"From native function:\" __FUNCTION__ \u003c\u003c std::endl; }\n\nvoid NEmpty::NativeBaseFunction( ) { std::cout \u003c\u003c \"From native function in base:\" __FUNCTION__ \u003c\u003c std::endl; }\n```\n\nThe post-macro substitution state:\n\n```C++\n//Empty.hpp\nstruct NEmpty\n{\n\tvoid NativeBaseFunction( );\n};\n\nstruct Empty : UC::Object , NEmpty , ::UC::EnableGCPtrFromMe\u003cEmpty\u003e\n{\n\tusing base0 = UC::Object;\n\tusing nbase0 = NEmpty;\n\tusing self = Empty;\n\tusing pself = ::UC::GCP\u003cself\u003e;\n\tusing wself = ::UC::WeakPtr\u003cself\u003e;\n\tusing EGCPFM = ::UC::EnableGCPtrFromMe\u003cEmpty\u003e;\nprotected:\n\tauto callImplUpChain( const ::UC::NatString\u0026 fname , const ::UC::NatODeque\u0026 args ) -\u003e ::UC::P_Any\n\t{\n\t\ttry\n\t\t{\n\t\t\tauto res0 = base0::callImpl( fname , args );\n\t\t\tif ( res0 ) return res0;\n\t\t}\n\t\tcatch ( const ::UC::NoSuchFunction_Exception\u0026 ) { };\n\t\tthrow ::UC::NoSuchConstructor_Exception(::UC::ConcatNatStrings(\n\t\t\t\t::UC::NatString( \"No function for type \\\"\" \"Empty\" \"\\\" with name \\\"\" ) ,\n\t\t\t\tfname , \"\\\" that takes in \" , std::to_string( args.size( ) ) ,\n\t\t\t\t\" parameters.\" ) );\n\t}\nprivate:\n\tstruct __classRegisterer\n\t{\n\t\t__classRegisterer( )\n\t\t{::UC::Object::addConstructor( \"Empty\" , \u0026self::make_reflective );}\n\t};\n\tstatic __classRegisterer __classRegistererInstance;\npublic:\n\tstatic const ::UC::NatString\u0026 SGetTypeName( )\n\t{\n\t\tstatic auto nm = ::UC::NatString( \"Empty\" );\n\t\treturn nm;\n\t}\n\tvirtual const ::UC::NatString\u0026 GetTypeName( ) const override{return SGetTypeName( );}\n\ttemplate\u003ctypename... Args\u003estatic ::UC::GCP\u003cself\u003e Make( Args\u0026\u0026... args )\n\t{return ::UC::GCP\u003cself\u003e( new self( std::forward\u003cArgs\u003e( args )... ) );}\nprotected:\nprotected:\n\tEmpty( );\n\tEmpty( ::UC::P_Any _1 );\npublic:\n\tstatic ::UC::P_Any make_reflective( const ::UC::NatODeque\u0026 args )\n\t{\n\t\tswitch ( args.size( ) )\n\t\t{\n\t\tcase 0:return ::UC::GCP\u003cself\u003e( new self( ) );\n\t\tcase 1: return ::UC::GCP\u003cself\u003e( new self( args[ 0 ] ) );\n\t\tdefault: throw ::UC::NoSuchConstructor_Exception(\n\t\t\t::UC::ConcatNatStrings(::UC::NatString( \"No constructor for type \\\"\" ) ,\n\t\t\t\tSGetTypeName( ) , \"\\\" that takes in \" , std::to_string( args.size( ) ) ,\n\t\t\t\t\" parameters.\" ) );\n\t\t}\n\t};\npublic:\n\tvirtual auto Do( ) -\u003e ::UC::P_Any;\n\tvirtual auto Do( ::UC::P_Any _1 ) -\u003e ::UC::P_Any;\n\tvirtual auto Do( ::UC::P_Any _1 , ::UC::P_Any _2 ) -\u003e ::UC::P_Any;\nprotected:\n\tauto callImpl( const ::UC::NatString\u0026 fname , const ::UC::NatODeque\u0026 args ) -\u003e ::UC::P_Any\n\t{\n\t\tconst auto\u0026 argsLen = args.size( );\n\t\tif ( fname == \"Do\" \u0026\u0026 argsLen == 0 ) { return this-\u003eDo( ); }\n\t\tif ( fname == \"Do\" \u0026\u0026 argsLen == 1 ) { return this-\u003eDo( args[ 0 ] ); }\n\t\tif ( fname == \"Do\" \u0026\u0026 argsLen == 2 ) { return this-\u003eDo( args[ 0 ] , args[ 1 ] ); }\n\t\treturn callImplUpChain( fname , args );\n\t}\npublic:\n\tvirtual ::UC::P_Any Call( const ::UC::NatString\u0026 fname , const ::UC::NatODeque\u0026 args ) override {return callImpl( fname , args );};\n\tvoid NativeFunction( );\n};\n```\n\n\n```C++\n//Empty.cpp\n#include \u003ciostream\u003e\n#include \"Empty.hpp\"\n\nusing namespace std;\n\nEmpty::__classRegisterer Empty::__classRegistererInstance {};\n\nEmpty::Empty( )\n{\n\tcout \u003c\u003c \"0 parameters for \" __FUNCTION__ \u003c\u003c endl;\n}\n\nEmpty::Empty( ::UC::P_Any _1 )\n{\n\tcout \u003c\u003c \"1 parameter for \"  __FUNCTION__ \u003c\u003c endl;\n}\n\n\nauto Empty::Do( ) -\u003e ::UC::P_Any\n{\n\tcout \u003c\u003c \"0 parameters for \"  __FUNCTION__ \u003c\u003c endl;\n\treturn nullptr;\n}\n\nauto Empty::Do( ::UC::P_Any _1 ) -\u003e ::UC::P_Any\n{\n\tcout \u003c\u003c \"1 parameter for \"  __FUNCTION__ \u003c\u003c endl;\n\treturn nullptr;\n}\n\nauto Empty::Do( ::UC::P_Any _1 , ::UC::P_Any _2 ) -\u003e ::UC::P_Any\n{\n\tcout \u003c\u003c \"2 parameter for \"  __FUNCTION__ \u003c\u003c endl;\n\treturn nullptr;\n}\n\nvoid Empty::NativeFunction( ) { std::cout \u003c\u003c \"From native function:\" __FUNCTION__ \u003c\u003c std::endl; }\n\nvoid NEmpty::NativeBaseFunction( ) { std::cout \u003c\u003c \"From native function in base:\" __FUNCTION__ \u003c\u003c std::endl; }\n```\n\nSee no surprises, no magic code, after macro substitution it's just plain C++. \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faryan-programmer%2Funiversal-cpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faryan-programmer%2Funiversal-cpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faryan-programmer%2Funiversal-cpp/lists"}