I have the following lines of code and compilation errors. It should be my wrong understanding of the template function, or c++ generics, or something else. Thanks in advance for pointing it out.   #include &lt;iostream&gt; #include &lt;vector&gt;  using namespace std;  template &lt;typename T&gt; T* find(vector&lt;T&gt; &amp;vec, T value) {   vector&lt;T&gt;::iterator first = vec.begin();   vector&lt;T&gt;::iterator last = vec.end();   for(; first != last; first ++)       if(*first == value)           return first;   return 0; }   The compile errors in console  debug.cpp: In function ‘T* find(std::vector&lt;T, std::allocator&lt;_CharT&gt; &gt;&amp;, T)’: debug.cpp:9: error: expected `;' before ‘first’ debug.cpp:10: error: expected `;' before ‘last’ debug.cpp:11: error: ‘first’ was not declared in this scope debug.cpp:11: error: ‘last’ was not declared in this scope
In templates, where and why do I have to put typename and template on dependent names? What exactly are dependent names anyway?    I have the following code:  template &lt;typename T, typename Tail&gt; // Tail will be a UnionNode too. struct UnionNode : public Tail {     // ...     template&lt;typename U&gt; struct inUnion {         // Q: where to add typename/template here?         typedef Tail::inUnion&lt;U&gt; dummy;      };     template&lt; &gt; struct inUnion&lt;T&gt; {     }; }; template &lt;typename T&gt; // For the last node Tn. struct UnionNode&lt;T, void&gt; {     // ...     template&lt;typename U&gt; struct inUnion {         char fail[ -2 + (sizeof(U)%2) ]; // Cannot be instantiated for any U     };     template&lt; &gt; struct inUnion&lt;T&gt; {     }; };   The problem I have is in the typedef Tail::inUnion&lt;U&gt; dummy line. I'm fairly certain that inUnion is a dependent name, and VC++ is quite right in choking on it. I also know that I should be able to add template somewhere to tell the compiler that inUnion is a template-id. But where exactly? And should it then assume that inUnion is a class template, i.e. inUnion&lt;U&gt; names a type and not a function?
Expected number of hamiltonian paths in a tournament The following theorem is from Alon&amp;Spencer's The probabilistic method, in the beginning of chapter 2:  Theorem 2.1.1: There is a tournament $T$ with $n$ vertices and at least $\frac{n!}{2^{n-1}}$ Hamiltonian paths.  Briefly the theorem is proved by looking at $X_\sigma$ the indicator random variable for a permutation $\sigma$ giving a Hamiltonian path, that is, satisfying $(\sigma(i),\sigma(i+1))\in T$ for $1\leq i \lt n$. Then   $\sum \mathbb{E}\left[X_\sigma\right] = \frac{n!}{2^{n-1}}$.  I don't understand where did this value ($\frac{n!}{2^{n-1}}$) came from! could someone explain it please? Understanding Join Attributes by Location in QGIS? I wonder if there is somewhere an explanation for the parameters that can be set when running the Algorithm "Join Attributes by Location" in QGIS 2.18.  I had a look here:       but there is no explanation. Any hints? How can I set a dark theme in TeXstudio? After perusing , I'm considering switching from TeXmaker (in which I use the preset "dark theme") to its fork, TeXstudio.  What I mean by "dark theme" is a dark background with suitable text colours, which, in my experience, is easier on the eyes than a bright background is. Here is an example:    TeXstudio doesn't seem to offer any preset dark theme, though, which means I have to customise all the colours/syntax-highlighting settings from scratch to get a dark theme even remotely usable. This can prove very time-consuming.   I'm aware this might sound a bit cheeky but,   if you are a long-time TeXstudio user, and you have fine-tuned the editor colours to get a visually pleasant dark theme,   please consider posting the relevant lines from your settings (.txsprofile or .tmxprofile) file as an answer below.  TeXstudio users who would like to use a dark theme could then build on your settings to fine-tune their own. Is there an unsubdivide function in Blender? I am wondering if there is a modifier or tool that will essentially undo a subsurf or subdivide command. unblock slime presta valve My Son's bike has slime inner tubes.  The bike has been sitting in the garage since last summer and the front tyres valve now seems blocked.  Its has what feels like 15-20 psi in it but I can not get the valve to let any air out or take any more in.  I have no idea at this point how to get it to unblock the valve so I can use it again.  For that matter I don't know how I could get the tire off as it has a reasonable (not ridable) amount of air in it without slashing the tyres (nice kings 2.2 which are pretty new).  I have tried putting the pump on it and putting a bit of air into it to try and clear the blockage but that didn't do anything.  Any ideas please? How to see the full date on macOS Big Sur? Let $G$ be a group with $|G| = n$ and let $ \emptyset \ne S \subseteq G$.   I want to show that $S^n$ is a subgroup of $G$ where by $S^n$ I mean the set $\lbrace s_1\cdots s_n \; | \; s_i \in S\rbrace$. Enable 'on the fly' CRS transformation in QGIS 3? Why does it says "welcome back -user- click here to 'refresh page'" After logging into one Stack Exchange site, when I visit another SE site, it says to me, welcome back - user - click here to refresh - web page.   Isn't it possible to refresh the page using code &amp; without the user's interaction? Just upgraded to Mountain Lion and I have to buy iPhoto again? Why did the texture I painted in texture paint mode disappear? Show that the congruence $x^{p-1} \equiv 1 \pmod {p^2}$ has precisely $p-1$ solutions modulo $p^2$ Let $p$ be a prime number. Show that the congruence $x^{p-1} \equiv 1 \pmod {p^2}$ has precisely $p-1$ solutions modulo $p^2$  I know the statment above is true for modulo $p$, but how is this imply to modulo $p^2$ Short Story about interminable rain on Venus what I want to do is this. I have an external hard disk drive, a SEAGATE expansion 1TB, you can take it a look here:  As you can see this is not a flash usb hard drive, it is a USB hard disk drive. What I want to do is installing Ubuntu in this external hard disk drive... BUT NOT PLACING THE GRUB ON MY C: DRIVE. In other words, I don't want to see the GRUB splash Window asking me every single time if I want to load Windows or Linux. I want my PC turn on or restart and go directly to Windows... BUT... I want to have Linux in my external USB hard disk drive How do I want to load Ubuntu then? Easy, when I restart my computer or just start it... in ASUS mother boards I have the possibility to select the boot device by pressing F8, and I get the boot menu. I want to turn on my computer, press F8, my mother board ask me what drive I want to use to load the Operating Sytem, I select the USB external hard disk drive where do I have Ubuntu, and bingo, I run Ubuntu. When I finish to use Ubuntu, I close it and turn off my computer. Later, I turn on my computer, and if I don't press F8, automatically load the hard disk drive C: and load Windows. My question about this, is what are the necessary steps to install the latest version from Ubuntu, doing exactly this. Not placing the GRUB in my C: hard disk drive, and installing it entirely in the external USB hard disk drive (normal one, not flash one). Is it possible, on Debian with Klipper running, to have a separate "clipboard stack" for a particular application?  I'd like the text that I copy in application Y not to be shared with all the other applications running.  All the solutions mentioned at  seems like overkill. Use Objects.hash() or own hashCode() implementation? Has Java 3D changed much since 2005? I'm thinking of picking up the book called "Killer Game Programming" by Andrew Davidson, but its pretty old, now. I know Java, and I've been messing with jMonkeyEngine for a few days, but I'm curious to see if I would benefit from the 3D chapters of this book.   The book was published was in 2005. Has Java changed to the point where this book would now be obsolete, assuming it was up to date at time of publication? Prove Lipschitz function $f$ with constant $K$ is integrable on $[0, 1].$ We suppose that $f : [0, 1] \rightarrow \mathbb{R}$ is a Lipschitz function with constant $K$. We want to show that $f$ is integrable on $[0, 1].$  I've been trying to use the Darboux criterion of integrability by trying to show that, for $\epsilon &gt; 0$, $$S^*(f,P) - S_*(f, P) &lt; \epsilon,$$ where $S^*(f, P)$ and $S_*(f, P)$ are the Upper and Lower Riemann Sums, respectively.  This is what I have so far: $$\sum_{i=1}^n M_i (x_i - x_{i-1})- \sum_{i=1}^n m_i (x_i - x_{i-1}) = \sum_{i=1}^n (M_i - m_i) (x_i - x_{i-1})$$ $$\le \sum_{i=1}^n K (x_i - x_{i-1}).$$ because $|f(x) - f(u)| \le K|x-u| \le K |1|$, since $x\in [0, 1]$. Then, $$\sum_{i=1}^n K (x_i - x_{i-1}) = K.$$ However, this is only a single upper bound, not an arbitrary $\epsilon.$ Can I get some pointers about how to proceed? Thanks! Why is $\sqrt{-x}*\sqrt{-x}=-x?$ Q1 - Why is $\sqrt{-x}*\sqrt{-x}=-x?$  Q2 - I was thinking it would be:  $\sqrt{-x}*\sqrt{-x}=\sqrt{-x*-x}=\sqrt{x^2}$ but apparently not (why not?)  Q3 - What are the formal algebra rules to use? Can I calculate this without using i such as in: $\sqrt{-x}*\sqrt{-x}=i\sqrt{x}*i\sqrt{x}=-\sqrt{x^2}=-x$. Almost surely convergence of the sequence Let ${X_n}$ be a sequence of independent and identically distributed, square integrable random variables.   Write $ u = E(X_n)$. Study the almost sure convergence, as $n \rightarrow \infty$, $$S_n = (X_1X_2 + X_2X_3 + ... + X_{n-1}X_{n})/n$$   Since $X_iX_{i+1}$ are not independent, it seems we cannot directly use law of large number for that, so anyone can give me some idea?