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

min_element() fails to compile on custom container without an empty() method #51

Closed
dfaure-kdab opened this issue Mar 11, 2023 · 0 comments

Comments

@dfaure-kdab
Copy link
Member

In my own class called Node, I wrote

	        using value_type     = std::unique_ptr<AbstractPrintItem>;
		using const_iterator = std::vector<std::unique_ptr<AbstractPrintItem>>::const_iterator;
		const_iterator begin() const
		{
			return m_printItems.begin();
		}
		const_iterator end() const
		{
			return m_printItems.end();
		}

This works fine for range-for, and STL algorithms.
But kdalgorithms::min_element failed to build with

kdalgorithms.h:214:19: error: ‘const class Node’ has no member named ‘empty’
  214 |     if (container.empty())

Shouldn't this be a begin()==end() test instead?

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

No branches or pull requests

2 participants