@Griwes If you want you can avoid the extra logic with two read modes, one where you can only read forward (call it "streaming") and one where you can read back too (name?)
Hey guys I've got a problem. I have an implementation file and a header file with declarations. In the declaration file I have a template function, example:
Quote from The C++ standard library: a tutorial and handbook:
The only portable way of using templates at the moment is to implement them in header files by using inline functions.
Why is this?
(Clarification: header files are not the only portable solution. But they are the most convenien...
@Griwes Is the dynamic polymorphism bit really so bad? After all, there's a lot of code that handles the base classes of std:: streams and then uses those.
Granted, they probably do that because it's the only way right now, but I would imagine a lot of developers are thankful they don't have to nail their choice down to a specific type of stream (see the FILE* fiasco of many C APIs which for some reason only take a FILE* file pointer or a const char* fname c-string, and usually have to be hacked up later to deal with a section of memory or otherwise).
> First, and not limited to concepts, we need to treat a member template as dependent if its signature depends on template parameters of its enclosing class […]
@R.MartinhoFernandes Now what about the other direction? How do you do writes? And more importantly, how do you connect that with async IO? Or is the async IO layer just the layer that the iterators build upon?
I guess for "synchronous" writes you could make it possible to write through those iterators, and that's okay, but async IO needs to be an actual thing (though it probably should be the layer below).
Would need a way to flush all the changes done through iterators.
@ThePhD how is it any more gross than something = *it;?
auto file = open("asdf"); auto it = file.seek(1024); ++it; peek(it); is fully reasonable IMO; not sure if giving the option to do it += 10000; would make sense (especially since you already have seek).
There's a bit more of discussion and random attempts at online design in the discussion above.
If you could write an IO layer beneath that that allowed you not to be forced to move forward or backwards when doing a read or write that'd be the first part of making iterators more viable, right?
It'd behave basically like a segmented iterator, where each segments has a control node that keeps a shared pointer to a buffer segment and to the next control node.
These are the two messages most important for understanding what I'm getting at, I think.
@ThePhD Vapor, sitting on top of an UEFI bootloader and a brand new greenfield kernel following it, sitting on top of a CPU toyed with in Verilog (where I'm currently mostly fighting with the language), sitting on top of Despayre (which's my build system thingy), sitting on top of constant improvements to my general purpose libraries.
@Ell Well, if you've never seen code that thinks that getc (+ ungetc after failed peek...) is a right interface to use when parsing text, then you'll keep missing it.
If you've seen such code, you are probably hating it and hoping to forget it ever existed one day.
@Xeo interestingly I attempted a first stab at a fold expr’d tuples::scan but repeated calls to tuples::append makes me think it’s not really worth it—although I’ll probably sleep on it first and revisit it some time later
> "To be honest with you, Sol2 is the first binding library that I have compared against where I have had to disable runtime checks in OOLua, so credit to you for that."
@Mysticial Would definitely make debugging interesting...
@AndreasPapadopoulos That's not true at all. Fully 4% of his projects have at least 1 source file. Now if you'd asked for a source file that actually worked, that might be a different story...
I don't think the standard says much about Unicode, or specific characters/encoding. (aside from maybe codecvt) I'd assume it was all implementation-dependent.
@RobertHarvey At first glance, it looks like just a specific compiler is allowing it. I'm searching through the comments to see if anyone says anything about what the standard itself says.
They're two names for the same function that does the same things.
Note, however, that in C++ std::exit/exit (regardless of how you get to its name) does have some behavior that's not specified for the exit in the C library. In particular,
exit first destroys all objects with thread storage du...
@RobertHarvey C++ is in that odd position where it's (barely) good enough to give a glimpse (or at least a notion) of how much better things could be. Users of most languages never really think much about it. I wish I had a link handy--there was a fairly recent thread on Reddit, where a guy using Haskell was bemoaning the fact that he couldn't find a way to enforce even more via a type (and a Java user jumped in, clueless that Java not only wouldn't fix it, but couldn't do nearly as much).
@JerryCoffin One of the folks on Programmers is adamantly against unit testing, and I finally found out why: because the unit test tools don't force people to use them properly.
The paper that he always cites ("Why most unit testing is a waste") seems more like an indictment of object-orientation and human behavior than about anything relevant to unit testing as a practice.
@JerryCoffin Based on some of the stuff I've read from Java people, there are a good number of them who really think Java is better than all other languages for everything. It's almost as crazy as FOSS evangelism.
@RobertHarvey You have to read that paper really carefully to get much of out of it. What it comes down to is that he (largely) advocates in favor of testing an integrated system more than individual bits and pieces. The problem he cites (and I think it's quite real) is that many unit tests are written at a level where their passing is pretty much a given, but doesn't really tell you anything about the likelihood of the system working as a whole.
The opening of the paper is unfortunate, because it's easy to misunderstand it as an indictment of OO programming, and saying (in essence) that back in the Fortran days, life was better.
@Morwenn God no! At least not when I wrote Fortran, anyway. When you get down to it, his only real point is that back then systems in general were so simple that it was easy to compare inputs and outputs, and be (at least reasonably) certain that the transformation from one to the other was either right or wrong. Now they're enough more complex that you often can't.
@Morwenn That depended on the computer. Certainly lots of programmers (especially on small machines) didn't need to know or care about such, but for those using machines that had them (and they did exist) they mattered at least as much as they do now).
I think, however, that you're taking a relatively poor approach. If you want to learn to use C++ well for a particular type of situation, you're probably best off asking about that directly, rather than asking about the methods you currently believe will give the result you want. You've created a classic XY problem.
@RobertHarvey He does say a few other things I think are probably reasonable, at least for some problems--for example, test driven development and refactoring doesn't always lead to good architecture. At times it can, but nowhere close to always.
I hardly ever ask for help with Git these days, but I type more and more random commands when there's a problem and I still don't know how to cherry pick.
Merging is the difficult part. I can commit, push, pull and fetch in SourceTree. Those things are all I really care about. But I haven't found a good way to resolve merge conflicts in SourceTree yet.
@RobertHarvey Yeah--problem is that I'm pretty sure a lot of it is written as fairly specific rejoinders to/comments on papers others have written (and such) so many of them make little or no sense in isolation.
There are too many things in Git and I never know where to look for. Typing the intent and then sometimes reading a bit of an explanation is so much easier ._____.