« first day (460 days earlier)      last day (2617 days later) » 

05:55
Anyone familiar with Boost Spirit (especially X3)? I want a language with operator precedence (stuff like x - 1 + 3 * y should be equivalent to ((x - 1) + (3 * y))). I can't seem to figure out how to do the operator precedence. I could try hacking it into the grammar to look something like this, but that seems like a really bad idea:
mulprecedence = '*' | '/';
mul = expr >> mulprecedence >> expr;

addprecedence = '+' | '-';
add = expr >> addprecedence >> expr;

unit = identifier | literal;
// Won't work with the recursion
expr = add | mul | unit;
I was originally parsing x - 1 + 3 * y into a single Arithmetic expression, with the intent to use Shunting Yard afterwards to obtain precedence information, but I feel like operator precedence is frequent enough that there should be a better way
06:14
I guess I'm picturing something like shunting_yard('*', '/')('+', '-')
I guess I could write a parser that works a lot like what I just suggested above
An x3-compatible parser, that is. Rather than building it from x3's built-in parsers
 
3 hours later…
Ron
Ron
09:41
In this answer, what is this int (&arra)[N] expression called?
Eer, I think I found it. Scratch that.
"template argument deduction"
Ron
Ron
09:57
Is this the reliable way of deducing raw array size during compile time?
@Ron int (&arra)[N] is a reference to a N-element array of int. The N gets deduced, and can be used there
std::begin and std::end use it, and them being marked constexpr make it the preferred way to get the size of a C-array
sup? Will std::string invalidate iterators upon resize to smaller one?
Ron
Ron
@milleniumbug I see. I was euphoric when I saw it, but now I see it applies to only C style arrays, right?
Can it be used on dynamically allocated arrays?
Apparently not. My bad.
@milleniumbug Thanks.
finding a size of a dynamically allocated array at compile time would require time travel :)
Ron
Ron
@milleniumbug Haha, right, I am in need of that second cup of coffee.
10:37
@EuriPinhollow given that there's no wording wrt invalidation in std::string::resize and this little remark, I'm going to assume that string can invalidate iterators pretty much on a whim, including when resizing to a smaller size
@milleniumbug so vectors are superior from that point of view right?
this may seem strange, but given a SSO-optimized string impl, invalidation on resizing to a smaller size could easily happen if the string determines whether it uses its own storage or whether it's pointing to a dynamically allocated memory by looking at .size()
@EuriPinhollow yes, vectors have more invalidation guarantees, but they don't do SSO
I want a 1 GB string which would not breath upon any touch, I do not care about SSO and I do need string methods (inb4 string_view).
Funny.
std::string is optimized for general usage, and lots of programs have lots of tiny strings and an occasional string larger than that
so, sure, for a special case you may want to pick something different
@EuriPinhollow string_view is indeed something you may want here, but IMO just avoid string methods and use the operations in <algorithm>
11:00
i have a question, im using ceil() to round up fractional numbers, but ceil isnt working in my code, this is the code i run:
std::cout << ceil(132/512)*512;
it outputs 0, shouldnt it output 1?
Oh and BTW is it safe string::replace string with larger one?
safe as in what
@jeyejow it outputs 0 because you are dividing integer numbers and getting integer (equaling 0) which is then converted to float.
It probably will invalidate iterators
Talking only about sizes now.
11:08
It's "safe" as in you won't get a buffer overflow
@EuriPinhollow so i need to do std::cout << ceil(132.0/512.0)*512; for it to work?
@jeyejow you should use dot in literal to get double number: std::cout << ceil(132./512)*512;
Yes.
ohhh okay, thanks!
11:43
std::vector<int> a;
std::vector<int>::iterator aIt;
How do I do the same without writing std::vector<int>:: in the second row?
inb4 auto
auto
or, decltype(a)::iterator
or
typedef std::vector<int> a_type;
a_type a;
a_type::iterator aIt;
note that decltype(a)::iterator doesn't work if a is actually a reference type
12:11
Thx.
nwp
nwp
12:27
@EuriPinhollow You should never need to declare an iterator like that. You should always be able to delay the declaration until you can assign a proper value in which case you can use auto.
@nwp because there are no classes in which auto cannot be used right?
nwp
nwp
@EuriPinhollow I don't know what you mean here.
nwp
nwp
It's just an observation that whenever people write code like std::vector<int>::iterator aIt; it can be trivially refactored into not writing that line.
And there are no vector_views btw.
nwp
nwp
12:37
@EuriPinhollow That code in itself doesn't do anything. If you make it do something then there is a good chance you will not need auto it=V.begin(); anymore.
wat
I mean, there is not a single necessary thing in programming at all which cannot be replaced with a combination of bool functions, what's the point? I want an iterator to be the member of class.
nwp
nwp
12:55
My point was that it appears to be an anti-pattern. That's based on me not seeing a single instance where the declaration of an iterator was a good thing to do. There is a chance I just missed those instances.
Hi guys
I need help with this question,plz
Is the following property equivalent to saying that object x is
wait-free?
For every infinite history H of x, every thread that takes an infinite number of
steps in H completes an infinite number of method calls.
That does not seem to be related to C++.
nwp
nwp
It's also a repost.
Guess the answer was not satisfying.
13:11
it's not directly related to c++
any ideas,still?
13:24
@sparrow2 Assuming that my ignorance is not critical and using first definition of "wait free" I found on SO (from Maurice Herlihy paper "Wait-free synchronization") I can claim that those are not equal because it roughly reduces to telling if infinite series having infinite sum are guaranteed to have finite terms (they are not).
I.e. if you are executing infinite series of code pieces and you know that the total length of history is infinite you cannot tell anything about finiteness of history of each code piece.
 
3 hours later…
16:30
Hello all
Should I provide an answer to my question once I have used a comment to research and find a solution?
if you found an answer to your question, you can provide an answer
Ok then, thank you.
I have a std::thread question please
If a thread in one class enters a method in another class, once the thread exits the method, am I not able to join that thread anymore?
Attempts to join throw About() so I assume once the thread has exited the method, std::thread.terminate() has already been called
that's most non-precise wording I ever saw :/
threads run code
classes define the member functions and member data
whatever you pass to std::thread's constructor gets run, on a separate thread
you can call .join() on a std::thread's instance
whether you define a std::thread as a data member is mostly irrelevant to how threads work
> If *this has an associated thread (joinable() == true), std::terminate() is called.
17:05
@milleniumbug My apologies. I'm new to C++ and still learning. In the thread classes, once the shared data class functions were ran, I tried to call std::thread.join() only to receive Abort() per running thread using Microsoft Visual Studio 2015
scratch that, provide a SSCCE instead
If you go to stackoverflow.com/questions/46720462/… I asked a question about why my producer/consumer wasn't working. In the Producer/Consumer run functions, once the thread called and finished their respective methods, I attempted to call join which results in Abort(). I checked stack on this issue and the answer to the question was likely that the threads already called terminate()
17:27
first of all, make your code compile
then, make your code compile without warnings
The code I have on my machine compiles without warnings. I have posted the complete classes and an answer that contains updates
and that code doesn't compile
Strange, does for me
The answer I provided contains the runtime output as well
I am using Visual Studio 2015
I'm certain that even on MSVS2015, you can't assign the result of a function returning void to an int variable
Aside form that, just looking at the code, can you determine why join() throws Abort()?
17:32
actually scratch that, it's your problem, it's in your interest to make it easy for me to run it and diagnose the issue
I suggest you just fix that and move on or I can take the actual code I have on my machine and mail it to you ... even the whole solution if you like
What I can do for you milleniumbug that gets you the complete solution which compiles?
I'd like your assistance
Do you want me to update the question?
get the code you currently have and compiles, and post it on pastebin, github, gist, ideone, or whatever code sharing service there is
17:48
I just updated all the code to what is on my machine
at the Stack question I linked to you
I will post the solution as well to one of the code sharing sites you mentioned as well
no, don't do that. if you have edited the question with the updated code, the code in the answer doesn't demonstrate the problem in the question
because it also includes the solution added in the answer
and now people reading the questions and its answers will get confused
actually dunno, the original question also has issues so there
Reading the code, can you ascertain why I can't call join() in the thread classes once the thread methods complete?
I believe I found a reason why on a stack question
Searching on thread join Abort() is giving me a clue
18:06
not directly related:
don't use new
also don't declare useless destructors like that
18:42
I have forgot I have click which button,
Then I have a such flag in my left window in vs2015
How to cancel it?
what happens when you right click it?
Nothing happen..
That mean nobody meet this problem?
probably a bookmark
go to edit -> bookmarks
Thanks a lot..@milleniumbug
19:04
Is the following property equivalent to saying that object x is
wait-free?
For every infinite history H of x, every thread that takes an infinite number of
steps in H completes an infinite number of method calls.
trying to find someone for 2 days who can help bit ...
2 messages moved from Lounge<C++>
@sehe could you find error in my Djkistra question? :))
@sparrow2 way too vague without context, but it does remind me of statements about wait-free being "equivalent to a system where all states always allow some task to proceed". Maybe this gives you some google-entry points
@sparrow2 I remember looking at it and making it compile. I think I dropped a comment telling you about my findings/questions?
yeah,but it the codes does not work for that particula input
2 messages moved from Lounge<C++>
1 message moved from Lounge<C++>
@sparrow2 sigh. I'll do it again.
19:17
thanks :)
@sparrow2 I still don't get your question. What about this comment doesn't work according to your expectations?
what do u get when you have that input i posted?
SIGH
@sparrow2 I just re-linked you that - when I posted it 15 days ago
Do you think I somehow make up input? I'm too lazy for that
i added the last line in the input
now it should be correct
I added right away as you pointed out
@sparrow2 You can read, can you? I obviously understood that because I was the one pointing it out to you before you edited the question. Look closer.
19:26
you confuse me man :) when I run the code it compiles and works but output should be different for that particular input which means that there is some error and I want to know where the error is.that's it
19:39
I had trouble getting my S3 upload to work because they changed to make HTTPS required :) That's why it took a bit longer to compose this visual clue
19:52
@sparrow2 nudge
why do we get this input :
1 -> 1 = 0
1 -> 2 = 5
1 -> 3 = 7
1 -> 4 = 9
1 -> 5 = 11
1 -> 6 = 2
it'c incorrect
there must be : 1 ->4 = 7 ,1 -> 5 = 5
20:13
VS2015 can tell me the cost of memory produce where?
I have to go now,it's kind of late here.Thanks for the effort @sehe
My code cost my 1GB. I have to refine it..
are you referring to a memory profiler
memory profiler?
I'm first hear it.
I want to know how to reduce the cost of memory.
20:15
In software engineering, profiling ("program profiling", "software profiling") is a form of dynamic program analysis that measures, for example, the space (memory) or time complexity of a program, the usage of particular instructions, or the frequency and duration of function calls. Most commonly, profiling information serves to aid program optimization. Profiling is achieved by instrumenting either the program source code or its binary executable form using a tool called a profiler (or code profiler). Profilers may use a number of different techniques, such as event-based, statistical, instrumented...
But I don't now which code cost my most memory
@milleniumbug VS2015 have this function?
How to do it?
analyze -> performance profiler
@sparrow2 Why isn't that shit in your question
Ron
Ron
20:44
What's the point of having using std::to_string; as in this post?
I must be looking at it from the using namespace xyz perspective only...
Pfff, call it without the std:: prefix. My bad. Do excuse this one.
21:27
:)
@Ron Self-learners are the best learners
Ron
Ron
@sehe Haha, indeed.
22:03
@sparrow2 More visual guided tours for the blind:
0
A: why this Dijkstra algorithm not working for this particular input?

seheSo, here's your graph: The output of your program is Live On Coliru: #include <boost/graph/adjacency_list.hpp> #include <boost/graph/dijkstra_shortest_paths.hpp> #include <boost/graph/graph_utility.hpp> #include <iostream> using Graph = boost::adjacency_list< boost::vecS, boost::vecS,...

And you can make your own:
> jon skeet is the traveling salesman
Here's a minor variation of the same code used to generate the graphviz visualizations from: coliru.stacked-crooked.com/a/2e225d10dd44d54b (using these commands to create the animation) — sehe 4 mins ago
22:29
finally a repro, been chasing a dumb for a while
fix was easy

« first day (460 days earlier)      last day (2617 days later) »