How do I create a C++ template for operator<< In C++, I am attempting to write a templated version of operator&lt;&lt; for std::set so that I don't have to write one for each permutation of contained value types.  I have defined my header as utils.h:  #ifndef UTILS #define UTILS  #include &lt;ostream&gt; #include &lt;set&gt;  template &lt;typename T&gt; std::ostream &amp;operator&lt;&lt;(std::ostream &amp;os, const std::set&lt;T&gt; &amp;tgt);  template &lt;typename T&gt; inline std::ostream &amp;operator&lt;&lt;(std::ostream &amp;os,                                 const std::set&lt;T&gt; *tgt) {   return os &lt;&lt; *tgt; }  #endif    The implementation is in utils.cpp:  #include "utils.h"  template &lt;typename T&gt; std::ostream &amp;operator&lt;&lt;(std::ostream &amp;os, const std::set&lt;T&gt; &amp;tgt) {   os &lt;&lt; "{";   bool first = true;   for (typename std::set&lt;T&gt;::const_iterator i = tgt.begin(); i != tgt.end();        i++) {     if (!first) {       os &lt;&lt; ", ";     } else {       first = false;     }     os &lt;&lt; i;   }   os &lt;&lt; "}";   return os; }   My attempt to use it in cout.cpp:  #include &lt;iostream&gt; #include &lt;set&gt; #include "utils.h"  class Value { public:   const int value;   Value(const int value) : value(value) {} };  std::ostream &amp;operator&lt;&lt;(std::ostream &amp;os, const Value &amp;tgt) {   os &lt;&lt; "Value(" &lt;&lt; tgt.value &lt;&lt; ")";   return os; }  inline std::ostream &amp;operator&lt;&lt;(std::ostream &amp;os, const Value *tgt) {   return os &lt;&lt; *tgt; }  int main(const int argc, const char **argv) {   std::cout &lt;&lt; argc &lt;&lt; std::endl;   std::cout &lt;&lt; *argv &lt;&lt; std::endl;   Value v(10);   std::cout &lt;&lt; v &lt;&lt; std::endl;   Value *w = &amp;v;   std::cout &lt;&lt; *w &lt;&lt; std::endl;   std::set&lt;const Value *&gt; vs;   vs.insert(w);   vs.insert(&amp;v);   Value x = Value(12);   vs.insert(&amp;x);   std::cout &lt;&lt; vs &lt;&lt; std::endl;   std::set&lt;const Value *&gt; *p = &amp;vs;   std::cout &lt;&lt; p &lt;&lt; std::endl;   return 0; }   I am attempting to compile &amp; run it with:  clang++ -c utils.cpp clang++ -o cout cout.cpp utils.o ./cout   The error that clang++ produces is:  tmp/cout-6e3988.o: In function `main': cout.cpp:(.text+0x24d): undefined reference to `std::ostream&amp; operator&lt;&lt; &lt;Value const*&gt;(std::ostream&amp;, std::set&lt;Value const*, std::less&lt;Value const*&gt;, std::allocator&lt;Value const*&gt; &gt; const&amp;)' /tmp/cout-6e3988.o: In function `std::ostream&amp; operator&lt;&lt; &lt;Value const*&gt;(std::ostream&amp;, std::set&lt;Value const*, std::less&lt;Value const*&gt;, std::allocator&lt;Value const*&gt; &gt; const*)': cout.cpp:(.text._ZlsIPK5ValueERSoS3_PKSt3setIT_St4lessIS5_ESaIS5_EE[_ZlsIPK5ValueERSoS3_PKSt3setIT_St4lessIS5_ESaIS5_EE]+0x19): undefined reference to `std::ostream&amp; operator&lt;&lt; &lt;Value const*&gt;(std::ostream&amp;, std::set&lt;Value const*, std::less&lt;Value const*&gt;, std::allocator&lt;Value const*&gt; &gt; const&amp;)' clang: error: linker command failed with exit code 1 (use -v to see invocation)   I understand that it's not finding the appropriate operator&lt;&lt; implementation during linking, but I have no idea how to go about resolving this issue.   Thanks.
Why can templates only be implemented in the header file? 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.)
running script with ". " and with "source " I was wondering if the following two ways of running a bash script are equivalent?  . ./myScript.sh  source myScript.sh  Are they both running the content of the script instead of running the script, i.e. not creating a subshell for running the script? Firstly, how do you gain the score exactly? I know it shows in the bar on the side of the map, but I remember a match where I was lone-wolfing and still got a pretty high score in that bar. I suppose my other squad members were together, but do I also gain for their work?  Also, does the score reset when I start a new game? I mean, I play support with the Offensive perk and it took me a long game of conquest to just unlock lvl-3 extra grenade. In the next match, that 'nade is gone. Don't I keep it forever? The locus of the intersection point of two perpendicular tangents to a given ellipse Lightning: why can you not have an expression combined with text in an HTML attribute? So, I've been struggling with this for a while, trying to figure out how to get it to work. Here is what I originally did:  &lt;button class="btn btn-primary {!v.isLink1 ? 'active' : ''}"&gt;   And so on. Here's the documentation on it.   However, when you actually try to save this in the developer console, you get the error:  Field Integrity Exception: Failed to save undefined: Cannot mix expression and literal string in attribute value, try rewriting like {!'foo' + v.bar}: Source   I finally figured out that you have to put all of the classes inside of the expression, like so:  &lt;button class="{!v.isLink1 ? 'btn btn-primary active' : 'btn btn-primary'}"&gt;   This doesn't seem very intuitive. It's also not documented anywhere I could find. Could someone explain to me why it is this way and if it will ever change?   (and hopefully this question saves someone some headaches in the future) The Center of $\operatorname{GL}(n,k)$ The given question:  Let $k$ be a ﬁeld and $n \in \mathbb{N}$. Show that the centre of $\operatorname{GL}(n, k)$ is $\lbrace\lambda I\mid λ ∈ k^∗\rbrace$.  I have spent a while trying to prove this and have succeeded if $ k \subseteq \mathbb{R}$. So I imagine there is a nicer way to go about this. I have seen people saying take matrices where every element except one is zero in proving similar results but such matrices are not in $\operatorname{GL}(n,k)$ as they are not invertible.  What I have done.  I have said let $B \in$ Center then $B$ commutes with everything in $\operatorname{GL}(n,k)$. So take a permutation matrix, $P$ which swaps rows $i,j$ $P \neq I$. From this you can deduce that $B^T = B$ and that $B_{ii} = B_{jj}$. We can use the fact that $B$ is symmetric to find an orthogonal diagonalisation of $B$ by the spectral theorem.  This gives $QBQ^T = D \rightarrow B=D$. And as $B_{ii} = B_{jj}$ we can say $B = k * I$.   But the spectral theorem requires $B$ to be a real matrix.   How do I prove this for a general $k$?. Proving by induction that $ \sum_{k=0}^n{n \choose k} = 2^n$ Prove by induction that for all $n \ge 0$:  $${n \choose 0} + {n \choose 1} + ... + {n \choose n} = 2^n.$$  In the inductive step, use Pascal’s identity, which is:  $${n+1 \choose k} = {n \choose k-1} + {n \choose k}.$$  I can only prove it using the binomial theorem, not induction. I want to remove the URL that gets printed on the bottom of the page.   like:  yomari.com/.../main.php?sen_n   How can it be omitted or prevent from getting printed?  To be more specific, is there any way I can prevent the page URL, date and the page title being printed along, while printing the web page? Are Windows file timestamps timezone aware? Do you need to erase the memory of *watching* a memory in a Pensieve? You remove your memory from your brain to store in a Pensieve (as Snape or Dumbledore did). Then, you re-watch the memory (e.g. as Dumbledore re-watched his memories of Voldemort's investigations with Harry) in the Pensieve.   Does that mean that you now re-created the memory in your brain (because you remember watching it) and thus you'll need to extract/erase it from your brain again if you don't wish to keep it there for security/capacity reasons (which was why you stored it in the Pensieve in the first place?  Canon answers only please. The question is as follows.  Imagine we have two closed geodesics on a surface, where these two geodesics bound a cylinder together and the geodesics are diffeomorphic to circles.  Can the cylinder have $K&gt;0$ everywhere or $K&lt;0$ everywhere?  Here $K$ is Gaussian Curvature.   What's confusing me about this question is that a cylinder has Gaussian Curvature of $K=0$ everywhere, so wouldn't the answer to both questions be no?  But then I don't get the point of the question with the geodesics.  Thank you in advance 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. Total space of a finite rank locally free sheaf, Vakil's 17.1.4 & 17.1.G I have hundreds of excel files which are all of the same format (i.e. 4 worksheets per Excel file). I need to combine all the files into 1 all singing and dancing file which must have the same format as the originals (i.e. maintain the four separate worksheets, which are all identically named).  While each file is structured the same, the number of columns (and the heading names) between sheet 1 and 2 (for example) is different. So it can’t be combined into one file with everything in one sheet!  There are two complications:   I need to create an EXTRA column in the merged file (on EACH sheet) to identify the source file (“file name”). The files contain a lot of zero data entries (e.g. 55 rows of useful data followed by hundreds of rows of zeros) which I need to remove from the merged file.   I’ve never used VBA, but everyone has to start somewhere I suppose. My ceiling fixture has all of a sudden stopped working properly. Half the diodes are dark and the others are blinking. Oddly, the same exact ones on each strip work and don't work. I have included a picture to show which ones are blinking and which ones don't work. I am wondering if it is something that I can fix? Maybe replace that driver? And if so, is there a good guide online to walk me through that process? Thanks in advance. I recently installed the apache2 package using the Software Centre, I want to create an alias apacheres which will replace the more cumbersome command /etc/init.d/apache2 restart.  I opened the .bashrc file in my home directory, and it contains the following lines:  # Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly. # See /usr/share/doc/bash-doc/examples in the bash-doc package.  if [ -f ~/.bash_aliases ]; then     . ~/.bash_aliases fi   So I created a .bash_aliases file in my home directory, and added only this line:  alias apacheres ='/etc/init.d/apache2 restart'  When I started my terminal, I get this error message:  bash: alias: apacheres: not found bash: alias: =/etc/init.d/apache2 restart: not found   The shell has obviously read the file, otherwise it wouldn't know of its existence. I have checked the directory path and I can find the file apache2 there. What do I need to do to make this alias work? Can we model gravitation as a repulsive force? This question is actually related to my earlier question ("").  The fact that objects move a lot in the universe and that the universe is expanding, can imply that gravity is a repulsive force that increases with distance.. so the farthest objects repel us more.  This can still explain several existing observations, e.g., why does the apple fall?   Motion is the result of such repulsion. Two objects unlucky enough not to be moving relative to each other get squished due to the repulsion of the rest of the universe  around them. The earth repels the apple less than the stars so it is pushed towards the earth.   Furthermore, it can explain the expanding universe without the need for dark energy.  This could be demonstrated in a thought experiment. If we take a lot of same-charge particles (with small mass) such as electrons and lock them in a large box at a low enough temperature. The mutual repulsion of the particles may cause similar motion as if due to gravitational attraction.   Another experiment would be to measure the slight changes in our weight during day and night when the sun and earth align (if their masses are large enough to detect the feeble change in repulsion).   [EDIT: the question in the original form may not have been clear. It is "can we model".. with a yes/no answer and why (not). If downvoting, please justify. Quadratic Formula in Complex Variables How do Minecraft biomes work? I've never seen any information about the distribution of biomes in a generated world.   First, are all types of biomes, guaranteed to exist in a world? Will I always find snow somewhere, and desert somewhere? I've got one world that doesn't seem to have cactus (so I guess the sand is beaches, no actual desert).  Second, is there any kind of pattern or relation to biomes? Is snow to the North, and desert South, for example?  Third, how about density of biomes? If all types do exist, would I find them all within distance X of my spawnpoint, or have to travel for weeks to find a given type? Is the trio's Polyjuice escapade in Chamber of Secrets ever discovered? In iOS 8.4.1, if a caller who has 6 numbers, calls you and you see a missed call. Then, clicking the "i" symbol next to the missed call showed you all the 6 numbers of the caller and the number from which he called, was indicated with blue. This helped in knowing exactly what number he called me from and I could call back on the same number.  iOS 9.0.1 call log does not indicate the number the caller called from with blue (if the caller has more than one number). So, it becomes impossible to call the person back on the same number.  This was one very important feature that made iOS 8 very useful. Apple has taken away a very important feature.