How is std::is_function implemented?

Let’s go over the conditions as they appear: If const T isn’t const (const doesn’t really apply to function types since functions aren’t objects), and T isn’t a reference (const doesn’t apply to references either for the same reason), it’s a function type. int (or any other non-function-non-reference type) wouldn’t fit in because is_const<const int>::value … Read more

What are Mixins (as a concept)

Before going into what a mix-in is, it’s useful to describe the problems it’s trying to solve. Say you have a bunch of ideas or concepts you are trying to model. They may be related in some way but they are orthogonal for the most part — meaning they can stand by themselves independently of … Read more

Restrict C++ Template Parameter to Subclass

With a C++11 compliant compiler, you can do something like this: template<class Derived> class MyClass { MyClass() { // Compile-time sanity check static_assert(std::is_base_of<BaseClass, Derived>::value, “Derived not derived from BaseClass”); // Do other construction related stuff… … } } I’ve tested this out using the gcc 4.8.1 compiler inside a CYGWIN environment – so it should … Read more

CRTP to avoid dynamic polymorphism

There are two ways. The first one is by specifying the interface statically for the structure of types: template <class Derived> struct base { void foo() { static_cast<Derived *>(this)->foo(); }; }; struct my_type : base<my_type> { void foo(); // required to compile. }; struct your_type : base<your_type> { void foo(); // required to compile. }; … Read more

Are ES6 template literals faster than string concatenation?

It seems for the moment string concatenation is faster: http://jsperf.com/es6-string-literals-vs-string-concatenation ES6 with variable 19,992,512 ±5.21% 78% slower String concatenation with variable 89,791,408 ±2.15% fastest ES6 with function 461,358 ±3.12% 99% slower String concatenation with function 503,255 ±1.77% 99% slower I tested was run on Chrome 43.0.2334.0 canary (64-bit), which is using V8 4.3.31, with the … Read more

Running a command in a Grunt Task

Alternatively you could load in grunt plugins to help this: grunt-shell example: shell: { make_directory: { command: ‘mkdir test’ } } or grunt-exec example: exec: { remove_logs: { command: ‘rm -f *.log’ }, list_files: { command: ‘ls -l **’, stdout: true }, echo_grunt_version: { command: function(grunt) { return ‘echo ‘ + grunt.version; }, stdout: true … Read more

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