Are constexpr functions that load files in C ++?

Here was a similar question, but it did not have any important information, so I want to ask again about this - is it possible to load the contents of an arbitrary file using the constexprfunction? I know that this seems impossible, since all the possible functions that allow file input / output ( fopen, open...) are not constexpr, therefore, cannot be called in this script. However, since there are many people who follow the development of C ++ 17 and beyond, is there any hope that additional standards will include some file I / O API that will constexprand can be used to download the file at compile time?

Just for comparison - Haxe allows you to do almost everything with compilation time macros, so it would be great to have something like this in C ++. For example, generating instances of a class by deserializing files.

+4
source share
1 answer

This (at least for me) is a typical case of excessive complexity when switching between languages. Yes, you could implement the functionality to add the loading of the compile-time file in C ++, we could also add reflection at runtime. However, in my opinion, they are not needed and functions are not needed.

, constexpr, ( Microsoft), , .

, .h(header), . .

, constexpr ,

" ", IDE , , , .

FOSS ./configure - Git - , , .

, , ++ 17 , , - , , .

, , . ~ Bjarn Stroustrup

( ). , ... .

, - , ..

[/]

- - ; , , - , , , - . , ++.

[edit 2/]

: " char *, ! .

  • , char* constantexp? , , - , .
  • - , ++ ( , ).

- - , , , ? ? ? ?

, . , , , (: \0x0, \0x12, \0x22), , . #include - , , , , ++, .

, , ++ , , Very Bad Press. , , - .

, ++ , " ++ ", , Nokia 1990 - , , , ++ . Java - .

, : , . , , , , ++ - Utopia, . , , . , , .

+6

All Articles