« first day (701 days earlier)      last day (2143 days later) » 

12:08 AM
Hmmm, sorry to have bothered you, the segfault didn't come from exception handling, but it comes from my exception constructor lol, I've fixed it now and it's all ok xD
 
 
6 hours later…
6:16 AM
Guys, what assembly does clang -S generate? Is it a clang-specific kind of assembly? Can I compile it further with something other than clang/llvm specific?
 
 
1 hour later…
Sam
7:37 AM
Can someone tell me what the following error is please?
>= no conversion from double to double(_thiscall Subject::*)(void)
 
nwp
You forgot to call a function and are now comparing a function pointer to a double instead of the result of a function call.
 
maybe extra & somewhere
 
Sam
hmm. OK, this was from the changes to how I was instantiating objects yesterday then
There is also another error above that (both errors point to the same code)
Subject::getCurrent() non standard syntax; use & to create a pointer to member
I guess it's that
And the code in which it is pointed to is
if (subject->getCurrentHba1c >= subject->currTreatment->getMaximumHba1c())
 
nwp
Did you mean subject->getCurrentHba1c()?
 
Sam
Aw man
Sorry guys :( I've been up since 4
Thanks @nwp
 
nwp
7:51 AM
Both clang and gcc tell you directly that you probably forgot a ().
 
Sam
I don't get those error messages in my console
 
nwp
Then you are probably using Visual Studio. If you think those messages are worth it consider installing gcc.
 
IIRC Visual Studio had clang frontend
I'm not sure if error messages are nice too though
 
Sam
Do you guys not use VS?
 
most people here use some linux distro
so no
 
Sam
8:02 AM
I'm going to ask my boss if I can dual boot
 
it's not that I would use VS even if I would be on windows
 
Sam
Might ask for Ubuntu
 
I use CLion's student license, but the IDE cannot keep up with my template metaprogramming. I've heard good things about VS code though
 
Its complete shit because it has almost no static analysis tools, and a crime against nature because its written in javascript. You'd be better off using VIM+some plugins
 
Sam
wow wow
I used Vim once and couldn't close it
 
8:15 AM
Nothing to be proud of
 
nwp
@Sam If they say no consider just installing gcc on windows.
 
Sam
Yeh I'll see what they say
 
Sam
8:31 AM
"What countries get stuck in Vim" hahaha
Brilliant descriptive statistics
So if Russia ever go to war with Ukraine they can just stick them in a life sized Vim and forget about them.
 
8:42 AM
hi guys
 
@sparrow2 hi. Go on, there is no need for greetings
 
yeah, I was just wandering if anyone knows how can i get pintos file system code which is not in public domains, I'm so lost :(
 
pintos seems like a standard or description of a file system, but not an implementation
ah, I see. I was confused by the github repos that seem to try to implement it
@sparrow2 may be you should try more operating system related chat rooms? It seems like a search for software, not a programming related problem
 
yeah,but those rooms are empty,aren't they?
 
I've never been in those to be honest
 
8:51 AM
I just need someone who has taken the course and github repo is private
 
well then what you want to do looks fishy. If it is not, try to change the wording, because now it looks alerting
 
what do u mean?
 
getting code from private repo is usually done by author's consensus, or some direct statement that code is in the public domain
 
yeah I want someone to give me his/her code
don;t want to fail the class :)
 
nwp
Can't you just ask them?
 
8:56 AM
who
?
 
nwp
The people you want to give you their code.
 
yeah I'm looking for them
do u know anyone?
 
Sam
I have a function which takes another object as a parameter who has a probability member variable associated with them.. I want to make some tests to show that the function is working properly according to the probability associated with the input.. Is it normal to write a unit test which actually consists of many function calls and observing some output?
The more tests I run, the more the probability rate and actual outcome will converge
 
@Sam if they're intended to be called together or called many times, may be you could write a decorator function which would make it easier to use them? Is there any common case? I believe that interface would get better from that
 
Sam
So currently, the function is called within a for loop which iterates x many times for a given "Person"
 
9:01 AM
@Sam can you show some example code? It looks like it has some chance to be replaced by standard algorithm
 
Sam
Yeah sure two secs
I just generate that random number and check that the current Subjects associated probability is not greater or equal to it. The result then get's handled elsewhere
I guess the best way to test is to say create a subject with a probability of 0.2, run the function x many times. The greater x, the closer to 0.2 we should get.
 
it seems like unit testing this is quite legit. Though I would pass by reference if nullptr is not valid argument
 
Sam
Awesome. And it is possible to call the function many times and store each output in the tests?
 
if you want each output, then you could conjure some combination of std::generate, std::transform
 
Sam
CppUnit::RepeatTest() looks promising
 
9:09 AM
is repeating part of the test, or repetition of the tests is required? If the former, then everything should be inside the test, if the latter, use the RepeatTest()
let me put it another way: if one iteration passes, does it mean that the whole function works correctly?
 
Sam
I think it's the latter
I need to demonstrate that the more times the function is called, the closer to the Subject probability will output
 
does the results from repeated calls abide some distribution rules? If yes, may be you could test the distribution instead
 
Sam
hmmm, yeh I suppose. I mean, I want to show the distribution as x increases so yeah
As x increases the closer to the distribution of true / false returns we get
For now, I think just the raw returns should suffice
As long as I can split them out (20% true, 80% false given 1000 repeats) I think that will do
17% true 83% false given 500 repeats etc etc
 
so you want to test your distribution function to ensure you are actually statistically close to what you want
 
Sam
Yup
 
9:17 AM
honestly I think that is better served by doing an offline test of your distribution function so you know it's proper
and then a test with a seeded deterministic RNG that ensures the output hasn't changed
 
Sam
What's an offline test? DX
 
basically you take the time to manually verify the distribution function
 
Sam
My alternative was to write the result to a file and just run the simulation different number of times
 
I belive it is saving all of the results then simulating the whole thing and see if the simulation matches the ones you got
 
Sam
Load the data into R and plot it
 
9:18 AM
or do that extensive test only once
 
Sam
Yeh I could just save it into a file and test from that
 
Sam
9:35 AM
Ahh having a hard time trying to make a global ofstream
Can I use an ofstream as function parameter?
I guess I could pass a reference actually
 
@Sam IIRC you can even std::move it
@milleniumbug, you saved me. I thought I'll be the only one with portrait avatar here amongst texture avatars forever
@Sam, I double checked, and it is indeed possible to move it
 
Sam
Yup you are right :)
 
9:53 AM
here it is working, i can capture private members of the struct in lambda.
its is in principle the same as this: coliru.stacked-crooked.com/a/6870c2b94d0d0b08
 
Sam
10:37 AM
I've just noticed an issue when I try to dynamically create instances of my class and add them to a vector.. example code here: coliru.stacked-crooked.com/a/f56c5ebf1b728076. It seems as though I'm just getting all instances equalling the last added instance. Is this because I'm using a reference of the same object?
 
because the objects die when the next iteration begins
you want std::vector<myClass> objectStore; and store the instance directly
or use a std::vector<std::unique_ptr<myClass>> and objectStore.push_back(std::make_unique<myClass>(someConstructorParametersWhichMa‌​keUseOfCurrentI[i], ...));
 
Sam
Ahh. Would this problem have occurred when I switched from that Java-like instantiation?
 
yeah, it's pretty important to keep in mind where the object lives when taking an address
 
Sam
With you, thanks
 
11:01 AM
is it possible to use std::enable_if when I have a condition like A or B?
 
nwp
@FerencRozsa Well, figure out what is different. Try to transform your code step by step to the example code until the error disappears so you understand where the error comes from.
 
can you show me an example where the enable_if is true if the argument is one between two types?
 
nwp
@user8469759 Wait, you probably don't want std::conditional. You can just do A || B inside enable_if and it should work fine.
 
are you sure?
(lemme try)
what I want to do
 
nwp
std::enable_if_t<std::is_same_v<A, T> || std::is_same_v<B, T>> might be what you are looking for.
 
11:11 AM
is to replace this:
template<typename Float>
struct Point3D<Float, typename std::enable_if<std::is_floating_point<Float>::value>::type> {
	Float x, y, z;
	Float val;
};
with something between Float32 and Float8
changed with this:
template<typename Float>
struct Point3D<Float,
		typename std::enable_if<
				std::is_floating_point<Float>::value
						|| std::is_same<Float8, Float>>::type> {
	Float x, y, z;
	Float val;
};
doesn't compile
tried also this:
template<class Float, bool B = false>
class Point3D {}; // primary template

template<class Float>
struct Point3D<Float, std::is_same<Float,Float32>::value || std::is_same<Float,Float8>::value> {
	Float x, y, z;
	Float val;
};
nothing
 
nwp
@user8469759 What is the error message?
Also I think you have to write struct Point3D<Float, class = typename ...>.
 
11:35 AM
@nwp what do you mean?
 
nwp
@user8469759 The syntax wants you to write something like template <class T> or template <int i>. You can't just write template <std::enable_if>.
You can do template <class T = enable_if...> and leave out the name T, but I think you can't leave out the class = part.
 
12:06 PM
@nwp yes. For SFINAE purposes there should be template argument deduction failure, not the specialization failure
can anybody recommend a good Directx 11 book? I was thinking about Frank Luna's, but there was API change right after he released it ...
 
 
1 hour later…
1:14 PM
how does find_if(iterator, iterator, predicate) know on which variable to search since you only pass the begin and end of the object
 
you can do operator++ on the begin until it equals end
 
yeah but say we've got a stringstd::string t = "Test". You pass in find_if(t.begin(), t.end(), predicate)
Isn't t.begin the first character and t.end the last
 
for(;begin!=end; ++begin)
    if(predicate(*begin))
        return begin;
return end;
 
how does it know the other characters
 
t.end is one past the end
and they are actually pointers (or objects imitating pointers)
 
1:20 PM
oh makes sense now
oh and by the way, does the predicate function have to return OutputIterator?
 
predicate returns a bool (or something convertible to a bool)
 
can I use a template with using template<typename T> using _t = std::vector<T>::iterator ?
 
nwp
template<typename T> using using _t = std::vector<T>::iterator;
 
 template<typename T> using   _t = typename std::vector<T>::iterator;
 
nwp
Oops.
 
2:09 PM
why do I have to put a template above iterate_vector as well if I already declared them at the top
 
nwp
Because functions work with types in parameters and V_Iterator is not a type.
 
2:24 PM
hmm. Not necessarily looking for an answer here, maybe just some discussion; but I ran into a bewildering race condition on the filesystem I believe
On the same context as yesterday, I spun up tons of threads to try and bulk copy things on the filesystem using boost::filesystem::copy_file(...)
I believe I ran into a Errno 2: No such file or directory error by catching and rethrowing this line
As per specs, copy_file(from, to, [extra]) copies the file in "from" to the destination "to", and copying single-threaded from has never given me an issue
so I'm inclined to say that the No such file or directory issue is not a coincidence as I could reproduce it many many times on multithreaded environment but not on single threaded. But boost would be stupid to tell me no such file on the destination side(because after all we're trying to write to it right...?)
so where could this error be propagating from?
 
nwp
@OneRaynyDay Sounds like you want to use a debugger.
 
@nwp gdb into the coredump was not very useful. Not enough symbols cause I didn't compile boost with debug flags
 
nwp
That said files behave super weird on linux. You can seek beyond the end and write there, leaving a hole in the file and having multiple processes write to the same file at the same time with weird effects.
@OneRaynyDay Run it under a debugger. Also use sanitizers.
 
@nwp don't sanitizers address memory-based issues?
But yeah, I will give that a try
 
nwp
There are a bunch of them. Some deal with threads and race-conditions, but they are not exactly easy to use.
 
2:38 PM
ah. Clang though
 
nwp
I don't know if the other ones work with gcc too. Probably worth a try.
Also apt-get install clang-6.0 isn't that painful.
 
can't willy nilly install clang here
I can't yum install anything for that matter
 
nwp
It's a development tool for a developer. It shouldn't be that difficult.
That said I don't think those sanitizers will help you with the Errno 2 issue.
 
I thought so too
I think instead of trying to figure out what the hell this FS is trying to do/boost is trying to do to the FS, I should just put a lock somewhere
but putting a single lock on all file I/O == basically single threaded
 
nwp
You could also log when you open and close files and then look for overlap.
 
2:45 PM
that would probably require an LD_PRELOAD, boost might be doing something extra
 
nwp
Maybe also when you create or delete files.
 
for sure. I'm looking into file locking and it seems like perhaps it is hard to do with boost as the high level API
 
jrh
I think I'm kind of getting the feel for winapi's GDI rendering setup but just to make sure -- it seems like GDI can choose to render a frame after any drawing call (BitBlt, etc) with whatever shapes the DC has.
... if I write code to redraw the whole window with two distinct images, and invalidate the window on resize, then record my screen while resizing, I can see it occasionally showing the first image, and occasionally showing the second image; is is my theory right? I can't find an official source that confirms it.
 
nwp
Have you considered not letting GDI ruin your life?
 
jrh
I'm too much of a retro nerd for that
 
nwp
2:59 PM
rip
 
jrh
If I'm right I'm guessing the reasoning was something like "back in the 1980s it took too long to draw the whole screen so we figured at least we'd get some of your shapes out sooner / on some periodic timer, better than waiting for EndPaint"; from working with game rendering that definitely wasn't what I expected, interesting though
 
I think it's more that a full screen clear was expensive as was a double buffer
 
nwp
@jrh I don't think that's the case. You can add a sleep before EndPaint to check.
 
jrh
@nwp great idea
that actually confirmed my theory
if I put a sleep between BltBlts I see one image for 2 seconds, then another image for 2 seconds
 
3:14 PM
@nwp Ah neat. That's really cool
 
jrh
what was the trick again for pasting code in here (so it expands properly)? I can put my WM_PAINT handler here if anyone's interested
 
nwp
If it is small you paste it and then press CTRL+K. If it is not small put it on pastebin or some other site.
No mixing of code blocks and text though.
 
jrh
case WM_PAINT:
{
    PAINTSTRUCT ps;

    HDC winGraphics = BeginPaint(hwnd, &ps);

    int imgIndex;

    for (imgIndex = 0; imgIndex < NUMBER_OF_IMAGES; imgIndex++)
    {
        HBITMAP imageToDraw = _images[imgIndex];

        HDC bitmapDC = CreateCompatibleDC(winGraphics);
        SelectObject(bitmapDC, imageToDraw);

        BITMAP image;
        GetObject(imageToDraw, sizeof(BITMAP), &image);

        BitBlt(winGraphics, 0, 0, image.bmWidth, image.bmHeight, bitmapDC, 0, 0, SRCCOPY);

        DeleteDC(bitmapDC);
(Where _images is just an array of HBITMAP that I allocated in WM_CREATE)
 
nwp
Ah, WinAPI code. How I have not missed you at all :P
@jrh I forgot what it is called, but microsoft has a free tool that monitors what GDI-calls you make and tells you when you make an incorrect call beyond what error codes already give you.
 
jrh
I looked at Wine's source and ReactOS's source, it looks like they just set a buffer pixel by pixel, though it's not clear where or when exactly that buffer gets copied to the video buffer; then again when it comes to GPUs and video memory I am definitely not an expert.
 
3:22 PM
it's very likely that there is some other component that hijacks the thread for a bit and reads the buffer
 
Oh man; the more I dig deeper into my own issues, the more I understand rsync's architectural decisions
and the more I realize what kind of a rabbit hole I got myself into
slams head repeatedly on desk
 
nwp
Or, you know, just tell rsync to do the work.
 
well, rsync does the work in a "wrong" way to protect us all from having to do what I'm doing right now
to be fair, rsync was probably functionally broken since the release of symlinks in 1990's
but people just never noticed that it was broken or they just didn't care enough
 
or noone was stupid enough to rsync a folder with symlinks in them
 
3:45 PM
@OneRaynyDay what's broken about what rsync does with symlinks?
I... uh... my friend wrote a backup script that uses rsync and he wonders whether it's broken
 
3:59 PM
@trentcl symlinks are copied as their referent
unless you specify to keep links
then you have a chance to not include the referent
which means you'll either 1. end up w/ not a symlnk on the destination, or 2. end up with a dangling symlink
Unless you're lucky and you captured the symlink referent by accident and it ends up on the destination
 
@OneRaynyDay ah, I see what you mean
 
and I guess you want to be able to retarget the symlink at the destination?
 
I only have a couple symlinks in my home directory and I'm capturing all the targets. But I'm not sure if I'm keeping the links or not
I'll have to check the script when I get home.
 
4:12 PM
You need to do a traversal over symlinks that are not included in your initial list which is a huge PITA
and also, I've been trying to write my own rsync that correctly follows symlinks and generates exactly from A to B
and I attempted to make it multithreaded, which led to a myriad of bewildering file I/O errors and thats when I realized:
rsync copying over symlinks as their referent is a good idea because then, with the assumption of single source, single destination, rsync will never lead to data races
trying to parallelize rsync done The Right Way becomes much harder because you start with not even a DAG, just a graph with no structure
meanwhile you try to do it The Rsync Way, you can easily assume a tree structure which is just embarrassingly parallel
Hence rsync's decisions are well motivated and trade correctness for performance which is not what everyone wans
unfotunately I am rsync'ing a giant workload of ~ 1TB on NFS and so a single thread will take days. I'm unsure what steps to take next.
 
@OneRaynyDay I'm not even sure what you mean by "correctness". What, in your estimation, is the correct way to copy a symlink?
 
@trentcl if a user says "sync my file /a/b/c/sym"
they probably mean the directory that sym points to
they don't mean "hey just copy this 1 symlink please"
so once you meet a symlink you should follow it
meanwhile, you can easily reproduce an "infinite loop" rsync:
```
/a/sym -> /b
/b/sym -> /a
```
rsync -azvR on a
you will get a resulting destination folder that looks like: /a/b/a/b/a/b/a/b/a/b/a/b/a/b/a/b/a/b/... 17 levels down until rsync chokes and says "oh god please no more torture"
 
@OneRaynyDay copying the symlink seems dubious... but following it seems even less "correct" to me
> By default, symbolic links are not transferred at all.
well that's just silly.
 
nwp
4:28 PM
If the symlink points to something that will be copied you could copy the symlink and adjust the target to the copy.
If it points at something outside the target you should probably leave the target alone or print a warning or something.
It seems like no matter what you do the behavior will be unintuitive.
So the best you can do is make other people deal with it and provide 2 switches for on-target symlinks and off-target symlinks and let them choose between copy, adjust and ignore.
Bonus: If they chose ignore you can just use default rsync.
Also the problem became significantly easier because you don't need to copy data anymore. All you need to do is restore symlinks.
Minus the combination off-target + adjust.
 
5:14 PM
sorry just came back.
@nwp that is what rsync doesn't do, and my program oes do
@nwp Regarding this point, I do raise warnings. I also tell the user to pass in a flag that says "It's okay, just run anyways" if they don't want it to raise system_error.
I agree in the end is no correct way to do this. But for my specific case, I need it done in this specific way.
 
5:34 PM
Hello there again! I am back with another beginner question:

Is there some special syntax needed when I try to overload the "<<" operator for std::fstream?

This is what I did in my class "MotorCycle":

friend std::fstream &operator<< (std::fstream &output, MotorCycle &M) {
output << "Model: " << M.model
<< "\nCurrently in shop: " << (M.isInShop ? "yes" : "no") << endl;

}

But when I try to use it ...

std::fstream f;
f.open("sample.txt", std::fstream::out);
for (auto const& i : cycleList) {
f << "------------------------------ " << (++count) << endl;
 
1 message moved from Lounge<C++>
 
nwp
@CrazyQwert The error message tells you "no operator "<<" matches these operands -- operand types are: std::__1::fstream << const MotorCycle". Look at the operator you think it should be calling and see if the types match.
 
const correctness 101: make your references const if you don't modify the object
 
@milleniumbug sorry ... just read at this moment that there is a dedicated chatroom for that in "TheRules". I hope I did not annoy anyone :/
@milleniumbug that did the trick. But I though [datatype] == const [datatype] and const only means that you cant alter the value?
 
5:51 PM
@CrazyQwert Also, write the operator<< in terms of std::ostream rather than the specific std::fstream: friend std::ostream& operator<<(std::ostream& output, MotorCycle const& M) { ... }
@CrazyQwert Yes-ish. Note that i, the loop variable, is const. You declared it as auto const&. Thus, you cannot change i. However, the operator<< you defined says, "I might change the MotorCycle you pass to me". Thus, it's not allowed to pass i to that operator<<, as that would be (potentially) modifying it.
 
@Justin hi, I also already have an overloaded operator for ostream (that is identical). I tried using it for writing in the document, but that die not work, so I overloaded it specifically for fstream. Is there another way I should rather have done it utilising the overloaded ostream operator?
 
@CrazyQwert Yes. Which is why void f(int& x) { x = 42; } ... const int a = 42; f(a); won't compile
This is basic type checking
int& can't refer to a const int
 
@Justin Ah, I understand. That makes sense. Thanks for clarifying
 
@CrazyQwert I can't reproduce what you said. What do you mean by "that die (sic) not work"? Can you show an example that reproduces it not working?
 
please stand by
https://pastebin.com/nRsgWbhU

Compiler Error:
no operator "<<" matches these operands -- operand types are: std::__1::fstream << const MotorCycle
With this being the only overloaded operator within motor-cycle:

friend std::ostream &operator<< (std::ostream &output, MotorCycle &M) {
output << "Model: " << M.model
<< "\nCurrently in shop: " << (M.isInShop ? "yes" : "no") << endl;
return output;
}
 
6:06 PM
friend std::ostream &operator<< (std::ostream &output, MotorCycle &M) {
Remember what we were just talking about?
 
well, yes. this is literally the same problem
 
ah lol
yeah, that is the moment where I facepalm and hide in shame
 
Don't worry. We all have these moments
 
Anyway, thank you so much for your help! :D
 
I know you can explicitly disable calling a copy ctor for example, by doing foo(..) = delete
however, can you do this for arbitrary functions?
I'm writing a wrapper above boost, and I want my users to specifically call my functions, i.e.` mynamespace::foo, and not boost filesystem's: boost::filesystem::foo()`.
 
6:19 PM
Is there a reason why everyone makes a char pointer instead of a normal char
 
can I just do something like boost::filesystem::foo() = delete?
It's just a compiler error saying "Hey, I deleted this function, you're doing something obviously wrong if you're compiling w/ my wrapper"
 
@OneRaynyDay No. You don't own the boost-filesystem library. You can't delete functions that already exist.
You can delete arbitrary functions, though.
 
then is there other methods to induce a compile time error from calling those functions?
 
@VioAriton Because they're bad because they don't use std::string
 
you can hide that it's using boost by putting boost in a mynamspace::detail namespace
 
6:26 PM
sure, that's what I was doing, except I accidentally ran into my own issues while developing the wrapper itself by ambiguating between mynamespace and mynamespace::detail :P
 
nwp
@VioAriton They use char * as a "null-terminated C string", not as a "pointer to char".
 
and null terminated string is a historic artifact that we are stuck with
 
6:51 PM
hi guys
any suggestion how can I debug an error like :
corrupted size vs. prev_size: 0x0000000002bb3610
in opencl
I have an empty kernel, and basically there's an issue I can't figure out relate to the arguments I pass
kernel is like this
__kernel void marchingCubesKernel(
	__global float * gpu_voxel_grid_TSDF,
	__global clCubeCaseEntry * gpu_LUT,
	float voxelSize,
	int voxelGridDimX) {


}
if I remove one it goes fine
for some reason
 

« first day (701 days earlier)      last day (2143 days later) »