SlideShare a Scribd company logo
1 of 27
Download to read offline
C++11	
  
Implementa-on	
  differences	
  between	
  
proprietary	
  and	
  open	
  source	
  compilers	
  
and	
  walkthrough	
  on	
  what’s	
  new	
  
if	
  (myself	
  !=	
  nullptr)	
  
•  Milot	
  Shala	
  
•  Primarily	
  wri-ng	
  soEware	
  in	
  C++	
  for	
  quite	
  
some	
  -me	
  
•  Been	
  in	
  the	
  industry	
  for	
  almost	
  13	
  years	
  now	
  
•  Worked	
  on	
  cool	
  and	
  innova-ve	
  projects	
  
•  Built	
  a	
  cross-­‐plaMorm	
  library	
  that	
  had	
  to	
  work	
  
with	
  MicrosoE’s	
  Visual	
  C++	
  compiler	
  
Beginning	
  of	
  C++11	
  and	
  Visual	
  C++	
  
compiler	
  ==	
  nightmare	
  
I	
  wrote	
  two	
  crazy	
  template	
  classes	
  
// List template class to “keep” reference count!
template<class T> class List {!
!
};!
!
// Window template template class with it’s constructor!
template<class W, class H, template <typename> class L> class Window
{!
public:!
Window() {!
auto references = new L<W>();!
}!
"!
"//...!
}!
Let	
  me	
  walk	
  you	
  through	
  new	
  changes	
  
Window<int, int, List>* window = new Window<int, int, List>();	
  
Before:	
  
auto window = new Window<int, int, List>();	
  
AEer:	
  
Let	
  me	
  walk	
  you	
  through	
  new	
  changes	
  
Imagine	
  a	
  piece	
  of	
  code	
  like	
  this:	
  
std::vector<Window<int, int, List> >* vec = new std::vector<Window<int, int, List> >();!
!
for (std::vector<Window<int, int, List> >::iterator it_begin = vec->begin(); !
it_begin != vec->end(); ++it_begin) {!
// iterate!
}	
  
Was	
  replaced	
  with	
  this:	
  
auto vec1 = new std::vector<Window<int, int, List> >();!
!
for (auto win : *vec1) {!
// iterate!
}	
  
Smart	
  Pointers	
  
Window<int, int, List>* window = new Window<int, int, List>();	
  
Not	
  as	
  easy	
  as	
  it	
  looks!	
  
	
  
Who	
  should	
  delete	
  this	
  object?	
  
std::shared_ptr<Window<int, int, List> > window(new Window<int, int, List>());	
  
We	
  can	
  use	
  shared_ptr	
  or	
  unique_ptr	
  
Or	
  beWer	
  this:	
  
auto window = std::make_shared<Window<int, int, List> >();	
  
std::unique_ptr!
std::shared_ptr	
  
From	
  the	
  list	
  of	
  41	
  entries	
  I	
  extracted	
  only	
  features	
  not	
  yet	
  implemented	
  _today_	
  in	
  
Visual	
  C++	
  and	
  are	
  implemented	
  in	
  g++	
  
Feature	
   Visual	
  C++	
  
2013	
  
g++	
  4.8.1	
  
sizeof	
  on	
  
non-­‐sta-c	
  
data	
  
members	
  
without	
  an	
  
instance	
  
No	
   Yes	
  
Changed	
  
restric-ons	
  
on	
  union	
  
members	
  
	
  
No	
   Yes	
  
User	
  defined	
  
literals	
  
No	
   Yes	
  
Encoding	
  
support	
  in	
  
literals	
  
No	
   Yes	
  
Feature	
   Visual	
  C++	
  
2013	
  
g++	
  4.8.1	
  
Template	
  
aliases	
  
No	
   Yes	
  
Defaulted	
  
methods	
  
No	
   Yes	
  
Deleted	
  
methods	
  
No	
   Yes	
  
Generalized	
  
aWributes	
  
No	
   Yes	
  
New	
  built-­‐in	
  
types	
  
Par-al	
   Yes	
  
Alignment	
  
support	
  
Par-al	
   Yes	
  
Inline	
  
namespaces	
  
No	
   Yes	
  
Feature	
   Visual	
  C++	
  
2013	
  
g++	
  4.8.1	
  
Arbitrary	
  
expressions	
  in	
  
template	
  
deduc-on	
  
contexts	
  
No	
   Yes	
  
Non-­‐sta-c	
  
data	
  member	
  
ini-alizers	
  
No	
   Yes	
  
noexcept	
   No	
   Yes	
  
constexpr	
   No	
   Yes	
  
Thread	
  local	
  
storage	
  
Par-al	
   Yes	
  
Inheri-ng	
  
constructors	
  
No	
   Yes	
  
Rvalue	
  
references	
  for	
  
*this	
  
No	
   Yes	
  
C++	
  Template	
  Meta-­‐Programming	
  
•  Compile-­‐-me	
  results	
  
•  Can	
  be	
  used	
  in	
  gaming,	
  e.g.	
  calculate	
  gravity	
  
equa-on	
  and	
  have	
  the	
  value	
  ready	
  
•  Not	
  easy!	
   Typical	
  func-on	
  to	
  calculate	
  Fibonacci	
  
int fibonacci(int n)!
{!
if (n <= 2) { " "!
return 1;!
} else {!
return fibonacci(n - 1) + fibonacci(n - 2);!
}!
}	
  
C++	
  Template	
  Meta-­‐Programming	
  
template <int T> struct Fibonacci!
{!
enum { value = (Fibonacci<T - 1>::value + Fibonacci<T -
2>::value) };!
};!
!
template <> struct Fibonacci<0>!
{!
enum { value = 1 };!
};!
!
template <> struct Fibonacci<1>!
{!
enum { value = 1 };!
};!
!
template <> struct Fibonacci<2>!
{!
enum { value = 1 };!
};	
  
Generalized	
  constant	
  expressions	
  
Bjarne	
  Stroustrup	
  is	
  not	
  good	
  with	
  words.	
  He	
  admiWed	
  it	
  himself!	
  
All	
  he	
  means	
  is	
  this	
  
constexpr int fibonacci (int n)!
{!
return (n <= 2 ? 1 : fibonacci(n - 1) + fibonacci(n - 2));!
}	
  
Calculates	
  the	
  Fibonacci	
  sequence	
  in	
  compile-­‐-me	
  so	
  the	
  result	
  is	
  already	
  there	
  to	
  be	
  used.	
  
Supports	
  only	
  a	
  single	
  line	
  implementa-on.	
  
And	
  this	
  is	
  missing	
  in	
  Visual	
  C++	
  compiler!	
  
Variadic	
  Templates	
  
•  C++	
  uses	
  variable	
  argument	
  list	
  (so	
  does	
  Java	
  
and	
  C):	
  
int avg( int n, ... )!
{!
va_list pVarArg;!
va_start( pVarArg, n );!
!
// ...!
}	
  
•  Now	
  we	
  use	
  similar	
  approach	
  with	
  templates	
  
and	
  it’s	
  arguments	
  
// usage!
int i = avg(10, 10, 10, 10, 10);	
  
Variadic	
  Templates	
  
•  Why	
  we	
  need	
  them?	
  
•  std::pair	
  pairs	
  two	
  items	
  together	
  
•  std::tuple	
  pairs	
  zero	
  or	
  more	
  items	
  together	
  
(feature	
  achieved	
  with	
  variadic	
  templates)	
  
std::tuple<int, int, std::string> getWindowInformation(int id)!
{!
if (id == 0) return std::make_tuple(100, 100, "Settings");!
if (id == 1) return std::make_tuple(800, 600, "Main Window");!
if (id == 2) return std::make_tuple(800, 60, "Chat Window");!
throw std::invalid_argument("id");!
}	
  
We	
  can	
  use	
  whatever	
  we	
  want!	
  
Variadic	
  Templates	
  
•  Usage	
  
for (auto window : windows) {!
auto win = getWindowInformation(window);!
std::cout << "Window 0 - "!
<< "Width: " << std::get<0>(win) << ", "!
<< "Height: “ << std::get<1>(win) << ", "!
<< "Title: ” << std::get<2>(win) << 'n';!
}	
  
Variadic	
  Templates	
  basic	
  
implementa-on	
  
template<class... elements> class tuple;!
!
// empty!
template<> class tuple<> {};!
!
template<class _class, class... elements>!
class tuple<_class, elements...> : private tuple<elements...>!
{!
public:!
_class _this;!
};	
  
Ellipsis	
  just	
  like	
  in	
  the	
  variable	
  argument	
  lists!	
  
Cool	
  stuff	
  about	
  variadic	
  templates	
  
•  This	
  is	
  how	
  they	
  can	
  be	
  used	
  (16	
  arguments):	
  
•  In	
  the	
  beginning	
  in	
  Visual	
  C++	
  maximum	
  was	
  5	
  
arguments	
  only!	
  
std::tuple<int, int, int, int, int,!
int, int, int, int, int,!
int, int, int, int, int,!
int, std::string> getWindowInformation(int id)!
{!
return std::make_tuple(100, 100, 100,!
100, 100, 100,!
100, 100, 100,!
100, 100, 100,!
100, 100, 100,!
100,"Settings");!
}	
  
A	
  comment	
  from	
  MicrosoE	
  kernel	
  
developer	
  on	
  the	
  issue!	
  
We	
  just	
  can't	
  be	
  fucked	
  to	
  implement	
  C11	
  support,	
  and	
  variadic	
  
templates	
  were	
  just	
  too	
  hard	
  to	
  implement	
  in	
  a	
  year.	
  (But	
  
ohmygosh	
  we	
  turned	
  "^"	
  into	
  a	
  reference-­‐counted	
  pointer	
  
operator.	
  Oh,	
  and	
  what's	
  a	
  reference	
  cycle?)	
  	
  ~	
  Anonymous	
  
MicrosoE	
  Employee	
  on	
  Reddit	
  
Lvalues	
  and	
  Rvalues	
  
•  Lvalue	
  can	
  appear	
  on	
  both	
  leE	
  and	
  right	
  sides	
  
of	
  the	
  assignment	
  operator	
  
•  Rvalue	
  can	
  appear	
  only	
  on	
  the	
  right	
  side	
  of	
  an	
  
assignment	
  operator	
  
int i = 42;!
i = 43; // lvalue!
int* p = &i; // lvalue!
!
int& atlas();!
atlas() = 42; // lvalue!
int* p1 = &atlas(); //lvalue	
  
int stryder();!
int j = 0;!
j = stryder(); // rvalue!
int* p2 = &stryder(); // fail!
j = 42; // rvalue	
  
Cannot	
  take	
  address	
  of	
  rvalue	
  reference	
  
Move	
  seman-cs	
  
Window<int, int, List> wnd();!
Window<int, int, List> x;!
// use x...!
x = wnd();	
  
Destroy	
  resource	
  held	
  
by	
  x	
  
Last	
  line	
  will	
  
Copy	
  from	
  temporary	
  
resource	
  returned	
  from	
  
wnd()	
  
Destroy	
  temporary	
  
resource	
  and	
  release	
  
the	
  memory	
  
Move	
  Seman-cs	
  
Original	
  
Object	
  
COPY	
  
New	
  
copied	
  
object	
  
Original	
  
Object	
  
MOVE	
   New	
  
object	
  
We	
  want	
  to	
  move!	
  Even	
  a	
  child	
  can	
  move	
  things	
  around!	
  
How	
  the	
  object	
  assignment	
  operator	
  
should	
  be	
  implemented?	
  
// Classical implementation!
Window& Window::operator=(Window const & rhs);!
!
// Move semantics: exchange content between this and wnd!
Window& Window::operator=(Window&& wnd) { "!
"return *this;!
}	
  
// Another usage with std::move!
std::string str = "Stand by for Titanfall!";!
std::vector<std::string> v;!
!
// Copy!
v.push_back(str);!
!
// Move!
v.push_back(std::move(str));	
  
Back	
  to	
  std::make_pair	
  
// C++98!
template <class T1, class T2> pair<T1,T2> make_pair (T1 x, T2 y);	
  
// C++11!
template <class T1, class T2> pair<V1,V2> make_pair (T1&& x, T2&& y);	
  
What	
  is	
  the	
  difference?	
  
Rvalue	
  references!	
  
Back	
  to	
  std::make_pair	
  
•  C++11	
  flag	
  was	
  set	
  on	
  Visual	
  C++	
  compiler	
  
op-on	
  
•  Code	
  worked	
  properly	
  on	
  g++	
  
•  I	
  was	
  gelng	
  “You	
  cannot	
  bind	
  an	
  lvalue	
  to	
  an	
  
rvalue”	
  error	
  message!	
  
•  It	
  was	
  lacking	
  proper	
  overloaded	
  method	
  to	
  
support	
  backward	
  compa-bility	
  
Had	
  to	
  hack	
  my	
  way	
  into	
  MicrosoE	
  header	
  files	
  to	
  trick	
  it	
  to	
  compile!	
  
Problem?	
  
•  Worked	
  on	
  a	
  corporate	
  
•  Bureaucracy	
  kills	
  the	
  mood	
  
•  If	
  you	
  do	
  something	
  small	
  will	
  go	
  unno-ced	
  
•  You	
  need	
  to	
  do	
  something	
  dras-c	
  to	
  get	
  no-ced	
  
•  In	
  open	
  source	
  community	
  you	
  just	
  need	
  to	
  start	
  
doing	
  it!	
  
•  Everyone	
  will	
  appreciate	
  whatever	
  you	
  do!	
  	
  
Even	
  if	
  it’s	
  5%	
  speed	
  increase	
  or	
  a	
  -ny	
  feature	
  you	
  will	
  get	
  appreciated!	
  
Another	
  comment	
  from	
  same	
  guy	
  
There's	
  also	
  liPle	
  incenQve	
  to	
  create	
  changes	
  in	
  the	
  first	
  place.	
  On	
  linux-­‐
kernel,	
  if	
  you	
  improve	
  the	
  performance	
  of	
  directory	
  traversal	
  by	
  a	
  
consistent	
  5%,	
  you're	
  praised	
  and	
  thanked.	
  Here,	
  if	
  you	
  do	
  that	
  and	
  you're	
  
not	
  on	
  the	
  object	
  manager	
  team,	
  then	
  even	
  if	
  you	
  do	
  get	
  your	
  code	
  past	
  the	
  
Ob	
  owners	
  and	
  into	
  the	
  tree,	
  your	
  own	
  management	
  doesn't	
  care.	
  ~	
  
Anonymous	
  MicrosoE	
  Employee	
  
Thank	
  you!	
  
•  Unfortunately	
  the	
  post	
  was	
  deleted	
  from	
  Reddit	
  
(yes	
  MicrosoE	
  reads	
  Reddit).	
  
•  Fortunately	
  someone	
  copied	
  it	
  over	
  to	
  his	
  blog:	
  
hPp://bit.ly/milot	
  

More Related Content

What's hot

Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)Olve Maudal
 
Types, classes and concepts
Types, classes and conceptsTypes, classes and concepts
Types, classes and conceptsNicola Bonelli
 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Scott Wlaschin
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesGanesh Samarthyam
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)jeffz
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming iiPrashant Kalkar
 
An introduction to property based testing
An introduction to property based testingAn introduction to property based testing
An introduction to property based testingScott Wlaschin
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionEelco Visser
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScriptT11 Sessions
 
Introduction to Programming Bots
Introduction to Programming BotsIntroduction to Programming Bots
Introduction to Programming BotsDmitri Nesteruk
 

What's hot (19)

Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)Modern C++ Explained: Move Semantics (Feb 2018)
Modern C++ Explained: Move Semantics (Feb 2018)
 
Types, classes and concepts
Types, classes and conceptsTypes, classes and concepts
Types, classes and concepts
 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)
 
Design Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on ExamplesDesign Patterns - Compiler Case Study - Hands-on Examples
Design Patterns - Compiler Case Study - Hands-on Examples
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
 
Functional programming ii
Functional programming iiFunctional programming ii
Functional programming ii
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
An introduction to property based testing
An introduction to property based testingAn introduction to property based testing
An introduction to property based testing
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
09. Methods
09. Methods09. Methods
09. Methods
 
09. Java Methods
09. Java Methods09. Java Methods
09. Java Methods
 
Java generics final
Java generics finalJava generics final
Java generics final
 
07. Arrays
07. Arrays07. Arrays
07. Arrays
 
Cheat Sheet java
Cheat Sheet javaCheat Sheet java
Cheat Sheet java
 
Introduction to web programming with JavaScript
Introduction to web programming with JavaScriptIntroduction to web programming with JavaScript
Introduction to web programming with JavaScript
 
C++ 11
C++ 11C++ 11
C++ 11
 
Introduction to Programming Bots
Introduction to Programming BotsIntroduction to Programming Bots
Introduction to Programming Bots
 
Javascript
JavascriptJavascript
Javascript
 
Ruby Programming Assignment Help
Ruby Programming Assignment HelpRuby Programming Assignment Help
Ruby Programming Assignment Help
 

Similar to C++11 Implementation Differences and What's New

PRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxPRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxSajalKesharwani2
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...Sang Don Kim
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#Hawkman Academy
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project AnalyzedPVS-Studio
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummaryAmal Khailtash
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Chris Adamson
 
TEMPLATES IN JAVA
TEMPLATES IN JAVATEMPLATES IN JAVA
TEMPLATES IN JAVAMuskanSony
 
An Experiment with Checking the glibc Library
An Experiment with Checking the glibc LibraryAn Experiment with Checking the glibc Library
An Experiment with Checking the glibc LibraryAndrey Karpov
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5thConnex
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2ASU Online
 
What’s new in .NET
What’s new in .NETWhat’s new in .NET
What’s new in .NETDoommaker
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifestohu hans
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C LanguageMohamed Elsayed
 
Headache from using mathematical software
Headache from using mathematical softwareHeadache from using mathematical software
Headache from using mathematical softwarePVS-Studio
 

Similar to C++11 Implementation Differences and What's New (20)

02basics
02basics02basics
02basics
 
C++ Training
C++ TrainingC++ Training
C++ Training
 
PRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptxPRINCE PRESENTATION(1).pptx
PRINCE PRESENTATION(1).pptx
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
2CPP15 - Templates
2CPP15 - Templates2CPP15 - Templates
2CPP15 - Templates
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
Modern C++
Modern C++Modern C++
Modern C++
 
The First C# Project Analyzed
The First C# Project AnalyzedThe First C# Project Analyzed
The First C# Project Analyzed
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features Summary
 
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
Oh Crap, I Forgot (Or Never Learned) C! [CodeMash 2010]
 
TEMPLATES IN JAVA
TEMPLATES IN JAVATEMPLATES IN JAVA
TEMPLATES IN JAVA
 
An Experiment with Checking the glibc Library
An Experiment with Checking the glibc LibraryAn Experiment with Checking the glibc Library
An Experiment with Checking the glibc Library
 
Presentation 5th
Presentation 5thPresentation 5th
Presentation 5th
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2
 
What’s new in .NET
What’s new in .NETWhat’s new in .NET
What’s new in .NET
 
C Programming Homework Help
C Programming Homework HelpC Programming Homework Help
C Programming Homework Help
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifesto
 
A brief introduction to C Language
A brief introduction to C LanguageA brief introduction to C Language
A brief introduction to C Language
 
Headache from using mathematical software
Headache from using mathematical softwareHeadache from using mathematical software
Headache from using mathematical software
 
College1
College1College1
College1
 

More from Open Labs Albania

Clair Tolan - Passwords for the clouds
Clair Tolan - Passwords for the cloudsClair Tolan - Passwords for the clouds
Clair Tolan - Passwords for the cloudsOpen Labs Albania
 
Ismet Azizi - Shquarsia: Si mund të siguroheni që artikulli juaj nuk do të fs...
Ismet Azizi - Shquarsia: Si mund të siguroheni që artikulli juaj nuk do të fs...Ismet Azizi - Shquarsia: Si mund të siguroheni që artikulli juaj nuk do të fs...
Ismet Azizi - Shquarsia: Si mund të siguroheni që artikulli juaj nuk do të fs...Open Labs Albania
 
Georges Labreche - Open Data Kosovo - Open data for good governance
Georges Labreche - Open Data Kosovo - Open data for good governanceGeorges Labreche - Open Data Kosovo - Open data for good governance
Georges Labreche - Open Data Kosovo - Open data for good governanceOpen Labs Albania
 
Chris Ward - Taking Open Source beyond Software
Chris Ward - Taking Open Source beyond SoftwareChris Ward - Taking Open Source beyond Software
Chris Ward - Taking Open Source beyond SoftwareOpen Labs Albania
 
Bruno Skvorc - Open sourcing content - peer review's effect on quality
Bruno Skvorc - Open sourcing content - peer review's effect on qualityBruno Skvorc - Open sourcing content - peer review's effect on quality
Bruno Skvorc - Open sourcing content - peer review's effect on qualityOpen Labs Albania
 
Andri Xhitoni - Indexing Albanian Language
Andri Xhitoni - Indexing Albanian LanguageAndri Xhitoni - Indexing Albanian Language
Andri Xhitoni - Indexing Albanian LanguageOpen Labs Albania
 
Alex Corbi - Building 100 percent os open data platform
Alex Corbi - Building 100 percent os open data platformAlex Corbi - Building 100 percent os open data platform
Alex Corbi - Building 100 percent os open data platformOpen Labs Albania
 
Kiril Simeonovski - The value of open knowledge
Kiril Simeonovski - The value of open knowledgeKiril Simeonovski - The value of open knowledge
Kiril Simeonovski - The value of open knowledgeOpen Labs Albania
 
Gjergj Sheldija - Healthcare and Open Technology
Gjergj Sheldija - Healthcare and Open TechnologyGjergj Sheldija - Healthcare and Open Technology
Gjergj Sheldija - Healthcare and Open TechnologyOpen Labs Albania
 
Giannis Konstantinidis - The fedora community
Giannis Konstantinidis - The fedora communityGiannis Konstantinidis - The fedora community
Giannis Konstantinidis - The fedora communityOpen Labs Albania
 
Enkeleda Ibrahimi - Open source security
Enkeleda Ibrahimi - Open source securityEnkeleda Ibrahimi - Open source security
Enkeleda Ibrahimi - Open source securityOpen Labs Albania
 
Chris Heilmann - The new challenge of open
Chris Heilmann - The new challenge of openChris Heilmann - The new challenge of open
Chris Heilmann - The new challenge of openOpen Labs Albania
 
Bruno Skvorc - The many ways to contribute to open source
Bruno Skvorc - The many ways to contribute to open sourceBruno Skvorc - The many ways to contribute to open source
Bruno Skvorc - The many ways to contribute to open sourceOpen Labs Albania
 
Blerta Thaçi & zana Idrizi - Empowering women in the community of coding
Blerta Thaçi & zana Idrizi - Empowering women in the community of coding Blerta Thaçi & zana Idrizi - Empowering women in the community of coding
Blerta Thaçi & zana Idrizi - Empowering women in the community of coding Open Labs Albania
 
Bledar Gjocaj - Java open source
Bledar Gjocaj - Java open sourceBledar Gjocaj - Java open source
Bledar Gjocaj - Java open sourceOpen Labs Albania
 
Besfort Guri - Floss Tools for Gis
Besfort Guri - Floss Tools for GisBesfort Guri - Floss Tools for Gis
Besfort Guri - Floss Tools for GisOpen Labs Albania
 
Alex Corbi - Visualizing open data with carto_db
Alex Corbi - Visualizing open data with carto_dbAlex Corbi - Visualizing open data with carto_db
Alex Corbi - Visualizing open data with carto_dbOpen Labs Albania
 
Inva Veliu & Florian Tani - Open Atrium
Inva Veliu & Florian Tani - Open AtriumInva Veliu & Florian Tani - Open Atrium
Inva Veliu & Florian Tani - Open AtriumOpen Labs Albania
 
Greta Doçi - WikiAcademy Albania
Greta Doçi - WikiAcademy AlbaniaGreta Doçi - WikiAcademy Albania
Greta Doçi - WikiAcademy AlbaniaOpen Labs Albania
 

More from Open Labs Albania (20)

Clair Tolan - Passwords for the clouds
Clair Tolan - Passwords for the cloudsClair Tolan - Passwords for the clouds
Clair Tolan - Passwords for the clouds
 
Ismet Azizi - Shquarsia: Si mund të siguroheni që artikulli juaj nuk do të fs...
Ismet Azizi - Shquarsia: Si mund të siguroheni që artikulli juaj nuk do të fs...Ismet Azizi - Shquarsia: Si mund të siguroheni që artikulli juaj nuk do të fs...
Ismet Azizi - Shquarsia: Si mund të siguroheni që artikulli juaj nuk do të fs...
 
Georges Labreche - Open Data Kosovo - Open data for good governance
Georges Labreche - Open Data Kosovo - Open data for good governanceGeorges Labreche - Open Data Kosovo - Open data for good governance
Georges Labreche - Open Data Kosovo - Open data for good governance
 
Chris Ward - Taking Open Source beyond Software
Chris Ward - Taking Open Source beyond SoftwareChris Ward - Taking Open Source beyond Software
Chris Ward - Taking Open Source beyond Software
 
Bruno Skvorc - Open sourcing content - peer review's effect on quality
Bruno Skvorc - Open sourcing content - peer review's effect on qualityBruno Skvorc - Open sourcing content - peer review's effect on quality
Bruno Skvorc - Open sourcing content - peer review's effect on quality
 
Andri Xhitoni - Indexing Albanian Language
Andri Xhitoni - Indexing Albanian LanguageAndri Xhitoni - Indexing Albanian Language
Andri Xhitoni - Indexing Albanian Language
 
Alex Corbi - Building 100 percent os open data platform
Alex Corbi - Building 100 percent os open data platformAlex Corbi - Building 100 percent os open data platform
Alex Corbi - Building 100 percent os open data platform
 
Kiril Simeonovski - The value of open knowledge
Kiril Simeonovski - The value of open knowledgeKiril Simeonovski - The value of open knowledge
Kiril Simeonovski - The value of open knowledge
 
Gjergj Sheldija - Healthcare and Open Technology
Gjergj Sheldija - Healthcare and Open TechnologyGjergj Sheldija - Healthcare and Open Technology
Gjergj Sheldija - Healthcare and Open Technology
 
Giannis Konstantinidis - The fedora community
Giannis Konstantinidis - The fedora communityGiannis Konstantinidis - The fedora community
Giannis Konstantinidis - The fedora community
 
Enkeleda Ibrahimi - Open source security
Enkeleda Ibrahimi - Open source securityEnkeleda Ibrahimi - Open source security
Enkeleda Ibrahimi - Open source security
 
Chris Heilmann - The new challenge of open
Chris Heilmann - The new challenge of openChris Heilmann - The new challenge of open
Chris Heilmann - The new challenge of open
 
Bruno Skvorc - The many ways to contribute to open source
Bruno Skvorc - The many ways to contribute to open sourceBruno Skvorc - The many ways to contribute to open source
Bruno Skvorc - The many ways to contribute to open source
 
Blerta Thaçi & zana Idrizi - Empowering women in the community of coding
Blerta Thaçi & zana Idrizi - Empowering women in the community of coding Blerta Thaçi & zana Idrizi - Empowering women in the community of coding
Blerta Thaçi & zana Idrizi - Empowering women in the community of coding
 
Bledar Gjocaj - Java open source
Bledar Gjocaj - Java open sourceBledar Gjocaj - Java open source
Bledar Gjocaj - Java open source
 
Besfort Guri - OS Geo Live
Besfort Guri - OS Geo LiveBesfort Guri - OS Geo Live
Besfort Guri - OS Geo Live
 
Besfort Guri - Floss Tools for Gis
Besfort Guri - Floss Tools for GisBesfort Guri - Floss Tools for Gis
Besfort Guri - Floss Tools for Gis
 
Alex Corbi - Visualizing open data with carto_db
Alex Corbi - Visualizing open data with carto_dbAlex Corbi - Visualizing open data with carto_db
Alex Corbi - Visualizing open data with carto_db
 
Inva Veliu & Florian Tani - Open Atrium
Inva Veliu & Florian Tani - Open AtriumInva Veliu & Florian Tani - Open Atrium
Inva Veliu & Florian Tani - Open Atrium
 
Greta Doçi - WikiAcademy Albania
Greta Doçi - WikiAcademy AlbaniaGreta Doçi - WikiAcademy Albania
Greta Doçi - WikiAcademy Albania
 

Recently uploaded

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

C++11 Implementation Differences and What's New

  • 1. C++11   Implementa-on  differences  between   proprietary  and  open  source  compilers   and  walkthrough  on  what’s  new  
  • 2. if  (myself  !=  nullptr)   •  Milot  Shala   •  Primarily  wri-ng  soEware  in  C++  for  quite   some  -me   •  Been  in  the  industry  for  almost  13  years  now   •  Worked  on  cool  and  innova-ve  projects   •  Built  a  cross-­‐plaMorm  library  that  had  to  work   with  MicrosoE’s  Visual  C++  compiler  
  • 3. Beginning  of  C++11  and  Visual  C++   compiler  ==  nightmare  
  • 4. I  wrote  two  crazy  template  classes   // List template class to “keep” reference count! template<class T> class List {! ! };! ! // Window template template class with it’s constructor! template<class W, class H, template <typename> class L> class Window {! public:! Window() {! auto references = new L<W>();! }! "! "//...! }!
  • 5. Let  me  walk  you  through  new  changes   Window<int, int, List>* window = new Window<int, int, List>();   Before:   auto window = new Window<int, int, List>();   AEer:  
  • 6. Let  me  walk  you  through  new  changes   Imagine  a  piece  of  code  like  this:   std::vector<Window<int, int, List> >* vec = new std::vector<Window<int, int, List> >();! ! for (std::vector<Window<int, int, List> >::iterator it_begin = vec->begin(); ! it_begin != vec->end(); ++it_begin) {! // iterate! }   Was  replaced  with  this:   auto vec1 = new std::vector<Window<int, int, List> >();! ! for (auto win : *vec1) {! // iterate! }  
  • 7. Smart  Pointers   Window<int, int, List>* window = new Window<int, int, List>();   Not  as  easy  as  it  looks!     Who  should  delete  this  object?   std::shared_ptr<Window<int, int, List> > window(new Window<int, int, List>());   We  can  use  shared_ptr  or  unique_ptr   Or  beWer  this:   auto window = std::make_shared<Window<int, int, List> >();   std::unique_ptr! std::shared_ptr  
  • 8. From  the  list  of  41  entries  I  extracted  only  features  not  yet  implemented  _today_  in   Visual  C++  and  are  implemented  in  g++   Feature   Visual  C++   2013   g++  4.8.1   sizeof  on   non-­‐sta-c   data   members   without  an   instance   No   Yes   Changed   restric-ons   on  union   members     No   Yes   User  defined   literals   No   Yes   Encoding   support  in   literals   No   Yes   Feature   Visual  C++   2013   g++  4.8.1   Template   aliases   No   Yes   Defaulted   methods   No   Yes   Deleted   methods   No   Yes   Generalized   aWributes   No   Yes   New  built-­‐in   types   Par-al   Yes   Alignment   support   Par-al   Yes   Inline   namespaces   No   Yes  
  • 9. Feature   Visual  C++   2013   g++  4.8.1   Arbitrary   expressions  in   template   deduc-on   contexts   No   Yes   Non-­‐sta-c   data  member   ini-alizers   No   Yes   noexcept   No   Yes   constexpr   No   Yes   Thread  local   storage   Par-al   Yes   Inheri-ng   constructors   No   Yes   Rvalue   references  for   *this   No   Yes  
  • 10. C++  Template  Meta-­‐Programming   •  Compile-­‐-me  results   •  Can  be  used  in  gaming,  e.g.  calculate  gravity   equa-on  and  have  the  value  ready   •  Not  easy!   Typical  func-on  to  calculate  Fibonacci   int fibonacci(int n)! {! if (n <= 2) { " "! return 1;! } else {! return fibonacci(n - 1) + fibonacci(n - 2);! }! }  
  • 11. C++  Template  Meta-­‐Programming   template <int T> struct Fibonacci! {! enum { value = (Fibonacci<T - 1>::value + Fibonacci<T - 2>::value) };! };! ! template <> struct Fibonacci<0>! {! enum { value = 1 };! };! ! template <> struct Fibonacci<1>! {! enum { value = 1 };! };! ! template <> struct Fibonacci<2>! {! enum { value = 1 };! };  
  • 12. Generalized  constant  expressions   Bjarne  Stroustrup  is  not  good  with  words.  He  admiWed  it  himself!   All  he  means  is  this   constexpr int fibonacci (int n)! {! return (n <= 2 ? 1 : fibonacci(n - 1) + fibonacci(n - 2));! }   Calculates  the  Fibonacci  sequence  in  compile-­‐-me  so  the  result  is  already  there  to  be  used.   Supports  only  a  single  line  implementa-on.   And  this  is  missing  in  Visual  C++  compiler!  
  • 13. Variadic  Templates   •  C++  uses  variable  argument  list  (so  does  Java   and  C):   int avg( int n, ... )! {! va_list pVarArg;! va_start( pVarArg, n );! ! // ...! }   •  Now  we  use  similar  approach  with  templates   and  it’s  arguments   // usage! int i = avg(10, 10, 10, 10, 10);  
  • 14. Variadic  Templates   •  Why  we  need  them?   •  std::pair  pairs  two  items  together   •  std::tuple  pairs  zero  or  more  items  together   (feature  achieved  with  variadic  templates)   std::tuple<int, int, std::string> getWindowInformation(int id)! {! if (id == 0) return std::make_tuple(100, 100, "Settings");! if (id == 1) return std::make_tuple(800, 600, "Main Window");! if (id == 2) return std::make_tuple(800, 60, "Chat Window");! throw std::invalid_argument("id");! }   We  can  use  whatever  we  want!  
  • 15. Variadic  Templates   •  Usage   for (auto window : windows) {! auto win = getWindowInformation(window);! std::cout << "Window 0 - "! << "Width: " << std::get<0>(win) << ", "! << "Height: “ << std::get<1>(win) << ", "! << "Title: ” << std::get<2>(win) << 'n';! }  
  • 16. Variadic  Templates  basic   implementa-on   template<class... elements> class tuple;! ! // empty! template<> class tuple<> {};! ! template<class _class, class... elements>! class tuple<_class, elements...> : private tuple<elements...>! {! public:! _class _this;! };   Ellipsis  just  like  in  the  variable  argument  lists!  
  • 17. Cool  stuff  about  variadic  templates   •  This  is  how  they  can  be  used  (16  arguments):   •  In  the  beginning  in  Visual  C++  maximum  was  5   arguments  only!   std::tuple<int, int, int, int, int,! int, int, int, int, int,! int, int, int, int, int,! int, std::string> getWindowInformation(int id)! {! return std::make_tuple(100, 100, 100,! 100, 100, 100,! 100, 100, 100,! 100, 100, 100,! 100, 100, 100,! 100,"Settings");! }  
  • 18. A  comment  from  MicrosoE  kernel   developer  on  the  issue!   We  just  can't  be  fucked  to  implement  C11  support,  and  variadic   templates  were  just  too  hard  to  implement  in  a  year.  (But   ohmygosh  we  turned  "^"  into  a  reference-­‐counted  pointer   operator.  Oh,  and  what's  a  reference  cycle?)    ~  Anonymous   MicrosoE  Employee  on  Reddit  
  • 19. Lvalues  and  Rvalues   •  Lvalue  can  appear  on  both  leE  and  right  sides   of  the  assignment  operator   •  Rvalue  can  appear  only  on  the  right  side  of  an   assignment  operator   int i = 42;! i = 43; // lvalue! int* p = &i; // lvalue! ! int& atlas();! atlas() = 42; // lvalue! int* p1 = &atlas(); //lvalue   int stryder();! int j = 0;! j = stryder(); // rvalue! int* p2 = &stryder(); // fail! j = 42; // rvalue   Cannot  take  address  of  rvalue  reference  
  • 20. Move  seman-cs   Window<int, int, List> wnd();! Window<int, int, List> x;! // use x...! x = wnd();   Destroy  resource  held   by  x   Last  line  will   Copy  from  temporary   resource  returned  from   wnd()   Destroy  temporary   resource  and  release   the  memory  
  • 21. Move  Seman-cs   Original   Object   COPY   New   copied   object   Original   Object   MOVE   New   object   We  want  to  move!  Even  a  child  can  move  things  around!  
  • 22. How  the  object  assignment  operator   should  be  implemented?   // Classical implementation! Window& Window::operator=(Window const & rhs);! ! // Move semantics: exchange content between this and wnd! Window& Window::operator=(Window&& wnd) { "! "return *this;! }   // Another usage with std::move! std::string str = "Stand by for Titanfall!";! std::vector<std::string> v;! ! // Copy! v.push_back(str);! ! // Move! v.push_back(std::move(str));  
  • 23. Back  to  std::make_pair   // C++98! template <class T1, class T2> pair<T1,T2> make_pair (T1 x, T2 y);   // C++11! template <class T1, class T2> pair<V1,V2> make_pair (T1&& x, T2&& y);   What  is  the  difference?   Rvalue  references!  
  • 24. Back  to  std::make_pair   •  C++11  flag  was  set  on  Visual  C++  compiler   op-on   •  Code  worked  properly  on  g++   •  I  was  gelng  “You  cannot  bind  an  lvalue  to  an   rvalue”  error  message!   •  It  was  lacking  proper  overloaded  method  to   support  backward  compa-bility   Had  to  hack  my  way  into  MicrosoE  header  files  to  trick  it  to  compile!  
  • 25. Problem?   •  Worked  on  a  corporate   •  Bureaucracy  kills  the  mood   •  If  you  do  something  small  will  go  unno-ced   •  You  need  to  do  something  dras-c  to  get  no-ced   •  In  open  source  community  you  just  need  to  start   doing  it!   •  Everyone  will  appreciate  whatever  you  do!     Even  if  it’s  5%  speed  increase  or  a  -ny  feature  you  will  get  appreciated!  
  • 26. Another  comment  from  same  guy   There's  also  liPle  incenQve  to  create  changes  in  the  first  place.  On  linux-­‐ kernel,  if  you  improve  the  performance  of  directory  traversal  by  a   consistent  5%,  you're  praised  and  thanked.  Here,  if  you  do  that  and  you're   not  on  the  object  manager  team,  then  even  if  you  do  get  your  code  past  the   Ob  owners  and  into  the  tree,  your  own  management  doesn't  care.  ~   Anonymous  MicrosoE  Employee  
  • 27. Thank  you!   •  Unfortunately  the  post  was  deleted  from  Reddit   (yes  MicrosoE  reads  Reddit).   •  Fortunately  someone  copied  it  over  to  his  blog:   hPp://bit.ly/milot