- "std::format in C++20" by Peter Gottschling - 1 Update
- Why should a "c" programmer learn c++ ? (V2) - 2 Updates
- basic_ofstream(const basic_ofstream&) = delete - 7 Updates
Lynn McGuire <lynnmcguire5@gmail.com>: Oct 06 04:06PM -0500 "std::format in C++20" by Peter Gottschling http://www.modernescpp.com/index.php/std-format-in-c-20 "Today, I'm happy to present Peter Gottschling's guest post to the new formatting library in C++20: std::format. Thanks to std::format, text formatting becomes in C++20 as easy as in Python." "Peter is the author of the must-read book "Discovering Modern C++" for professional C++ developers." https://www.amazon.com/Discovering-Modern-Scientists-Programmers-Depth/dp/0134383583 Lynn |
Juha Nieminen <nospam@thanks.invalid>: Oct 06 06:03AM > An "unwanted duplication of the function implementation" has no need to > involve the linker, if it is an inline definition. What I meant by "duplication" was not that the code is duplicated (which it rather obviously probably will be, if it's inlined into several places), but that the function definition itself is duplicated, just as if you had a non-static non-inline function definition in a header, and that header included and used in multiple compilation units. I admit it's not 100% clear to me what 'inline' means in C (because it's quite confusing), but to the best of my understanding is that when it comes to the linker, it ought to work like in C++. In other words, an inline function (with no non-inline version) never causes a linker error for duplicated symbols. I could be wrong. For some reason C decided to make inline functions really complicated and hard to understand. |
James Kuyper <jameskuyper@alumni.caltech.edu>: Oct 06 03:12PM -0400 On 10/6/20 2:03 AM, Juha Nieminen wrote: > but that the function definition itself is duplicated, just as if you > had a non-static non-inline function definition in a header, and > that header included and used in multiple compilation units. It could, instead, have been duplicated in the same fashion that a static function would be. Such a duplicate wouldn't use up any less space than the one you're talking about, but it would also not involve the linker in any way. > comes to the linker, it ought to work like in C++. In other words, an > inline function (with no non-inline version) never causes a linker error > for duplicated symbols. That's almost true of C too, but not quite. In C, an external definition can be provided for an inline function with external linkage, in addition to the inline definition. It's perfectly legal for the external definition and the inline definition to be different. In most cases, it would be a bad idea to do so, since it's unspecified which version is used by any given call to that function. About the only reasonable use I can see for taking advantage of that fact would be that it allows you to monitor which one is used. Providing more than one such external definition would cause a linker error, just as it would for a non-inline function. . |
RM <robert_magdziarz@wp.pl>: Oct 06 12:11PM +0200 When trying to output xml_document of rapidxml library: ofstream xml_file(xml_filepath.c_str()); print(xml_file, doc, 0); I recive error: src/cache.cpp: In function 'void save_cache(std::__cxx11::string, const char*, const char*, std::__cxx11::string, std::__cxx11::string, std::__cxx11::string, bool&, const identifiers_vector (&)[5], const std::unordered_map<std::__cxx11::basic_string<char>, apostrophed_strings_map>*)': src/cache.cpp:204:27: error: use of deleted function 'std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const std::basic_ofstream<_CharT, _Traits>&) [with _CharT = char; _Traits = std::char_traits<char>]' print(xml_file, doc, 0); ^ In file included from src/cache.cpp:14:0: /usr/include/c++/7/fstream:723:7: note: declared here basic_ofstream(const basic_ofstream&) = delete; ^~~~~~~~~~~~~~ How can I solve the problem of deleted function? |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 06 12:59PM +0200 Am 06.10.2020 um 12:11 schrieb RM: > basic_ofstream(const basic_ofstream&) = delete; > ^~~~~~~~~~~~~~ > How can I solve the problem of deleted function? Define a proper print-function that takes a _reference_ to the stream. |
"Öö Tiib" <ootiib@hot.ee>: Oct 06 04:04AM -0700 On Tuesday, 6 October 2020 13:11:25 UTC+3, RM wrote: > When trying to output xml_document of rapidxml library: > ofstream xml_file(xml_filepath.c_str()); > print(xml_file, doc, 0); You post again what does not even compile? Your print function is bad. This time about some kind of library that probably hasn't been maintained for more than 10 years? > How can I solve the problem of deleted function? Streams are not copyable so copy constructor is deleted. You solve your problem with it by not attempting to copy streams. |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 06 01:06PM +0200 >> How can I solve the problem of deleted function? > Streams are not copyable so copy constructor is deleted. You solve > your problem with it by not attempting to copy streams. I'm wondering why he is dealing with such beyond-n00b-topics like doing xml-processing and not even knowing how to define the print function properly. |
"Öö Tiib" <ootiib@hot.ee>: Oct 06 04:50AM -0700 On Tuesday, 6 October 2020 14:07:10 UTC+3, Bonita Montero wrote: > I'm wondering why he is dealing with such beyond-n00b-topics like > doing xml-processing and not even knowing how to define the print > function properly. I suspect that the reason is that there are not enough stand-alone interesting novice programming missions but to do something actually useful isn't easy. For example try to communicate with some useful online service. Those often reply to requests with xml, csv, yaml or json. Same is with data or config files of some on-premise program. Such are often whole compressed directories of huge structured text files. For me it is piece of cake ... but for novice in world full of various garbage libraries it is hilly territory. |
James Kuyper <jameskuyper@alumni.caltech.edu>: Oct 06 12:10PM -0400 On 10/6/20 6:11 AM, RM wrote: > basic_ofstream(const basic_ofstream&) = delete; > ^~~~~~~~~~~~~~ > How can I solve the problem of deleted function? From what you've told us so far, the only thing we can say is "don't do that". It would be easier to provide a useful answer to that question if you would provide the source code for save_cache() from src/cache.cpp. |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 06 07:02PM +0200 > From what you've told us so far, the only thing we can say is "don't do > that". It would be easier to provide a useful answer to that question if > you would provide the source code for save_cache() from src/cache.cpp. Not necessary. He is obviously passing an ofstream by value and not by referrence. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment