details of std::make_index_sequence and std::index_sequence

I see sample code around there, but I really want a dumbed down step by step explanation of how an index_sequence is coded and the meta programming principal in question for each stage. What you ask isn’t exactly trivial to explain… Well… std::index_sequence itself is very simple: is defined as follows template<std::size_t… Ints> using index_sequence … Read more

Why does std::stack not use template template parameter?

Because typically containers like std::vector have more than one template argument. By not caring about it being a template, you allow every kind of container to be used. How would template<class T, class Allocator = std::allocator<T>> class vector; fit onto template<typename> class Container as you would have it in your stack? (Hint: it doesn’t!) You’d … Read more

C++ template and inline

Since when you instantiate you get a class, that function is like an ordinary member function. It’s defined in that class, so the function is automatically inline. But it does not really matter here that much. You can define function templates or members of class templates multiple times in a program anyway – you don’t … Read more

What are modern uses of script type=”text/html” and is this example considered good use?

According to the HTML5 spec for the script tag, it’s totally fine to use <script> with a type attribute set to any valid MIME type. That includes MIME types like text/html or text/plain. According to the HTML4 spec for the script tag, it’s not quite fine: “There are two types of scripts authors may attach … Read more

Visual Studio 2010 Make and Install Templates

In Visual Studio’s path you will find the default templates, these are a set of zip files that get expanded into the template cach. They are stored in Item Templates – %VSInstallDir%\Common7\IDE\ItemTemplates\ Project Templates – %VSInstallDir%\Common7\IDE\ProjectTemplates\ Extracting the {{.zip}} in question and recompressing with the modified contents will update the template. You can also copy … Read more

Is specializing std::swap deprecated now that we have move semantics? [duplicate]

The specialization of std::swap is now optional, but not deprecated. The rationale is performance. For prototyping code, and perhaps even for much shipping code, std::swap will be plenty fast. However if you’re in a situation where you need to eek out every little bit from your code, writing a custom swap can still be a … Read more

Should templated functions take lambda arguments by value or by rvalue reference?

FunctorT&& is a universal reference and can match anything, not only rvalues. It’s the preferred way to pass things in C++11 templates, unless you absolutely need copies, since it allows you to employ perfect forwarding. Access the value through std::forward<FunctorT>(f), which will make f an rvalue again if it was before, or else will leave … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)