I have template in my .h file:  template &lt;typename T&gt; void addToolsAreaItem(){     T* item = new T(_image, this);     doSpecifiedStaff&lt;T&gt;(item);     _tools.addTool(item); }   and its specialization in .cpp file:  template &lt;&gt; void ImageWorkspace::addToolsAreaItem&lt;Preview&gt;(){     _preview = std::make_unique&lt;QGraphicsView&gt;(_splitter);     _imagesLayout.addWidget(_preview.get()); }   Class Prewiew is empty and is used only for specialize behavior of one case (when preview button is toggled).   But I get compiler error:  imageworkspace.h:45: error: new initializer expression list treated as compound expression [-fpermissive]      T* item = new T(_image, this);                ^~~~~~~~~~~~~~~~~~~  imageworkspace.h:45: error: no matching function for call to ‘Preview::Preview(ImageWorkspace*)’      T* item = new T(_image, this);                ^~~~~~~~~~~~~~~~~~~   Does compiler see specialization? How to fix it?   Function is called as addToolsAreaItem&lt;Preview&gt;() from sorces.
Quote from :     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 convenient portable solution.)
Puzzle: Find largest rectangle (maximal rectangle problem) What's the most efficient algorithm to find the rectangle with the largest area which will fit in the empty space?  Let's say the screen looks like this ('#' represents filled area):  .................... ..............###### ##.................. .................### .................### #####............... #####............... #####...............   A probable solution is:  .................... ..............###### ##...++++++++++++... .....++++++++++++### .....++++++++++++### #####++++++++++++... #####++++++++++++... #####++++++++++++...   Normally I'd enjoy figuring out a solution. Although this time I'd like to avoid wasting time fumbling around on my own since this has a practical use for a project I'm working on. Is there a well-known solution?  Shog9 wrote:     Is your input an array (as implied by the other responses), or a list of occlusions in the form of arbitrarily sized, positioned rectangles (as might be the case in a windowing system when dealing with window positions)?   Yes, I have a structure which keeps track of a set of windows placed on the screen. I also have a grid which keeps track of all the areas between each edge, whether they are empty or filled, and the pixel position of their left or top edge. I think there is some modified form which would take advantage of this property. Do you know of any? Angle notation for complex numbers in polar form Antivirus software is breaking SE web page? (blocking CSS and JS)? Firefox application associations not working in the 'Downloads' window How to make sure one understands each and every detail while reading a textbook/research paper without leaving any gaps? I am a physics Master's student.  I have good grades, with CGPA above 9(/10)(However, all courses in my university are graded on a curve so the actual marks are significantly lower than 90%). This has been my marks throughout my undergraduate and graduate courses and I was happy because this was above average. Also, my summer projects in UG were usually computational and any difficulty I had in theoretical aspects I attributed it to my inexperience in advanced Physics.   However, recently I have started to work on pure theoretical project and while reading for the project I realized that I consistently miss some details from each topic. I understand the general idea, can re-derive most of the equations(with some effort) however when I discuss things with my professor or when I read further topics I realize that I have missed certain key-details. This is exactly similar to the case of me missing a few key questions in my exams and getting that 9 grade point instead of 10(or at-least I think so). I was not worried about this before but now I realize that there is some flaw in the way I study (but I do not know what).   Since I want to apply for Physics PhD I realized that I will need to have solid concepts and it would be best to correct my mistakes but I do not know how or even what could be the reason for my imperfect understanding.  Any direct suggestion would help or even certain general guidelines on what I can do.    Things I've tried recently -   1) I've started to written down almost everything I read. This is slightly laborious but is certainly helping. It also helps me to gloss over the things I read previously when I come back the next day.  2) I completely avoid smartphone when I'm library/study room so that I won't get distracted. Not sure if it helps me solve the above problem but certainly helps me study better in general.  3) I've tried to read the topics from several sources. The books I am reading is somewhat like a collection of research papers and hence does not have a exercises. So I though reading from various sources might help get better ideas but it's not really helping because most other sources are too high level as an introductory text. But this will probably help me in cases where it's practical to do this.  4) Somewhat similar to point (1)- I am trying reread, whenever I can, what I've done until that point. But not sure how much this will help me in filling the gaps. If you have two envelopes, and ... Suppose you're given two envelopes. Both envelopes have money in them, and you're told that one envelope has twice as much money as the other. Suppose you pick one of the envelopes. Should you switch to the other one?  Intuitively, you don't know anything about either envelope, so it'd be ridiculous to say that you should switch to the other envelope to maximize your expected money.   However, consider this argument. Let $x$ be the amount of money in the envelope you picked. If $y$ is the amount of money in the other envelope, then the expected value equals  $$E(y) = \frac{1}{2}\left(\frac{1}{2}x\right) + \frac{1}{2}\left(2x\right) = \frac{5}{4} x$$  But $5x/4 &gt; x$, so you should switch!    The Wikipedia article says that $x$ stands for two different things, so this reasoning doesn't work. I say this is not a valid resolution.   Consider opening up the envelope that you pick, and finding $\$10$ inside. Then you can run the expected value calculation to get $$E(y) = \frac{1}{2} \cdot \$5+\frac{1}{2} \cdot \$20 = \$12.50$$  This means that if you open one of the envelopes and find $\$10$, you should switch to the other envelope. The $\$10$ doesn't stand for two different things, it literally just means $\$10$.   But you don't have to open up the envelope to run this calculation, you can just imagine what's inside, and run the calculation based on that. This is what "Let $x$ be the amount in the envelope" means. The problem with the argument is not that $x$ stands for two different things.   So what is the problem?    Previous questions on stack exchange have given the resolution that I just said I wasn't satisfied by, so please don't mark this as a duplicate. I want a different resolution, or a more satisfying explanation of why $x$ does stand for two different things.  Apparently there is still research being published about this problem - maybe it isn't so obvious?    I think there's something subtle wrong with the premise. Because there's no uniform probability distribution on $\mathbb{R}$, statements like "random real number" are not well-defined. Likewise, I think "one envelope has twice as much money as the other" assumes some probability distribution on $\mathbb{R}$, and perhaps our expected value calculation assumes that this distribution is uniform, which it cannot be ... Should +1 and thanks comments be a declined flag? As a moderator for GD.SE I was always led to believe our role is to clean old comments as they are intended to be a temporary item depending on the level of context and if they add any benefit to an answer.  On SO I haven't had any issues or declines when I read old Q&amp;As and see +1 and thanks and flag.    However, on other sites when I read an old Q&amp;A and I see thanks or +1 I try to be courteous and flag them as I am aware moderators do get measured by their cleanup and I'm accustomed in doing so on SO but these flags are declined.    So this leads me to ask:   Should +1 and thanks comments be flagged and is the intended role of a comment still to be considered as temporary? What is the proper classification for a thanks or +1 comment if it should be flagged?   I didn't see any Q&amp;As on this topic after browsing the tags:   and searching led me to:  but that was several years old. How can I respawn the Ender Dragon? In a theoretical physics homework problem, I have to show the following: $$\partial_\nu T^{\mu\nu} = - j_\nu F^{\mu\nu}$$  Where $T$ is the Energy-Momentum-Tensor, $j$ the generalized current and $F$ the Field-Tensor. We use the $g$ for the metric tensor, I think in English the $\eta$ is more common.  I know the following relationships:   Current and magnetic potential with Lorenz gauge condition: $$\mathop\Box A^\mu = \mu_0 j^\mu$$ Energy-Momentum-Tensor: $$T^{\mu\nu} = \frac1{\mu_0} g^{\mu\alpha} F_{\alpha\beta} F^{\beta\nu} + \frac1{4\mu_0} g^{\mu\nu} F_{\kappa\lambda} F^{\kappa\lambda}$$ Field-Tensor: $$F^{\mu\nu} = 2 \partial^{[\mu} A^{\nu]} = \partial^{\mu} A^{\nu} - \partial^{\nu} A^{\mu}$$ d'Alembert operator: $$\mathop\Box = \partial_\mu \partial^\mu$$ Bianchi identity: $$\partial^{[\mu} F^{\nu\alpha]} = 0$$   So far I have set all the definitions into the formula I have to show, but I only end up a lot of terms from antisymmetrisation and product rule. I also drew all what I have in , but I still cannot see how to tackle this problem.  Could somebody please give me a hint into the right direction? Is it true that one should not use NSLog() on production code? I was told this a few times in this very site, but I wanted to make sure this is really the case.  I was expecting to be able to sprinkle NSLog function calls throughout my code, and that Xcode/gcc would automatically strip those calls out when building my Release/Distribution builds.  Should I avoid using this? If so, what alternatives are most common between experienced Objective-C programmers? At which moment does the 'Surprised' state disappear? Though tangentially related to another post on MathOverflow (), the questions below are mainly out of curiosity. They may be very-well known ones with very well-known answers, but...    Suppose $\Sigma$ is a sigma-algebra over a set, $X$. For any given topology, $\tau$, on $X$ denote by $\mathfrak{B}_X(\tau)$ the Borel algebra over $X$ generated by $\tau$.     Question 1. Does there exist a topology, $\tau$, on $X$ such that $\Sigma = \mathfrak{B}_X(\tau)$?   If the answer to the previous question is affirmative, it makes sense to ask for the following too:     Question 2. Denote by ${\frak{T}}_X(\Sigma)$ the family of all topologies $\tau$ on $X$ such that $\Sigma = \mathfrak{B}_X(\tau)$ and let $\tau_X(\Sigma) := \bigcap_{\tau \in {\frak{T}}_X(\Sigma)} \tau$. Is $\Sigma = \mathfrak{B}_X({\frak{T}}_X(\Sigma))$?   Updates. Q2 was answered in the negative by Mike (). Question:  Is exception handling in Java actually slow?  Conventional wisdom, as well as a lot of Google results, says that exceptional logic shouldn't be used for normal program flow in Java.  Two reasons are usually given,   it is really slow - even an order of magnitude slower than regular code (the reasons given vary),     and    it is messy because people expect only errors to be handled in exceptional code.     This question is about #1.  As an example,  describes Java exception handling as "very slow" and relates the slowness to the creation of the exception message string - "this string is then used in creating the exception object that is thrown. This is not fast."  The article  says that "the reason for this is due to the object creation aspect of exception handling, which thereby makes throwing exceptions inherently slow".  Another reason out there is that the stack trace generation is what slows it down.  My testing (using Java 1.6.0_07, Java HotSpot 10.0, on 32 bit Linux), indicates that exception handling is no slower than regular code.  I tried running a method in a loop that executes some code.  At the end of the method, I use a boolean to indicate whether to return or throw.  This way the actual processing is the same. I tried running the methods in different orders and averaging my test times, thinking it may have been the JVM warming up.  In all my tests, the throw was at least as fast as the return, if not faster (up to 3.1% faster).  I am completely open to the possibility that my tests were wrong, but I haven't seen anything out there in the way of the code sample, test comparisons, or results in the last year or two that show exception handling in Java to actually be slow.  What leads me down this path was an API I needed to use that threw exceptions as part of normal control logic.  I wanted to correct them in their usage, but now I may not be able to.  Will I instead have to praise them on their forward thinking?  In the paper , the authors suggest that the presence of exception handlers alone, even if no exceptions are thrown, is enough to prevent the JIT compiler from optimizing the code properly, thus slowing it down.  I haven't tested this theory yet. What exactly is voltage? Bit of a strange question, but what is it? My physics teacher said it was kind of like a "push" that pushes electrons around the circuit. Can I have a more complex explanation? Any help is much appreciated. Continuous v. per-chapter/section numbering of figures, tables, and other document elements How to approach a student with bad hygiene? I teach engineering at a community college in the US. I currently have a student with very poor hygiene. He stinks pretty badly, has obviously greasy hair, doesn’t change his clothes frequently, and I usually seat him in the back of the room (during exams and labs, when I have power over seating arrangements) so I don’t have to smell his (relatively strong) body odor.  This student has also spoken with a colleague of mine about his low self-esteem. He’s worried that he isn’t making friends, and doesn’t know if the people he hangs out with are hanging out with him because they want something from him (help with classwork) or because they are truly friends.   In my opinion, this student follows me around like a puppy, and he tries too hard to impress people (students and faculty alike). I am a young-ish female faculty member and I try to create very large boundaries, especially with my male students. As an example, he frequently finds the need to explain to me (in way too much detail) why he gets questions wrong on exams (I don’t care, and I don’t need to know, which I’ve told him several times with no success).  So, I would like to mention to this student that his hygiene is off-putting and isn’t helping him out in the friends department. However, because he already follows me around like a puppy dog, I don’t want to encourage any more interaction from him. Additionally, it frankly embarrasses me to have to bring up hygiene issues with somebody in their late teens / early twenties. How can I bring this issue up while still maintaining my boundary as a female faculty member who doesn’t want her male students following her around and asking her for advice all the time?  I was hoping that I would be finished up with this student by now, but I am the only professor who teaches Electrical Engineering courses, so I can’t recommend that he take classes with someone else, or ask another colleague to discuss this with him. He will be taking another of my courses next semester and I don’t personally know any of his other intended professors for next semester to ask them to bring it up. php function for collating external variables into a single object regardless of GET or POST I recall reviewing someone else's PHP code once and he had a function or class method that rolled all GET and POST variables into a single plain old object that could then be passed around. If the same name-value pair appeared in both GET and POST, POST would win.  Is there a well-coded PHP add-on out there of any sort that does exactly this? Morphing only a part of a full path in tikz This might be a tikz newbie question but I have some trouble solving this.  I want to draw and fill a rectangular path where path morphing should be applied only to the upper side of the shape, more specifically I want to have an upper part with random steps. The rest of the path (left, lower and right sides) should just be straight lines. The shape should be closed and filled with one color.   My problem is that I cannot figure out how to apply the morphing only to the upper side and I suppose I cannot break up the path into different subpaths since I want to fill the final shape. Is there a way to use the morphing only on a part of the full path? Another problem is that the cycle command does not really close the shape at the upper left corner.  I tried to find a solution in the tikz manual but there was nothing that really helped me.  Here is some example code:  \documentclass[tikz, border=10pt]{standalone} \usepackage{tikz}  \begin{document}  \usetikzlibrary{decorations.pathmorphing} \begin{tikzpicture}  \draw[decorate, decoration={random steps,segment length=3.0mm, amplitude=2.0mm}, thick, rounded corners=1ex, fill=brown!70] (0,0) -- (4,0) -- ++(0, -1) -- ++(-4,0) -- cycle;   \end{tikzpicture} \end{document} Defining font color inside highlight fails Since I wanted a better readability of highlights of a would be black &amp; white-printed document, I needed to change both the highlighting color (gray) AND the font color (white).  Depending which command you implement inside the other will compile or not: \hl{\textcolor{white}{Fail}} does not work, compiling returns Package xcolor Error: Undefined color '{white}'.  Here's the mwe:  \documentclass{article} \usepackage{xcolor} \usepackage{color} \usepackage{soul} % Enables highlighting \sethlcolor{gray}  \begin{document}      \textcolor{white}{\hl{Success}}     %% Error:     %% Package xcolor Error: Undefined color `{white}'.     \hl{\textcolor{white}{Fail}}  \end{document}   So, in the end, the problem is sorta solved but I thought you might have an answer as to what happens. Operator norm. Alternative definition