Posts

C++ auto-generated copy constructors with const and non-const refs -

consider following code snippet: #include <iostream> struct foo { foo() = default; foo(foo &) { std::cout << "foo(foo &)" << std::endl; } }; struct bar { foo m; }; int main() { bar b; bar b2(b); } if code run, foo(foo &) message written. ok, foo doesn't have foo(const foo &) constructor, base(base &) constructor generated base . now, if add following definition of foo : foo(const foo &) { std::cout << "foo(const foo &)" << std::endl; } the foo(const foo &) message written. ok, foo has copy-constructor const ref parameter, base(const base &) generated compiler. but, if declare foo(const foo &) explicitly deleted: foo(const foo&) = delete; then program won't compile following errors: prog.cc: in function 'int main()': prog.cc:15:13: error: use of deleted function 'bar::bar(const bar&)' bar b2(b); ...

jekyll: combine limit and where and reverse -

using jekyll i'd to: iterate through pages where page.path not current path where page.categories contains "featured" reverse them(most recent first) limit 3 i'm having problems when getting filters together {% assign posts = site.posts | reverse %} {% post in posts limit:3 %} {% if post.categories contains 'featured' , post.path != page.path %} {% include card.html post=post %} {% endif %} {% endfor %} right limit not working because inner if prevent few items being rendered. assign 0 counter variable before entering loop. don't set limit on loop, instead set condition on counter being below limit, , increment counter using liquid's plus filter every time meet criteria , output card. {% assign posts = site.posts | reverse %} {% assign counter = 0 %} {% post in posts %} {% if counter < 3 , post.categories contains 'featured' , post.path != page.path %} {% include card.html post=post %} {% ...

c - understanding asm blocks written for gcc -

what following assembly mean in simple c (this meant compiled gcc): asm volatile ( "mov.d %0,%4\n\t" "l1: bge %2,%3,l2\n\t" "gslqc1 $f2,$f0,0(%1)\n\t" "gslqc1 $f6,$f4,0(%5)\n\t" "madd.d %0,%0,$f6,$f2\n\t" "madd.d %0,%0,$f4,$f0\n\t" "add %1,%1,16\n\t" "add %2,%2,2\n\t" "add %5,%5,16\n\t" "j l1\n\t" "l2: nop\n\t" :"=f"(sham) :"r"(foo),"r"(bar),"r"(ro),"f"(sham),"r"(bo) :"$f0","$f2","$f4","$f6" ); after several hours of searching , reading i've come following assembly code in at&t syntax: mov.d %xmm0,%xmm1 l1: bge %ebx,%ecx,l2 gslqc1 $f2,$f0,0(%eax) gslqc1 $f6,$f4,0(%esi) madd.d %xmm0,%xmm0,$f6,$f2 madd.d %xmm0,%xmm0,$f4,$f0 add %eax,%eax,16 add %ebx,%ebx,2 add %esi,%esi,16 jmp l1 l2: nop i'm in...

javascript - struggling with normalisation using map and reduce -

i want radar chart have no control api output, have turn complicated data form. i'm stuck @ least half hour. how can turn raw data const raw = [{ "device_info": { "device_id": 123, "name": "iphone", }, "age_data": [{ "age_range": "0-10", "total_count": 15, "man": 6, "women": 9 }, { "age_range": "11-20", "total_count": 11, "man": 7, "women": 4 }] }, { "device_info": { "device_id": 456, "name": "android", }, "age_data": [{ "age_range": "0-10", "total_count": 1, "man": 1, "women": 0 }, { "age_range": "11-20", "total_count": 2, "man": 0, "women": 2 }] }] into this const data = [{ ...

redux - What is a network callback? -

i reading redux docs , came across passage "this ensures neither views nor network callbacks ever write directly state" http://redux.js.org/docs/introduction/threeprinciples.html i know callback function passed function, network callback? success function in jquery ajax request?

timeline.js - How to replace all items in a vis.js timeline -

i built timeline using vis.js. have ajax call returns dataset can populate timeline. how can use javascript replace items in original vis.js timeline dataset return ajax call. full replacement of items. i'm okay redraw of timeline. example appreciated.

html - PHP doesn't connect with MySQL -

this code supposed information simple html form , post in mysql database: <html> <head> <title>cadastro de cinema</title> <head> <body> <?php $host = "localhost"; $user = "root"; $pass = ""; $banco = "cinema"; $con = @mysqli_connect($host, $user, $pass, $db) or die(mysql_error()); ?> <?php $email= isset($_post['email']) ? $_post['email'] : ''; $senha= isset($_post['senha']) ? $_post['senha'] : ''; $nome= isset($_post['nome']) ? $_post['nome'] : ''; $rua= isset($_post['rua']) ? $_post['rua'] : ''; $bairro= isset($_post['bairro']) ? $_post['bairro'] : ''; $numero= isset($_post['numero']) ? $_post['numero'] : ''; $cidade= isset($_post['cidade']) ? $_post['cidade'] : ''; $sql = mysqli_query($con, ...