I have a function template which is called with different values, i.e.  template &lt;typename T&gt; T do_calculations(const T &amp;var) {      T return_variable;      //Do calculations      return return_variable; }   Now the calculations depend on the type of the variable var. T can either be a scalar (such as double or int), a vector (such as std::vector&lt;&gt; or other types) or a matrix. I know that I can differentiate between for example a std::vector and a double by knowing that double does not have a member function called size(). How can I implement that in my code above? My aim is to have similar code to this:  template &lt;typename T&gt; T do_calculations(const T &amp;var) {      T return_variable;      if(T.has_function_size())          //Do calculations on vector      else          //Do calculations on scalar      return return_variable; }   I can not do a simple check if T is a known type due to having a lot of different input types, but I know that all possible types having a function size() behave similar enough for me.  Now my problem is: My code for the vector calculation loops over all elements, but the code for scalar calculation only over the single element:  template &lt;typename T&gt; T do_calculations(const T &amp;var) {      T return_variable;      if(T.has_function_size())          for(size_t i = 0; i &lt; T.size(); ++i)              return_variable[i] = func(var[i]);      else          return_variable = func(var);      return return_variable; }   with func() a function taking a scalar. Compilation fails with the error that I can not apply func() to a vector (or my own type). Do I have to create separate functions for that, or can I tell the compiler that I know what I do?
Is it possible to write a template that changes behavior depending on if a certain member function is defined on a class?  Here's a simple example of what I would want to write:  template&lt;class T&gt; std::string optionalToString(T* obj) {     if (FUNCTION_EXISTS(T-&gt;toString))         return obj-&gt;toString();     else         return "toString not defined"; }   So, if class T has toString() defined, then it uses it; otherwise, it doesn't. The magical part that I don't know how to do is the "FUNCTION_EXISTS" part.
Where Android apps store data? A calligraphic font with small (lowercase) letters Is there a widely available calligraphic font that (1) contains small (lowercase) letters and (2) has a recognizably calligraphic capital letter O?  Background. (1) In mathematics (algebraic geometry), , the latter being written in calligraphic script (standard notation for sheaves). However, most books end up typesetting the sheaf as follows    pulling the small letters from the italics of a completely different font.  (2) The calligraphic capital letter O plays a special role in algebraic geometry, too, and most authors insist on it being recognizably calligraphic (i.e. not just a closed round loop)    Edit. The following are achieved with extra kerning from @egreg's and @UlrikeFischer's answers (in chronological order)    @egreg's answer  \makeatletter \DeclareFontEncoding{LS1}{}{} \DeclareFontSubstitution{LS1}{stix}{m}{n} \DeclareMathAlphabet{\mathcal}{LS1}{stixscr}{m}{n} \makeatother  \DeclareMathOperator{\sHom}{\mathcal{H\mkern-7mu o\mkern-2.5mu m\mkern-1.5mu}} \DeclareMathOperator{\sExt}{\mathcal{E\mkern-4.5mu x\mkern-2.5mu t\mkern-1mu}} \DeclareMathOperator{\sEnd}{\mathcal{E\mkern-4mu n\mkern-4.5mu d\mkern-1mu}}       @UlrikeFischer's answer  \DeclareFontFamily{U}{mathc}{} \DeclareFontShape{U}{mathc}{m}{it}% {&lt;-&gt;s*[1.03] mathc10}{} \DeclareMathAlphabet{\mathcal}{U}{mathc}{m}{it}  \DeclareMathOperator{\sHom}{\mathcal{H\mkern-3mu om}} \DeclareMathOperator{\sExt}{\mathcal{E\mkern-3mu xt}} \DeclareMathOperator{\sEnd}{\mathcal{E\mkern-3mu nd}} Is there any uncountably infinite set that does not generate the reals? Does there exist an uncountably infinite set $X \subseteq \mathbb R$ such that $\mathbb R \neq \left&lt;X\right&gt;$? I can't think of any, but I'm also having trouble trying to prove that no such subset exists.  For example: $\mathbb R$ is uncountable and obviously $\mathbb R = \left&lt;\mathbb R\right&gt;$. The Cantor set $C$ is uncountable, and we know that $C - C = [0, 1]$, so then since $\mathbb R = \left&lt;[0, 1]\right&gt;$ we know that $C$ also generates $\mathbb R$. Also the set of irrationals $\mathbb R \setminus \mathbb Q$ is uncountable, but we can generate all the rational numbers by fixing one irrational number $\alpha$ and then saying the any rational number $x$ shall be $(\alpha + x) - \alpha$, since both $\alpha + x$ and $\alpha$ are irrational.  So the examples that quickly come to mind all generate the reals. Is there a simple counterexample? Variance of product of dependent variables How to delete specific lines from a txt file I have a Bash script that writes data into a log file, then from that I take out stuff I want using the sed command. That gives me a file data.txt. What I want to know is how I go about deleting specific line inside that data.txt file.  For example:  123 456 789   I want to remove the 2nd line, containing 456 so that I only have  123  789   I tried with sed '2d' data.txt but it doesn't work.  I use this command to create data.txt from log.log:  sed -nE '1s/.{1}(.{2}).*/\1/p;' log.log &gt;&gt; data.txt I have a 64-bit (amd64 a.k.a. x86_64) Debian or Ubuntu installation. I need to run 32-bit (i386/i686) programs occasionally, or to compile programs for a 32-bit system. How can I do this with a minimum of fuss?  Bonus: what if I want to run or test with an older or newer release of the distribution? Unable to delete recup_dir.1 folder A folder was created when I used a utility to recover pictures from a cd card that I deleted by mistake.  Now I can't delete it or move it. I am told I am not the owner of it even when I am logged on as root.  How can I delete the recup_dir.1 folder from my machine? Short circuit or disconnect to bypass a compressor I have an Altec Lansing ATP3 2.1 audio system PCB which I reverse-engineered, and I would like to bypass the JFET compressor that's on it. Its active components are a JFET and four op-amps. I will connect the input to the output so it gets forwarded to the next stage.  My question is: should I disconnect the input and output from the compressor (in that case should I remove power supply as well, which would be very annoying), or can I leave it connected but short-circuited?  The block I want to short-circuit is the pink one on the left.    I realize the image is very small. The sound comes in on the right, in the green box. In the middle yellow box there's some trebble/volume/bass control. The small green box on its left merges the left and right channels to forward it to the subwoofer section, which is the complete left half of this diagram (except the red box on the left, which is just power). Signal then goes through a low-pass, a small equalizer and a compressor (the big purple box). It finally gets amplified in the brown power amp. Evaluating a mathematical expression in a string How to make a vf page with the same look &amp; feel as salesforce1, any ideas? Windows 10 stuck in install loop I was having a time getting my bootable USB 3, 32GB W10 install USB to be recognized. It recognized one time but I had to restart for something and it never came up again. I eventually removed all other boot up options to make it easier and faster to try again (no F12 needed).  Finally I gave up and tried another drive (16GB this time FWIW) and then it worked.  HOWEVER, it's stuck on a reboot loop now. I can choose to install, then to select the right disk, then it says it's loading file and then next thing I know it's saying do you want to install or upgrade. Why does a candle blow out when we blow on it? Our breath is 16% oxygen and only 4% CO2 Meaning of hash symbol in pin name I'm reading the datasheet of a PSRAM (available ). In the top-right hand corner all the pins are listed. Some of the pin names end with a hash, e.g. LB#, OE#.  What does the # notation mean for pins? Superluminal neutrinos I was quite surprised to read this all over the news today:     Elusive, nearly massive subatomic particles called neutrinos appear to travel just faster than light, a team of physicists in Europe reports. If so, the observation would wreck Einstein's theory of special relativity, which demands that nothing can travel faster than light.   &mdash;  Apparently a CERN/Gran Sasso team measured a faster-than-light speed for neutrinos.   Is this even remotely possible? If so, would it be a real violation of Lorentz invariance or an "" effect?   The ; a webcast is/was planned .  News conference video How to change the style of the title attribute inside an anchor tag? Referencing bib files with spaces in the filename I am using a Mac with TeX Live and Mendeley for automatically generating .bib files, some of which have spaces in the file names. I would like to know how to reference such files from LaTeX as using "" or \ doesn't seem to work. The "Reputation &amp; Moderation" page on any site (/help/site-moderators) still refers to the company behind Stack Exchange as Stack Exchange and not Stack Overflow.     Moderators act as a liaison between the community and Stack Exchange the company.   Seeing as how the name change was recent, I'm not surprised this hasn't been caught yet, and I'm sure there are other instances of this around somewhere. How to generate a simple cartesian plane system? I need to make a cartesian plane for plotting the straight line joining the points (-3,1) and (6,-2). This is a very simple cartesian plane plotting. When I looked at the manual for tikz the graphics for cartesian planes are for more advance plotting, and what I need is very simple.  Something like this: Is it possible to change the default width of an image included via \includegraphics (from the graphicx package) to a custom value, for example \linewidth.  So I want something like this:  \documentclass{article}  \usepackage[draft,width=\linewidth]{graphicx}  %or something like \setglobalimagewidth=\linewidth  \begin{document}  \includegraphics{test1} %width=\linewidth \includegraphics[width=4cm]{test1} %width=4cm   \end{document} I'm using a  freely downloadable latex class file and the style is set to \bibliographystyle{ieeetr}. But when I cite something with \cite{} I get it inside ().   For example I get it as abc et al. (1) but what I want to get is abc et al. [1].   Please tell me how to get my citations inside [ ] ?