r/cpp • u/andre_friend • Sep 27 '21
stdeasy - Easy way to find header
https://github.com/olegpublicprofile/stdeasy
Instead of opening C++ documentation for searching header for STL class you can include header with class name, for example std::pair
#include <stdeasy/pair>
int main()
{
std::pair<int, int> pair;
return 0;
}
23
u/carrottread Sep 27 '21
https://github.com/olegpublicprofile/stdeasy/blob/master/include/stdeasy/vector
#include "stdfwd_details.hpp"There is no such file in the repository.
And it doesn't include <vector>, it just forward declares it, which is UB.
3
22
u/stilgarpl Sep 27 '21
Instead of opening C++ documentation for searching header for STL class
Who does that? I just type std::pair and let my IDE automatically add proper includes...
8
u/PunctuationGood Sep 27 '21 edited Sep 27 '21
When said that way, it's amusing to imagine that the next step would be for the compiler to do it for you.
9
5
2
u/gvcallen Sep 27 '21
which IDE does that?
4
u/stilgarpl Sep 27 '21
Clion.
1
u/gvcallen Sep 27 '21
aha. thought as much. VS Code extension for that would be nice 😂
1
u/jguegant Sep 27 '21
VS Code + clandg does that automatically too.
1
u/gvcallen Sep 28 '21
I've tried setting that up but failed. how did you get auto includes to work? did you use the clangd extension?
1
u/jguegant Sep 28 '21
Clangd does it automatically. In fact it does it so well that sometimes people want to disable it: https://github.com/clangd/clangd/issues/55
1
1
u/jcelerier ossia score Sep 28 '21
in Qt Creator you can generally right-click on a type > add include
3
46
u/gvcallen Sep 27 '21
Cool idea, but no thanks. I'd rather just include the stock header than add a dependency to every project I build because I didn't want to do a quick Google search. Plus this might add confusion for readers of a source tree, as opposed to simply using the standard includes which everyone understands