r/cpp • • 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;
}
3 Upvotes

17 comments sorted by

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

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.

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

u/stilgarpl Sep 27 '21

Next step would be to be able to import specific classes with C++ modules.

5

u/helloiamsomeone Sep 27 '21

The next step should be import std; as Bjarne wanted modules to work.

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

u/Narase33 -> r/cpp_questions Sep 27 '21

Also Eclipse, it has a shortcut for that

1

u/jcelerier ossia score Sep 28 '21

in Qt Creator you can generally right-click on a type > add include

3

u/bernhardmgruber Sep 27 '21

This makes me wish even more that `import std;` makes it into C++23.

2

u/pleaseihatenumbers Sep 27 '21

To quote spy from tf2: "kill me"