I read about the attributes likely and unlikely of c++20, and i want to ask if there are some reasonable and official data of performance advantages that this new attributes give to the execution. I mean there are examples execution test that give me a measure of how much this feature has impact on performance when the code is executed? I noticed that this attributes are often used in linux kernel development ( in C code ). So my question is: Does not the compiler optimaze the code sufficiently already? There are example or proof of the effective improved performances? Is this true for all kind of machine or some architectures need Likely/Unlikely for a good improvement? EDIT : I'm searching for Graph or data that demostrate the effeciency of this kind of suggestion to the compiler. ( I search online, but i don't find nothing good ) If someone know some paper, or similar can answer this question?
I've been digging through some parts of the Linux kernel, and found calls like this:  if (unlikely(fd &lt; 0)) {     /* Do something */ }   or  if (likely(!err)) {     /* Do something */ }   I've found the definition of them:  #define likely(x)       __builtin_expect((x),1) #define unlikely(x)     __builtin_expect((x),0)   I know that they are for optimization, but how do they work? And how much performance/size decrease can be expected from using them? And is it worth the hassle (and losing the portability probably) at least in bottleneck code (in userspace, of course).
Stuck at 0% [waiting for headers] On googling this error it seems that a lot of people are having this issue.  apt-get upgrade hangs at 0% [waiting for headers] apt-get install apache2 hangs at 0% [waiting for headers]. Some apt-get commands are working, but only certain packages.  Any ideas? I don't think this is an issue with slow repos because I've had it up for a long while and it hasn't budged from 0%. I have edited sources.list but I removed the lines I added when this issue presented itself and it hasn't made a difference.  Any clues would be really useful. I am trying to pass a reference to a two-dimensional array to a function in C++. I know the size of both dimensions at compile time. Here is what I have right now:  const int board_width = 80; const int board_height = 80; void do_something(int[board_width][board_height]&amp; array);  //function prototype   But this doesn't work. I get this error from g++:  error: expected ‘,’ or ‘...’ before ‘*’ token   What does this error mean, and how can I fix it? Yesterday I had 3,606 reputation but today I have 3,592.  My profile shows that I lost 6 reputation when a user was removed, but that would put me on 3,600 - 8 reputation has magically disappeared.  Adding up all of my reputation does work out at 3,591 (I'm assuming by default new users have 1 rep, so that would make sense).  Somewhere a reputation change since yesterday isn't being displayed. I don't know what this would be for, but -8 would lead me to believe that someone removed their up-vote on an answer I'd posted which already had a down-vote (could it be from that deleted user?).  I don't know if this is a bug or if there is simply a delay between reputation updating, but I figured it was worth reporting.    Sadly I cannot prove that I had 3,606 reputation yesterday. Natural (human alpha-numeric) sort in Microsoft SQL 2005 We have a large database on which we have DB side pagination. This is quick, returning a page of 50 rows from millions of records in a small fraction of a second.  Users can define their own sort, basically choosing what column to sort by.  Columns are dynamic - some have numeric values, some dates and some text.  While most sort as expected text sorts in a dumb way. Well, I say dumb, it makes sense to computers, but frustrates users.  For instance, sorting by a string record id gives something like:  rec1 rec10 rec14 rec2 rec20 rec3 rec4   ...and so on.  I want this to take account of the number, so:  rec1 rec2 rec3 rec4 rec10 rec14 rec20   I can't control the input (otherwise I'd just format in leading 000s) and I can't rely on a single format - some are things like "{alpha code}-{dept code}-{rec id}".  I know a few ways to do this in C#, but can't pull down all the records to sort them, as that would be to slow.  Does anyone know a way to quickly apply a natural sort in Sql server?    We're using:  ROW_NUMBER() over (order by {field name} asc)   And then we're paging by that.  We can add triggers, although we wouldn't. All their input is parametrised and the like, but I can't change the format - if they put in "rec2" and "rec10" they expect them to be returned just like that, and in natural order.    We have valid user input that follows different formats for different clients.  One might go rec1, rec2, rec3, ... rec100, rec101  While another might go: grp1rec1, grp1rec2, ... grp20rec300, grp20rec301  When I say we can't control the input I mean that we can't force users to change these standards - they have a value like grp1rec1 and I can't reformat it as grp01rec001, as that would be changing something used for lookups and linking to external systems.  These formats vary a lot, but are often mixtures of letters and numbers.  Sorting these in C# is easy - just break it up into { "grp", 20, "rec", 301 } and then compare sequence values in turn.  However there may be millions of records and the data is paged, I need the sort to be done on the SQL server.  SQL server sorts by value, not comparison - in C# I can split the values out to compare, but in SQL I need some logic that (very quickly) gets a single value that consistently sorts.  @moebius - your answer might work, but it does feel like an ugly compromise to add a sort-key for all these text values. When in Demon Form, are demons vulnerable to mortal frailties? When a Demon is in Demonic Form, does he gain any intrinsic protection against mundane concerns like breathing or falling unconscious? In particular, when in Demonic Form do/are demons:  need to breath? immune to poisons? fall unconscious? (ie do they stay conscious on full lethal?) suffer from wound penalties for having damage in last 3 boxes? need to consume food/water? need to sleep?  The last two are only really a concern to demons who have burnt their last cover. However this can happen in play, and is pretty significant for any burnt NPCs. Is seems odd that a swarm of glass beetles clinging together into the shape of a man might have any issues with being poisoned. But I can't find it clearly stated, whereas it is clearly stated in Werewolf (the Forsaken). Show that any set of 7 distinct integers includes two integers $x$ and $y$, such that either $x-y$ or $x+y$ is divisible by 10 Show that any set of 7 distinct integers includes two integers $x$ and $y$, such that either $x-y$ or $x+y$ is divisible by 10. I'm trying to apply the pigeonhole principle, but haven't been able to come up with a convincing argument.   Though similar to , I think the difference between the two is enough to warrant a second post. Do reactions interrupt their triggers or not? In the Player's Handbook, it is pretty clear that reactions normally interrupt the thing that they are reacting to.    Xanathar's Guide to Everything, however, has explicitly changed all reactions to occurring after their triggers have finished resolving unless the ability specifies otherwise, and is reliant on that implicit assumption for several reaction abilities already.  This leads to contradictory interpretations of reactions that take implicit timing. How should this be resolved?   I'm particularly interested in how to resolve this in Adventurers League games, where players show up with perfectly legal characters reasonably expecting their abilities to work either way on account of owning or not owning XGE. Short sci-fi story of plan devised by marooned spaceship pilot to save paradise world from development Spaceship crashes on beautiful, remote planet. The pilot survives and lives quite well on the beautiful "island paradise" world amongst friendly, good-natured people... but, one day (while relaxing in a hammock near a beach) he "realized he was dying" (actually, that he would eventually die, then being unable to help the people he had come to love). He fears future "discovery" of his adopted world and the inevitable plundering of the resources and people by "developers"... so he devises... "a plan" "convinced island elders to support his plan" "his students taught others" "achieved 80% literacy... a remarkable feat" "established world government" "more generous than developer expected" "successfully argued for independent status" "established 100% taxation rate" "finished resort buildings converted to school" "developer hired to build resort in isolated area"  ...'not having luck finding it... my recollection of the story is good, but apparently not EXACT/searchable phrases Can we get an alternative to the "That solved my problem!" button that doesn't make the presumption that it solved my problem? I.e. "Yes, that's the problem I have."  In some cases, SE (et. al.) answer something, but the answer really doesn't solve it, it was a "cop-out" -- a "we know there's a problem, but there's currently no fix or workaround". Can we get a button that indicates that "Yes, I acknowledge I have that same problem, and I may have even tried those solutions, but it's not solved by any means." button or something?  I get the purpose of it - make it more friendly and easier to remove duplicates, but I refuse to say "That solved my problem!" if I still have a problem (mostly on principle). I'd rather have a "Ah yes, that's my issue! But, it seems like there's no actual solution there."  As an example: I'm studying for an abstract algebra exam and one of the review questions was this:     Let $X$ be a set, and $\mathcal P(X)$ be the power set of $X$. Consider the operations $\Delta$ = symmetric difference (a.k.a. "XOR"), and $\bigcap$ = intersection.   a) Does $\Delta$ and $\bigcap$ make $P(X)$ into a ring?   b) If so, is it a ring with unity?   c) Is the ring commutative?   d) Is it a field?   For parts a) and b), I think it does form a ring with unity, but I'm not quite sure how to get started on proving it.   For part c), it is a commutative ring since $\mathcal P(X)$ is closed under symmetric difference and intersection, right?  Not even sure how to get started on d).  I'd really like to understand this question fully, so any kind of input would be tremendously helpful. Thank you! A shrinking map that is not a contraction no fixed point. Working from Munkres.  Show that $f: \mathbb{R}\to \mathbb{R}$ given by $f(x) = [x+\sqrt{(x^2+1)}]/2$ is a shrinking map that is not a contraction that has no fixed point.   I figured out the fixed point part but have no clue how to show the other part.  For the fixed point part $$f(x) = x \Leftrightarrow x = [x+\sqrt{(x^2+1)}]/2$$  then $$2x = x + \sqrt{(x^2+1)}$$ $$x = \sqrt{(x^2+1)}$$ $$ x^2 = x^2+1$$  Which is a contradiction.   Thanks in advance. This picture is a part of a table i am using, the terms subcases are vertically written but i cant center them vertically also in the next columns terms like A, B, etc are also not vertically centered. I made this table using tabulary package a. My code is  \begin{table}[H]  \centering  \caption{Saturation Table}  \label{tab:5}%  \begin{tabulary}{1\linewidth}{J J J J J J J J J J J J J}  \toprule  &amp; \textbf{Method} &amp; \multicolumn{1}{c}{\textbf{Parameters}} &amp; \textbf{Step 0} &amp; \textbf{Step 1} &amp; \textbf{Step 2} &amp; \textbf{Step 3} &amp; \textbf{Step 4} &amp; \textbf{Step 5} &amp; \textbf{Step 6} &amp; \textbf{Step 7} &amp; \textbf{Step 8} &amp; \textbf{Step 9} \\  \midrule  \multirow{4}[4]{*}{\begin{sideways}\textbf{Subcase A}\end{sideways}} &amp;  \multirow{2}[2]{*}{\textbf{A}} &amp; \textbf{No} &amp; 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 &amp; \textbf{6} &amp; &amp; &amp; &amp; \\[1mm]  &amp; &amp; \textbf{Maximum Saturation {(\%)}} &amp; 1 &amp; 2 &amp; 3 &amp; 4 &amp; 4 &amp; \textbf{5} &amp; &amp; &amp; &amp; \\  \cmidrule{2-13} &amp; \multirow{2}[2]{*}{\textbf{B}} &amp; \textbf{No} &amp; 1 &amp; 2 &amp; 3 &amp; 4 &amp; 5 &amp; 6 &amp; 7 &amp; \textbf{8} &amp; &amp; \\[1mm]  &amp; &amp; \textbf{Maximum Saturation {(\%)}} &amp; 6 &amp; 6 &amp; 7 &amp; 8 &amp; 9 &amp; 9 &amp; 19 &amp; \textbf{8} &amp; &amp; \\  \bottomrule  \end{tabulary}%  \end{table}% What does it mean for two objects to "touch"? How are quantum gates realised, in terms of the dynamic? When expressing computations in terms of a quantum circuit, one makes use of gates, that is, (typically) unitary evolutions.  In some sense, these are rather mysterious objects, in that they perform "magic" discrete operations on the states. They are essentially black boxes, whose inner workings are not often dealt with while studying quantum algorithms. However, that is not how quantum mechanics works: states evolve in a continuous fashion following Schrödinger's equation.  In other words, when talking about quantum gates and operations, one neglects the dynamic (that is, the Hamiltonian) realising said evolution, which is how the gates are actually implemented in experimental architectures.  One method is to decompose the gate in terms of elementary (in a given experimental architecture) ones. Is this the only way? What about such "elementary" gates? How are the dynamics implementing those typically found? I have asked this question on SO but perhaps that was the wrong location. Apologies for double posting but the question may have a better audience here.  The original question is:   And the text is below. Thanks.    When running the postgresql [9.3] "COPY TO" functionality, the postgres user creates a file. I have told it to put the file in the tmp directory (although this can be changed if needed).  This is run as part of a cron job, the user is an "export" user set up especially for this task. The end goal is for the exported file to end up in /home/export/created_file.csv.  1) postgres can't stash the exported file straight into the home directory of another user without setting up the folder to be overly permissive.  2) the export user can copy the file from /tmp to it's home directory, but then can not clean up (delete) the postgres owned file in /tmp.  This is a daily process and so old files will need to be deleted in some way. I can add a cron job to clean up the files afterwards but I was hoping for a cleaner solution - either a way to change the permissions on the file that postgres creates, or some way to give the export user the additional permission of being able to delete that file in advance of it's creation.  Giving the export user the same permissions as postgres in general however isn't an option, as it would then have free reign over the database.  Any advice, be it unix based or postgres based would be very welcome, thanks. Should you use a plural verb if you refer to a fraction?     Nine tenths of the pillar have rotted away.   I think has should be used here, but I'm not sure. Scenario (Ubuntu 16.04):  I compile and run a C program (with -g, I get the traditional Segmentation Fault (core dumped), and then (of course) there is no mythical "core" file to be found. Some digging says to modify /proc/sys/kernel/core_pattern with a command to the effect of: echo '|tee /home/me/my_core_folder/my_core_file' | sudo tee /proc/sys/kernel/core_pattern, and after doing this, I stop getting (core dumped) and start only getting the plain Segmentation Fault. I try things like gdb ./program_object_file.out core.pid which obviously doesn't exist (I was getting desperate), and of course try the plain gdb ./a.out followed by (gdb) core core.pid and variants of the commands where I spam the tab key desperately trying to get auto-completion to get me to where I need to be.  Question:  Is there a generalized way I can get to core dumps? I recognize that every machine that I touch seems to have a Michael Bay's Transformers-esque ability to reconfigure hardware and software such that no device I own can be expected to work normally out-of-the-box. Is there a simple algorithm/recipe I can follow to locate core dumps on my own machine as well as on other peoples' machines? I always find myself tutoring friends on stuff like this after no small amount of  work to get things working for myself and it would be nice to be able to run a command or something to get core files dumped to the directory which the executable was run from... is there any way to do this that should work on most (I would settle for "some") Linux/Unix machines? Force applied off center on an object Correct usage of "see" vs. "watch" Definition of $\mathbb{R}^\infty$