Include everything, Separate "use"

I am developing a C ++ library. This made me think about how to handle Java and C #, including various library components. For example, Java uses β€œimports” to allow the use of classes from other packages, and C # simply uses β€œuses” to import entire modules.

My questions: would it be a good idea # to include everything in the library in one massive include, and then just use the using directive to import certain classes and modules? Or will it just be crazy?

EDIT: Good answers so far, here are a few mitigating factors that I feel adding to this idea:

1) The internal #includes are contained as usual (short and dots)
2) A file that includes everything is supplied with the library for those who want to use it. 3) . You can optionally make a large include file part of a precompiled header

+3
source share
5 answers

#include ++. Java #. #include , ; , . , . , , #include, , .

#include ; . (, , )

tl; dr β†’ , . #include . , , , .

+5

, , , . , , , , . , , , , /; .

+2

, , , . , , , .

using - , - , , . , #include d, ? .

, , .:)

+1

@Billy ONeal, , #include - , "^ C, ^ V" (-) , .

++ , ".h" ".cpp". , C/++ , .

, M $ , , . , , , .

, Qt, . , , .

0

I think this will be confusing. When you write C ++, you should avoid making it look like Java or C # (or C :-). I would really wonder why you did it.

Providing an include-all file is actually not that useful, as the user can easily create it by himself, using those parts of the library that are actually used. You can then add it to the precompiled header, if one is used.

0
source

Source: https://habr.com/ru/post/1795402/


All Articles