Skip to content
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

Add support for range assign and insert for input iterator #163

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

Conversation

winner245
Copy link
Contributor

@winner245 winner245 commented Oct 28, 2024

This patch addresses the issue where range assignment and insertion for vector did not support input iterators. With this update, both range assignment and insertion now fully support iterators of the input iterator category. New tests have been added to validate the correctness of the code, and all existing tests have passed successfully. With the prior PR #160 adding support for input iterators for the constructor of vector, this PR extends that support to both range assignment and range insertion.

@Peas-Li
Copy link

Peas-Li commented Oct 29, 2024

大佬,我问你一个问题:
#include
using namespace std;
template
class B
{
B(){
const int a = 1;
const T b = a;
}
};
int main()
{
B<int&> v;
return 0;
}
报错error: binding reference of type 'int&' to 'const int' discards qualifiers
为什么

@Peas-Li
Copy link

Peas-Li commented Oct 29, 2024

可以看一下issue里面第一个我的提问吗,实在是不理解,谢谢啦

@winner245
Copy link
Contributor Author

winner245 commented Oct 29, 2024

报错信息不是已经很清楚了吗?int& b = const_a; 这样的初始化有问题。类模板中 const T b = a; 的 const 是施加给 T 的 top-level const 属性,不是 low-level const。你换成 B<const int&> v; 试试

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.

2 participants