|
If I understood you correctly, you should just const_cast away the constness internally to support both const and nonconst interface. This is one of the few cases where it is completely sane and expected to use const_cast.
|
# ¿ Jun 30, 2015 12:07 |
|
|
# ¿ May 21, 2024 01:55 |
|
I am not entirely sure this falls under scope of this thread, but this seems like the best place to ask anyway. I have a chance to significantly alter the C/C++ course taught at my university. Its current state is the usual C89+C++98 basics that needlessly repeat things from prerequisite courses and then end before saying anything useful about templates. Obviously I would prefer to burn things to the ground and start anew, but that is not an option (yet ) so I am going to try and get C dropped, because there isn't enough time to do modern C AND C++ (hell, there isn't enough time to do C++ properly, but that is another story and another fight) and everything currently in the course is covered by direct prerequisite. I am also going to push to update C++ part to C++11 with C++14 elements (basically taking the current MSVC as the least common denominator). So now I am looking for ideas (You HAVE to teach r-value references), opinions (You are dumb for dropping C) and examples of high quality C++ courses (Stroustrup's PPP using C++ seems pretty good) to use as references for the changes.
|
# ¿ Jul 28, 2015 13:11 |
|
nielsm posted:Is that course a general "introduction to programming" course, or is it intended for students who already know other languages to learn C and/or C++? No, the "introduction to programming" is the (two semester) prerequisite. However the current state feels a lot like it is.
|
# ¿ Jul 28, 2015 13:17 |
|
Blotto Skorzany posted:What is the title of that C-and-C++ course, and what is its ultimate purpose? The title is "Programming in C/C++" and the purpose is to teach someone who supposedly has at least basic understanding of programming in some other language some C++. Ideally it would give large degree of competency, but without getting more time, the target is usable competency. The closest to proper requirement on the course is that the computer vision guys would really like course that teaches their students to take Matlab prototype and make something roughly demoable. Its not a formal prerequisite for any other course, and it isn't informal prerequisite for any courses either. Some courses want their student to understand C, but there is already a course to help catch up with C in low level environment. The only course to take an informal dependency in the near future is going to be advanced C++ and that is only if someone pushes is through. (It is currently blocked by academic elitism and politics)
|
# ¿ Jul 29, 2015 11:55 |
|
Plorkyeran posted:There's a few people pushing to take advantage of the backwards-compatiblity break when the standard library is Conceptified to clean up all the old cruft and bad decisions, but I suspect that'll get bogged down in endless committees. My money is on minor cleanups being done and then a fuckton of bikeshedding blocking anything interesting.
|
# ¿ Jul 30, 2015 10:14 |
|
Can someone explain that to someone lucky enough to get started with git as source control? Ekster: I think you would learn more by thinking up data structure implementation from high/mid level description, rather than from reverse engineering some horrific C library.
|
# ¿ Sep 4, 2015 17:28 |
|
hackbunny posted:Because tag-based dispatch is awful Anyway, with the concepts coming, STL might be able to take a compatibility break and fix some things being wrong. Core language is not so lucky, it did take until C++17 to get rid of freaking trigraphs. So lets hope for the best?
|
# ¿ Sep 24, 2015 08:10 |
|
Two CcpCon 2015 videos are already up at their youtube channel. They are about Stroustrup's and Sutter's modern coding style guidelines, and sound pretty interesting. (Sutter's much more so)
|
# ¿ Sep 25, 2015 06:41 |
|
xgalaxy posted:I don't quite follow Sutter's argument that Rust requires annotations just after showing C++ code that requires annotations. Anyway, pretty neat to see this stuff actually working and it sounds like it will be in an update in Visual Studio before the end of the year. I think his argument was that annotations should be exception, not norm.
|
# ¿ Sep 26, 2015 18:32 |
|
Well, it doesn't seem to be worth its own thread
|
# ¿ Oct 5, 2015 19:19 |
|
First of all, if you have access to C++11 I heartily recommend using std::function instead. Anyway, my guess would be that since your Task<T> has naive copy constructor and assignment, you tried returning it and it outlived the original object.
|
# ¿ Oct 14, 2015 06:39 |
|
What is a nice and sane C++ concurrency library? This means higher level than <thread>, <mutex> et al. and less macroy than OpenMP pragmas. Bonus points if it runs on Windows as well as on Linux.
|
# ¿ Nov 9, 2015 16:19 |
|
Subjunctive posted:Maybe check out Intel TBB? It's not to everyone's tastes, but I recall being generally happy with it. TBB is what I definitely plan on checking out, but I was looking for alternatives. Ralith posted:What exactly do you want it to do for you? Give a reasonably simple task oriented interface... IE being able to chain tasks, not having to explicitly manage threads for simple async stuff.
|
# ¿ Nov 10, 2015 20:37 |
|
Is there any (preferably sane) way to have Windows and Linux computers work together using OpenMPI? I am using MSMPI on Windows.
|
# ¿ Nov 12, 2015 16:02 |
|
code:
|
# ¿ Nov 23, 2015 22:46 |
|
Illusive gently caress Man posted:No, it's pretty simple to write an algorithm linear in the sizes of the sets (use iterators), but it sounds like the kind of thing the standard library would have, and possibly be better than what I write. Yeah, linear time is easy and it is up to you to implement it. I would also expect it to be faster than having one of the set be unordered and do lookups in it.
|
# ¿ Jan 20, 2016 18:14 |
|
What do I need to find out and replicate in a VM, to be able to precompile .o files in a VM that will link properly when used on the real machine? I already know that it is running Debian Jessie, is using g++ 4.9.2 and should be able to find out anything else I will need to.
|
# ¿ Mar 26, 2016 16:57 |
|
pseudorandom name posted:Why aren't you doing the final link in the VM? Because the whole thing is crazy ... Basically, my university has a system for uploading of student's semestral work/homeworks, etc. Bolted on top of it is a system for automatic grading -- i.e. for programming classes you upload your implementation of $homework and it then gives you a grade (points for the final grade). So, this semester I decided to go and help modernize and teach our C++ course and one of the things we decided to do is to have a lot of smallish homeworks that are automatically graded. To be nice to the students, we are using Catch for behavior tests (and we also do some more behind-the-scenes validation for correctness, i.e. use Valgrind) and give them the tests, so they can have a quicker feedback cycle than uploading it through the web interface, waiting for results and so on. However, Catch's main takes quite a long time to compile (g++ on my notebook takes 8.5s, on the server it needs 10+) and to keep the time it takes to validate student's submission short, we want to precompile it (and precompile everything else we can, while we are at it). The fun part is, I am not allowed SSH access to the grading server (because of technical debt and lots of bureaucracy, long story), but we already got this much working -- we just had to bother someone who is allowed access to copy over a file and compile it into .o file once a week. This worked until last week, when we asked for a C++14 compiler and were told to set the grading system to use different server (the automatic evaluation system has a master server, which takes care of accepting submissions, copying it to a shared folder and farming out the actual work to different slave servers), which has different software configuration. As we weren't able to get someone with access to this server to help us with precompiling stuff, we decided to create a VM that would allows us to create compatible .o files and then copy them to the server we have access to, because the course's folder is automagically shared with the server doing the actual evaluating. ---edit--- And no, I cannot change the evaluation script to copy back the .o files, because the moment evaluation starts, the shared folder is read-only. Xarn fucked around with this message at 20:14 on Mar 26, 2016 |
# ¿ Mar 26, 2016 20:08 |
|
Volguus posted:No, that's not crazy, that's loving insane. And thats even without the dumb bugs I found in the ~4 weeks I am working with the system. Well at least next semester the big "rewrite" will be done. The rewrite will bolt on access control (using faculty hosted gitlab) for uploading evaluation scripts, the lovely backend will stay.
|
# ¿ Mar 27, 2016 09:10 |
|
My fight with the system for automatic evaluation continues. I have given up on creating a link-compatible VM, because the target has moved and some changes in the way our own script works makes it impractical right now (if there was an easy way to get the precompiled .o files, we would would make them work, but right now ). But I have new question: Is there a way to get Valgrind working with compressed debug data? Currently it spits out a whole ton of code:
|
# ¿ Apr 4, 2016 19:47 |
|
Cory Parsnipson posted:Does anyone have tips/best practices/reading for converting a project of non-trivial size from using raw pointers to using smart pointers? I want to see if I can introduce smart pointers module by module or something into an existing project that only uses raw pointers, but that seems like I could shoot myself in the foot that way. When we tried it, we started using smart pointer everywhere in new code and slowly changed the old code as we did refactoring. It mostly worked, although there was some initial pain as noone actually understood the old ownership model, so suddenly there were double free etc.
|
# ¿ May 20, 2016 10:45 |
|
Joda posted:I want to start developing commercial software, which means my educational license for CLion isn't really gonna cut it anymore. Before spending €99 a year on a commercial license, I thought I'd ask if there are any good, free alternatives that work on Windows, Linux and OSX? Preferably with CMake as the primary system for project management, and it has to work with MinGW, gcc and its standard library >=4.8. Cmake to generate makefiles/project files and VS for development. I am actually mostly serious, VS 2015 is p. nice, free for commercial use and you can always switch by having CMake generate different poo poo.
|
# ¿ Jun 22, 2016 17:52 |
|
Klades posted:YCM (and anything else relying on clang) will absolutely poo poo the bed if your codebase does anything weird enough, but hopefully if you're starting a new project with modern C++ it shouldn't come up. Does Clang also poo poo the bed during compilation? If yes, Clang problem, if not, I'd give it about 3/5 of being configuration problem versus being problem in the libclang. For a little bit of content, does anyone here work with clang-tidy regularly? I have a toy .cpp file: code:
code:
|
# ¿ Jun 22, 2016 21:29 |
|
b0lt posted:Are you using a sufficiently new version? code:
|
# ¿ Jun 23, 2016 17:01 |
|
C++17 is shaping up to be interesting even with modules and concepts removed.code:
|
# ¿ Jun 26, 2016 16:06 |
|
Cory Parsnipson posted:I want to make a Node class to build trees and have a template parameter "HasParentPointers" that will let me enable parent pointers or not in the Node class. Is it possible, when HasParentPointers is false, to have the Node class not even contain a pointer member? Basically, I want to use templates to make a node class that either has a parent * member or not. Assuming that you want to have a tree of either nodes with parent pointers, or nodes without parent pointers, not mix and match, it is definitely possible, but kinda painful in C++14 (and pre C++14 as well). You will end up writing the code twice, using template specialization. It should be p. easy in C++17, but thats not quite out or production ready yet.
|
# ¿ Jul 8, 2016 12:44 |
|
leper khan posted:I think you could do it with the policy based design template template parameters outlined in Alexandrescu's Modern C++. Is that what you're referring to, and if so what's coming in 17 (I haven't been keeping up)? I would just write the two specializations, as I see policies as useful for user customization without combinatoric explosion if you have more parameters, but there isn't much user customization to be done here. code:
C++17 adds code:
code:
|
# ¿ Jul 8, 2016 14:06 |
|
IIRC that should be fixed in C++17
|
# ¿ Aug 13, 2016 10:29 |
|
Harik posted:Someone doublecheck me on this one: When adding elements to a vector, it will have to reallocate the underlying storage sooner or later. What will happen with the memory it used to use at that point?
|
# ¿ Aug 16, 2016 20:06 |
|
Harik posted:
|
# ¿ Aug 17, 2016 07:03 |
|
Joda posted:Is it a new thing in g++ 6.0 that it won't accept std::string() as an argument to a function that expects std::string&? No, a non-const ref shouldn't bind to a temporary since forever, because that is almost certainly an error.
|
# ¿ Sep 16, 2016 07:34 |
|
Spatial posted:Also while I'm complaining about MSVC, lmao that their implementation of deque<T> allocates buckets smaller than a cache line and degrades to a linked list if T is bigger than 64 bits. IIRC, only libc++ has sane deque<T>, libstdc++ also has a predetermined bucket size and then just divides it to elements. There is some scary poo poo in old C++ stdlib implementations.
|
# ¿ Sep 16, 2016 11:52 |
|
Plorkyeran posted:Not being able to bind an lvalue reference to a temporary was a restriction added fairly late in the standardization process, and it's a rare example of C++ forbidding something because it's a footgun rather than because it can't work. Maybe even the only one? (I still think that the rule-of-3 should've been language level rule.)
|
# ¿ Sep 16, 2016 18:28 |
|
ufarn posted:I can't get C++ to work in ST3 on Win10 x64 with external class files (Class.h and Class.cpp) and my current build system. Is there a build-system solution to this or something else? Without any information about your build system, what kind of help do you expect? Also use Visual Studio.
|
# ¿ Sep 25, 2016 21:34 |
|
ufarn posted:I actually think IDEs make things a lot worse when it comes to picking up a new language. Maybe if it's the first time you try coding and want to move a turtle in different directions, but all the magic involved in creating external classes in C++ is one of the things that really put me off IDEs. I don't have a problem with using them for programming in general, I just don't see the point of programs where you struggle to even find the build button. Put up or shut up. Either go with "blah blah, IDEs are too magic" and don't try to use ST3's weird, bespoke JSON build tool, invoking cl.exe from cmd instead (its not actually that hard), or admit that you just want ST3, there is nothing wrong with that (well, except the build tool seems poo poo).
|
# ¿ Sep 26, 2016 21:25 |
|
nielsm posted:You only get MFC if you use the "MFC Application" wizard, or select the MFC box in the "Win32 Project" wizard settings for a DLL or static library type project. It only forces precompiled headers if you select Win32 project -> Windows application subtype, otherwise it just has it checked by default. (No idea why it still thinks that stdafx.h is neccessary for Windows application, and really should let you just uncheck it.)
|
# ¿ Sep 27, 2016 08:08 |
|
Plorkyeran posted:The upcoming version doesn't even install MFC by default anymore. Is the new installer any good? I just remembered I got an email while on vacation to test it.
|
# ¿ Sep 27, 2016 20:19 |
|
Shy posted:I don't know if that's better suited for the general programming thread but I've been meaning to ask about C++ standard/compiler progress over the last 15-20 years. If I understand it correctly C++11 and newer is mostly supported across all modern compilers and performs well, but let's say 15 years ago would a team choosing it over C for a large project encounter many additional difficulties compared to now? Depends a lot on how much back do you want to go. It is also important to realize that compilers and code tends to push each other... as compilers get better at aggressively inlining code created by nested templates, people get better at creating nested templates for crazy compile time magic.
|
# ¿ Oct 6, 2016 19:03 |
|
GeneralZod posted:
On one hand, I still think that part of the spec was actually genius, because of what it meant for splicing. On the other, I've seen way too many people try to do code:
code:
|
# ¿ Oct 10, 2016 17:17 |
|
|
# ¿ May 21, 2024 01:55 |
|
If you really want to go full performance mode, align your data highly and vectorize that poo poo. (Actual results not guaranteed, some poo poo might not be vectorizable or requires major rethinking of your data layout)
|
# ¿ Oct 13, 2016 21:09 |