https://github.com/b1f6c1c4/cpp-create-objects

How many ways to create object(s) in C++?

https://github.com/b1f6c1c4/cpp-create-objects

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.1%) to scientific vocabulary

Keywords

cplusplus cpp
Last synced: 5 months ago · JSON representation

Repository

How many ways to create object(s) in C++?

Basic Info
  • Host: GitHub
  • Owner: b1f6c1c4
  • License: cc0-1.0
  • Language: C++
  • Default Branch: master
  • Homepage:
  • Size: 31.3 KB
Statistics
  • Stars: 5
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
cplusplus cpp
Created about 7 years ago · Last pushed about 7 years ago
Metadata Files
Readme License

README.md

How many ways to create object(s) in C++?

Build Status License

Only heard of T a and new T()? You are not a REAL™ C++ programmer.

Checkout how many ways you can think of to create some objects.

Rules

  • Write your snippet in snippet/**/*.hpp:
    • We will #include <stdlib.h> for you at the beginning.
    • It should have one (1) function definition named create:
    • You may use auxilliary typedef, function, etc.
    • You may NOT do anything irrelevent to the object creation.
    • You MUST use auto whenever possible.
    • The creation method should be universal - not just for our stub.
  • Checkout main.cpp and see what is considered valid.
    • Remember, MAGIC_NUMBER is 114514.
  • Two creation methods are considered identical if they:
    • are lexically the same (adding comments); or
    • are syntactically the same (adding parentheses); or
    • are (trivially) semantically the same (1+1 v.s. 2); or
    • are identical after preprocessor;
    • only differ quantitatively (repeating something)
  • Two methods are NEVER considered identical if they:
    • call different constructors
  • Dirty methods are allowed as long as they:
    • are not identical to previous methods;
    • are compilable by both g++ and clang++ on ubunut xenial;
    • don't triggering any warnings (-Wextra);
    • are not "evil" (rm -rf /*)
  • Additional rules for single:
    • with template typename T;
    • of signature T ();
    • invoke the constructor of T exactly once (1);
      • copy-constructor and move-constructor are NOT included
    • return an instance of T.
  • Additional rules for array:
    • with template typename T;
    • of signature void (check_t<T>), where check_t<T> = void (*)(size_t, T (*)[3]));
    • invoke the constructor of T exactly three (3) times
      • copy-constructor and move-constructor are NOT included
    • treat the three values equally (i.e., construct them the same way)
    • invoke the function pointer exactly once (1):
      • the first parameter should be the sizeof of the array
      • the second parameter should be the pointer to the created array

Example

snippet/single/named-default.hpp: c++ template <typename T> T create() { T a; return a; }

snippet/single/new-empty.hpp: c++ template <typename T> T create() { return *new T(); }

snippet/array/named-default.hpp: c++ template <typename T> void create(check_t check) { T a[3]; check(sizeof(a), &a); }

License

We don't want you to think about legal consequence every time before creating an object. This project is proudly licensed as Creative Commons Zero v1.0 Universal

Owner

  • Login: b1f6c1c4
  • Kind: user
  • Location: NJ, USA
  • Company: Princeton University

52BE D143 A92D BE96 2B83 092B 9BAC 0164 9600 1E70

GitHub Events

Total
Last Year

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 20
  • Total Committers: 2
  • Avg Commits per committer: 10.0
  • Development Distribution Score (DDS): 0.25
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
b1f6c1c4 b****4@g****m 15
Jacob Zhong c****e@q****m 5
Committer Domains (Top 20 + Academic)
qq.com: 1

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 1
  • Total pull requests: 2
  • Average time to close issues: about 15 hours
  • Average time to close pull requests: about 17 hours
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 4.0
  • Average comments per pull request: 0.5
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • cmpute (1)
Pull Request Authors
  • cmpute (2)
Top Labels
Issue Labels
rules (1)
Pull Request Labels