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

Constificator: suggests this-const for BoundedBuffer::push_many #31

Open
The-Compiler opened this issue Aug 24, 2019 · 0 comments
Open
Labels
bug Something isn't working

Comments

@The-Compiler
Copy link

I'm using Archlinux, with Cevelop 1.12.1-201907081203 and Constificator 1.12.2.20190710144.

With this source code (from BoundedBuffer):

	template<typename Head, typename... Tail>
	void push_many(Head && head, Tail &&... tail) {
		push(std::forward<Head>(head));
		if constexpr (sizeof...(Tail)) {
			push_many(std::forward<Tail>(tail)...);
		}
	}

	template<typename E>
	void push(E && element) {
		ensureNotFull();
		auto const position = &(*this)[sizeCounter];
		new (position) value_type{ std::forward<E>(element) };
		sizeCounter++;
	}

I'm getting:

image

But obviously push_many can't be this-const, as it calls push which isn't const:

In file included from ../src/bounded_buffer_student_suite.cpp:4:
../src/BoundedBuffer.h: In instantiation of ‘void BoundedBuffer<T>::push_many(Head&&, Tail&& ...) const [with Head = int; Tail = {int, int}; T = int]’:
../src/bounded_buffer_student_suite.cpp:17:26:   required from here
../src/BoundedBuffer.h:112:3: error: passing ‘const BoundedBuffer<int>’ as ‘this’ argument discards qualifiers [-fpermissive]
  112 |   push(std::forward<Head>(head));
      |   ^~~~
../src/BoundedBuffer.h:150:7: note:   in call to ‘void BoundedBuffer<T>::push(E&&) [with E = int; T = int]’
  150 |  void push(E && element) {
      |       ^~~~
@fmorgner fmorgner transferred this issue from Cevelop/Issues Feb 23, 2021
@fmorgner fmorgner added the bug Something isn't working label Feb 23, 2021
@fmorgner fmorgner changed the title Constificator suggests this-const for BoundedBuffer::push_many Constificator: suggests this-const for BoundedBuffer::push_many Feb 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants