Task 2 : Templated Triple
Having learnt about classes, templates and concepts I want you to reimplement your Triple
class so that it behaves more like a standard type and has a more sophisticated implementation and interface. Similar to Assignment 1, you will submit using a pull request on GitHub to this repo.
Requirements
- Must be templated for a single type
T
- A way to add two points of different
T
- A way to subtract two points of different
T
- A way to multiply a point by a scalar of different
T
- A way to divide a point by a scalar of different
T
- A way to be print a formatted output using
std::cout
- Using concepts ensure that
T
satisfies only:std::integral
- or
std::floating_point
- or
T
andU
supportT + U
T - U
U * T
T / U
- and doesn't support
is_pointer
is_reference
is_enum
etc.
- and
T
supports<<
to anstd::ostream
Note: Let me know if the concept requirements are confusing
Bonus
- A way to be created using input from
std::cin
- Allow three different type parameter; say
T
,U
andV
for the member variables while still maintaining the base requirements [hard]
Submitting
You can use Godbolt or bpt to build and test your struct. Once you have created your implementation:
- Clone this repo using
git clone https://github.com/MonashDeepNeuron/HPP.git
. - Create a new branch using
git checkout -b triple/<your-name>
. - Create a folder in the
/submissions
directory with your name. - Create a folder with the name of this task.
- Copy your mini project into this directory (bpt setup, cmake scripts etc.) with a
README.md
or comment in the code on how to run the program (verify it still works). There is a sample header file in/templates
that you can use. - Go to https://github.com/MonashDeepNeuron/HPP/pulls and click 'New pull request'.
- Change the branches in the drop down so that your branch is going into
main
and `Create new pull request. - Give the pull request a title and briefly describe what you were able to implement and any struggles you had.
- On the right side-panel, under the 'Assignees' section, click the cog and assign me.
- Click 'Create pull request' and I'll take it from there.
Note: If you created a GodBolt instance, put the link in a comment at the top of the file (under your copy comments). This is generated by clicking the
share
button in the top-right-most corner of the webpage and clicking the 'short link' option.