Comments (4)
Thanks for the bug report.
This code does not compile for me in g++, I get:
$ g++ -c a.cc
a.cc: In function ‘bool isUpper(const string&)’:
a.cc:7:55: error: no matching function for call to ‘find_if(std::__cxx11::basic_string<char>::const_iterator, std::__cxx11::basic_string<char>::const_iterator, <unresolved overloaded function type>)’
7 | return std::find_if(s.begin(), s.end(), std::islower) == s.end();
| ^
In file included from /usr/include/c++/10/algorithm:62,
from a.cc:2:
/usr/include/c++/10/bits/stl_algo.h:3925:5: note: candidate: ‘template<class _IIter, class _Predicate> _IIter std::find_if(_IIter, _IIter, _Predicate)’
3925 | find_if(_InputIterator __first, _InputIterator __last,
| ^~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3925:5: note: template argument deduction/substitution failed:
a.cc:7:55: note: couldn’t deduce template parameter ‘_Predicate’
7 | return std::find_if(s.begin(), s.end(), std::islower) == s.end();
| ^
Which variant of C++ are you using? CDT is missing some support for C++17 and newer standards.
from cdt.
The code does not compile even if you pass -std=c++17
or -std=c++20
(I'm using GCC 12) -- if you ask CDT to open the declaration, it seems to be trying to resolve bool std::islower(char, locale)
instead of int std::islower(int)
Maybe this is what the "unresolved overloaded function type" error from GCC is trying to tell me, but I'm not really a C++ guy and I find C++ errors a bit impenetrable :-)
However passing a lambda instead seems to make it compile just fine:
return std::find_if(s.begin(), s.end(), [](unsigned char c) {return std::islower(c);}) == s.end();
And indeed CDT is also happy with it as a lambda, so CDT seems consistent with GCC here.
Removing the std
prefix presumably causes it to use the int islower(int)
libc function from the C header ctype.h
Maybe @Sporking can tell us more about their compiler version and the compiler flags they are using....
from cdt.
After doing more research, I think that this was the problem:
https://stackoverflow.com/questions/7131858/stdtransform-and-toupper-no-matching-function
Specifically, there is more than one 'std::islower' in the C++ standard library, and when its address is taken without function arguments to disambiguate, the compiler can't decide which one is meant.
I think that the reason that my code was able to successfully compile on Visual Studio 2017 is because they were probably including a different set of C++ standard header files in their includes than the header files I was using with Eclipse (which were from the Cygwin gcc 11 release). So when I compiled, it probably only included one definition of std::islower instead of two that were included when I used Eclipse with gcc header files.
Thanks for your investigations. I am closing this bug, since at the moment I think that Eclipse was probably behaving correctly.
from cdt.
Thanks @Sporking for reporting back on your resolution and closing this issue.
from cdt.
Related Issues (20)
- CDT cannot be built on Java 21 due to security manager changes
- java.lang.NullPointerException: Cannot invoke "org.eclipse.cdt.core.parser.IToken.getType()" because "token" is null
- Migrate from javax.inject|annotation to Jakarta
- *.S files are not preprocessed in managed builds HOT 11
- Switch from "Require-Bundle: org.eclipse.osgi.services" to "Import-Package" directive HOT 1
- Adding new lines above collapsed code breaks the display of collapsed code
- std::optional is not working on Eclipse 4.30.0 HOT 4
- Invalid template Arguments for std::map in Eclipse 2023-12 with GCC version 13.2.0 HOT 5
- Improve workflow for new users when MinGW toolchain not detected HOT 2
- Terminal does not read Eclipse variables used as argument for External Executables HOT 1
- Jenkins CI failing to complete builds HOT 4
- Macro expansion for functions and function pointers
- Add compile-commands.json generation for Managed Build Projects HOT 12
- Remove Build and Clean command fields from Launch Bar Launch Configuration, Build Settings tab
- Fix resource leak warnings for org.eclipse.cdt.core.utils
- Improve localization for `org.eclipse.tools.templates.ui` bundle
- An internal error occurred during: "Launching Eclipse Application". Cannot invoke "java.util.List.stream()" because the return value of "java.util.Map.get(Object)" is null HOT 3
- Binding lookup for Constructor Call vs Method Call
- Platform APIs have been removed breaking CDT build on latest platform dependencies
- NPE after creation of new cmake project
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cdt.