Skip to content

temp&func #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

temp&func #29

wants to merge 1 commit into from

Conversation

Tigerrr07
Copy link

  1. 修复vector<<重载函数

补充模板类template<class T>

  1. 修复两个vector相加+重载函数+列表的逐元素加法

使用using+decltype获取相加后的类型,随后创建新类型的vector再for循环相加

  1. 实现自动匹配容器variant中具体类型的加法

使用visit+lambda表达式得到+左右两个变量的类型,由于vector的加法在2中实现,故直接返回a+b

  1. 实现自动匹配容器variant中具体类型的打印

也需要通过visit+lambda表达式得到variant中的具体类型,然后给os,随后返回os

  1. main()中有variant<vector<int>, vector<double>>variant<double>的加法,由于原程序中未实现,因此实现了variant<T1, T2> const &b, T2 const &a的加法,而且需要考虑参数顺序,否则还需要写一个重载函数(暂时未想到如何不考虑顺序);且若是variant<vector<int>, vector<double>>variant<int>的加法,则仍需做相应的加法重载,main()中没调用,就不再实现。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant