<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.planetchili.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Albinopapa</id>
		<title>Chilipedia - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.planetchili.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Albinopapa"/>
		<link rel="alternate" type="text/html" href="https://wiki.planetchili.net/index.php/Special:Contributions/Albinopapa"/>
		<updated>2026-06-13T06:30:25Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.3</generator>

	<entry>
		<id>https://wiki.planetchili.net/index.php?title=Std::variant&amp;diff=1501</id>
		<title>Std::variant</title>
		<link rel="alternate" type="text/html" href="https://wiki.planetchili.net/index.php?title=Std::variant&amp;diff=1501"/>
				<updated>2018-10-17T19:28:55Z</updated>
		
		<summary type="html">&lt;p&gt;Albinopapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== What is &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt;? ==&lt;br /&gt;
In C++17, std::variant was introduced and is basically a strongly typed &amp;lt;code&amp;gt;union&amp;lt;/code&amp;gt;.  It allows you to specify a list of states that the &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt; can be in.  These states are actually types, such as &amp;lt;code&amp;gt;int, float, double, MyClass&amp;lt;/code&amp;gt;.  It can only be in one state at a time, so if you assign it an &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; on one line, then assign it a &amp;lt;code&amp;gt;float&amp;lt;/code&amp;gt; on another, the int is no long able to be retrieved.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to use &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt; ==&lt;br /&gt;
Std::variant has kind of a black-box approach in dealing with access to the data stored.  While this does allow for some optimizations to be made in the form of compile time knowledge for the compiler, it makes it non-trivial for the user to access.  Luckily, there are options, from safe but requires a bit of boiler-plate to not so safe but trivial.  Look at the examples below.&lt;br /&gt;
&lt;br /&gt;
First, the safe way.  There are a few versions that pretty much do the same thing.  Since the compiler knows the type stored in an &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt;, you can use the &amp;lt;code&amp;gt;std::visit&amp;lt;/code&amp;gt; function to have the compiler choose which function to handle the variant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
#include &amp;lt;variant&amp;gt;  // for std::variant, std::visit and an overload of std::get that works with std::variant&lt;br /&gt;
#include &amp;lt;iostream&amp;gt; // for std::cout&lt;br /&gt;
&lt;br /&gt;
void PrintNumber( const int _number )&lt;br /&gt;
{&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
}&lt;br /&gt;
void PrintNumber( const float _number )&lt;br /&gt;
{&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
}&lt;br /&gt;
void PrintNumber( const double _number )&lt;br /&gt;
{&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main( int ArgsC, char* ArgV[] )&lt;br /&gt;
{&lt;br /&gt;
     std::variant&amp;lt;int, float, double&amp;gt; number;&lt;br /&gt;
&lt;br /&gt;
     number = 42;  // number is now considered an int&lt;br /&gt;
     std::visit( &amp;amp;PrintNumber, number );  // The PrintNumber( int ) overload should be called&lt;br /&gt;
     &lt;br /&gt;
     number = 3.14159f;  // number is now considered a float&lt;br /&gt;
     std::visit( &amp;amp;PrintNumber, number );  // The PrintNumber( float ) overload should be called&lt;br /&gt;
&lt;br /&gt;
     number = 2.5  // number is now considered a double&lt;br /&gt;
     std::visit( &amp;amp;PrintNumber, number );  // The PrintNumber( double ) overload should be called&lt;br /&gt;
&lt;br /&gt;
     return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Version two using a function object as the 'visitor'.&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
#include &amp;lt;variant&amp;gt;  // for std::variant, std::visit and an overload of std::get that works with std::variant&lt;br /&gt;
#include &amp;lt;iostream&amp;gt; // for std::cout&lt;br /&gt;
&lt;br /&gt;
struct PrintNumber&lt;br /&gt;
{&lt;br /&gt;
     void operator()( const int _number )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
     void operator()( const float _number )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
     void operator()( const double _number )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main( int ArgsC, char* ArgV[] )&lt;br /&gt;
{&lt;br /&gt;
     std::variant&amp;lt;int, float, double&amp;gt; number;&lt;br /&gt;
&lt;br /&gt;
     number = 42;  // number is now considered an int&lt;br /&gt;
     std::visit( PrintNumber(), number );  // The PrintNumber::operator()( int ) overload should be called&lt;br /&gt;
     &lt;br /&gt;
     number = 3.14159f;  // number is now considered a float&lt;br /&gt;
     std::visit( PrintNumber(), number );  // The PrintNumber::operator()( float ) overload should be called&lt;br /&gt;
&lt;br /&gt;
     number = 2.5  // number is now considered a double&lt;br /&gt;
     std::visit( PrintNumber(), number );  // The PrintNumber::operator()( double ) overload should be called&lt;br /&gt;
&lt;br /&gt;
     return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Version 3 using lambdas for the 'visitor'&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
#include &amp;lt;variant&amp;gt;  // for std::variant, std::visit and an overload of std::get that works with std::variant&lt;br /&gt;
#include &amp;lt;iostream&amp;gt; // for std::cout&lt;br /&gt;
&lt;br /&gt;
int main( int ArgsC, char* ArgV[] )&lt;br /&gt;
{&lt;br /&gt;
     auto PrintNumber = []( auto _number )&lt;br /&gt;
          {&lt;br /&gt;
               using type = std::decay_t&amp;lt;decltype( _number )&amp;gt;;&lt;br /&gt;
               if constexpr( std::is_same_v&amp;lt;type, int&amp;gt; )&lt;br /&gt;
               {&lt;br /&gt;
                    std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
               }&lt;br /&gt;
               else if constexpr( std::is_same_v&amp;lt;type, float&amp;gt; )&lt;br /&gt;
               {&lt;br /&gt;
                    std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
               }&lt;br /&gt;
               else if constexpr( std::is_same_v&amp;lt;type, double&amp;gt; )&lt;br /&gt;
               {&lt;br /&gt;
                    std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
               }&lt;br /&gt;
          };&lt;br /&gt;
&lt;br /&gt;
     std::variant&amp;lt;int, float, double&amp;gt; number;&lt;br /&gt;
     &lt;br /&gt;
     number = 42;  // number is now considered an int&lt;br /&gt;
     std::visit( PrintNumber, number );  // The if constexpr( std::is_same_v&amp;lt;type, int&amp;gt; ) branch should be used&lt;br /&gt;
     &lt;br /&gt;
     number = 3.14159f;  // number is now considered a float&lt;br /&gt;
     std::visit( PrintNumber, number );  // The else if constexpr( std::is_same_v&amp;lt;type, float&amp;gt; ) branch should be used&lt;br /&gt;
&lt;br /&gt;
     number = 2.5  // number is now considered a double&lt;br /&gt;
     std::visit( PrintNumber, number );  // The else if constexpr( std::is_same_v&amp;lt;type, double&amp;gt; ) branch should be used&lt;br /&gt;
&lt;br /&gt;
     return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Do note that for each type in the variant, you must have a case handling the 'visit' or you'll get a compile time error, and it is nowhere near helpful in determining what case you missed, but not impossible.  &lt;br /&gt;
&lt;br /&gt;
Next is a safe way, but can be less efficient depending on your accuracy in knowing the type being stored.&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
#include &amp;lt;variant&amp;gt;  // for std::variant, std::visit and an overload of std::get that works with std::variant&lt;br /&gt;
#include &amp;lt;iostream&amp;gt; // for std::cout&lt;br /&gt;
&lt;br /&gt;
void PrintNumber( std::variant&amp;lt;int, float, double&amp;gt;&amp;amp; _number )&lt;br /&gt;
{&lt;br /&gt;
     if( const int* myInt = std::get_if&amp;lt;int&amp;gt;( &amp;amp;_number ); myInt != nullptr )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; *myInt &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
     else if( const float* myFloat = std::get_if&amp;lt;float&amp;gt;( &amp;amp;_number ); myFloat != nullptr )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; *myFloat &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
     else if( const double* myDouble = std::get_if&amp;lt;double&amp;gt;( &amp;amp;_number ); myDouble != nullptr )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; *myDouble &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main( int ArgsC, char* ArgV[] )&lt;br /&gt;
{&lt;br /&gt;
     std::variant&amp;lt;int, float, double&amp;gt; number;&lt;br /&gt;
     &lt;br /&gt;
     number = 42;  // number is now considered an int&lt;br /&gt;
     PrintNumber( number );&lt;br /&gt;
&lt;br /&gt;
     number = 3.14159f;  // number is now considered a float&lt;br /&gt;
     PrintNumber( number );&lt;br /&gt;
&lt;br /&gt;
     number = 2.5  // number is now considered a double&lt;br /&gt;
     PrintNumber( number );&lt;br /&gt;
&lt;br /&gt;
     return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Unlike &amp;lt;code&amp;gt;std::tuple&amp;lt;/code&amp;gt;, variants cannot hold multiples of the same type.  Each type in the template parameter list must be unique.&lt;br /&gt;
&lt;br /&gt;
Finally, the unsafe way.&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
#include &amp;lt;variant&amp;gt;  // for std::variant, std::visit and an overload of std::get that works with std::variant&lt;br /&gt;
#include &amp;lt;iostream&amp;gt; // for std::cout&lt;br /&gt;
&lt;br /&gt;
int main( int ArgsC, char* ArgV[] )&lt;br /&gt;
{&lt;br /&gt;
     std::variant&amp;lt;int, float, double&amp;gt; number;&lt;br /&gt;
     &lt;br /&gt;
     number = 42;  // number is now considered an int&lt;br /&gt;
     int&amp;amp; myInt = std::get&amp;lt;int&amp;gt;( number );&lt;br /&gt;
     myInt = 69;&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; myInt &amp;lt;&amp;lt; '\n';&lt;br /&gt;
&lt;br /&gt;
     number = 3.14159f;  // number is now considered a float&lt;br /&gt;
     float&amp;amp; myFloat = std::get&amp;lt;float&amp;gt;( number );&lt;br /&gt;
     myFloat = 0.707f&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; myFloat &amp;lt;&amp;lt; '\n';&lt;br /&gt;
&lt;br /&gt;
     number = 2.5  // number is now considered a double&lt;br /&gt;
     double&amp;amp; myDouble = std::get&amp;lt;double&amp;gt;( number );&lt;br /&gt;
     myDouble = 419.999999999&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; myDouble &amp;lt;&amp;lt; '\n';&lt;br /&gt;
&lt;br /&gt;
     return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This example, made it safe by using the retrieved type directly after assignment, but after that, the user may not know what state the variant is in and calling &amp;lt;code&amp;gt;std::get&amp;lt;/code&amp;gt; on the wrong type will throw a &amp;lt;code&amp;gt;std::bad_variant_access&amp;lt;/code&amp;gt; exception.  The above method of assigning the value, then retrieving a reference to the underlying type allows you to modify the state of the object from within without having to setup visitors just for initialization.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements for &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt; ==&lt;br /&gt;
* The list of types must be unique, a variant cannot be declared with two ints and a float&lt;br /&gt;
* The types in a variant must be default constructable or the use of &amp;lt;code&amp;gt;std::monostate&amp;lt;/code&amp;gt; can be set as the first type in the parameter list&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
     std::variant&amp;lt;std::monostate, MyComplexClass, MyComplexClass1&amp;gt; data;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* Types in &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt; parameter list, must not be forward declared types.  The compiler must be able to determine whether or not the types in the list are default constructable before instantiating a variant of those types.&lt;br /&gt;
* The list may not contain reference types: int&amp;amp;, const MyCompolexClass&amp;amp;&lt;/div&gt;</summary>
		<author><name>Albinopapa</name></author>	</entry>

	<entry>
		<id>https://wiki.planetchili.net/index.php?title=Std::variant&amp;diff=1500</id>
		<title>Std::variant</title>
		<link rel="alternate" type="text/html" href="https://wiki.planetchili.net/index.php?title=Std::variant&amp;diff=1500"/>
				<updated>2018-10-17T18:59:15Z</updated>
		
		<summary type="html">&lt;p&gt;Albinopapa: Created page with &amp;quot; == What is &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt;? == In C++17, std::variant was introduced and is basically a strongly typed &amp;lt;code&amp;gt;union&amp;lt;/code&amp;gt;.  It allows you to specify a list of state...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
== What is &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt;? ==&lt;br /&gt;
In C++17, std::variant was introduced and is basically a strongly typed &amp;lt;code&amp;gt;union&amp;lt;/code&amp;gt;.  It allows you to specify a list of states that the &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt; can be in.  These states are actually types, such as &amp;lt;code&amp;gt;int, float, double, MyClass&amp;lt;/code&amp;gt;.  It can only be in one state at a time, so if you assign it an &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; on one line, then assign it a &amp;lt;code&amp;gt;float&amp;lt;/code&amp;gt; on another, the int is no long able to be retrieved.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to use &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt; ==&lt;br /&gt;
Std::variant has kind of a black-box approach in dealing with access to the data stored.  While this does allow for some optimizations to be made in the form of compile time knowledge for the compiler, it makes it non-trivial for the user to access.  Luckily, there are options, from safe but requires a bit of boiler-plate to not so safe but trivial.  Look at the examples below.&lt;br /&gt;
&lt;br /&gt;
First, the safe way.  There are a few versions that pretty much do the same thing.  Since the compiler knows the type stored in an &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt;, you can use the &amp;lt;code&amp;gt;std::visit&amp;lt;/code&amp;gt; function to have the compiler choose which function to handle the variant.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#include &amp;lt;variant&amp;gt;  // for std::variant, std::visit and an overload of std::get that works with std::variant&lt;br /&gt;
#include &amp;lt;iostream&amp;gt; // for std::cout&lt;br /&gt;
&lt;br /&gt;
void PrintNumber( const int _number )&lt;br /&gt;
{&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
}&lt;br /&gt;
void PrintNumber( const float _number )&lt;br /&gt;
{&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
}&lt;br /&gt;
void PrintNumber( const double _number )&lt;br /&gt;
{&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main( int ArgsC, char* ArgV[] )&lt;br /&gt;
{&lt;br /&gt;
     std::variant&amp;lt;int, float, double&amp;gt; number;&lt;br /&gt;
&lt;br /&gt;
     number = 42;  // number is now considered an int&lt;br /&gt;
     std::visit( &amp;amp;PrintNumber, number );  // The PrintNumber( int ) overload should be called&lt;br /&gt;
     &lt;br /&gt;
     number = 3.14159f;  // number is now considered a float&lt;br /&gt;
     std::visit( &amp;amp;PrintNumber, number );  // The PrintNumber( float ) overload should be called&lt;br /&gt;
&lt;br /&gt;
     number = 2.5  // number is now considered a double&lt;br /&gt;
     std::visit( &amp;amp;PrintNumber, number );  // The PrintNumber( double ) overload should be called&lt;br /&gt;
&lt;br /&gt;
     return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Version two using a function object as the 'visitor'.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#include &amp;lt;variant&amp;gt;  // for std::variant, std::visit and an overload of std::get that works with std::variant&lt;br /&gt;
#include &amp;lt;iostream&amp;gt; // for std::cout&lt;br /&gt;
&lt;br /&gt;
struct PrintNumber&lt;br /&gt;
{&lt;br /&gt;
     void operator()( const int _number )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
     void operator()( const float _number )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
     void operator()( const double _number )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
int main( int ArgsC, char* ArgV[] )&lt;br /&gt;
{&lt;br /&gt;
     std::variant&amp;lt;int, float, double&amp;gt; number;&lt;br /&gt;
&lt;br /&gt;
     number = 42;  // number is now considered an int&lt;br /&gt;
     std::visit( PrintNumber(), number );  // The PrintNumber::operator()( int ) overload should be called&lt;br /&gt;
     &lt;br /&gt;
     number = 3.14159f;  // number is now considered a float&lt;br /&gt;
     std::visit( PrintNumber(), number );  // The PrintNumber::operator()( float ) overload should be called&lt;br /&gt;
&lt;br /&gt;
     number = 2.5  // number is now considered a double&lt;br /&gt;
     std::visit( PrintNumber(), number );  // The PrintNumber::operator()( double ) overload should be called&lt;br /&gt;
&lt;br /&gt;
     return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Version 3 using lambdas for the 'visitor'&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#include &amp;lt;variant&amp;gt;  // for std::variant, std::visit and an overload of std::get that works with std::variant&lt;br /&gt;
#include &amp;lt;iostream&amp;gt; // for std::cout&lt;br /&gt;
&lt;br /&gt;
int main( int ArgsC, char* ArgV[] )&lt;br /&gt;
{&lt;br /&gt;
     auto PrintNumber = []( auto _number )&lt;br /&gt;
          {&lt;br /&gt;
               using type = std::decay_t&amp;lt;decltype( _number )&amp;gt;;&lt;br /&gt;
               if constexpr( std::is_same_v&amp;lt;type, int&amp;gt; )&lt;br /&gt;
               {&lt;br /&gt;
                    std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
               }&lt;br /&gt;
               else if constexpr( std::is_same_v&amp;lt;type, float&amp;gt; )&lt;br /&gt;
               {&lt;br /&gt;
                    std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
               }&lt;br /&gt;
               else if constexpr( std::is_same_v&amp;lt;type, double&amp;gt; )&lt;br /&gt;
               {&lt;br /&gt;
                    std::cout &amp;lt;&amp;lt; _number &amp;lt;&amp;lt; '\n';&lt;br /&gt;
               }&lt;br /&gt;
          };&lt;br /&gt;
&lt;br /&gt;
     std::variant&amp;lt;int, float, double&amp;gt; number;&lt;br /&gt;
     &lt;br /&gt;
     number = 42;  // number is now considered an int&lt;br /&gt;
     std::visit( PrintNumber, number );  // The if constexpr( std::is_same_v&amp;lt;type, int&amp;gt; ) branch should be used&lt;br /&gt;
     &lt;br /&gt;
     number = 3.14159f;  // number is now considered a float&lt;br /&gt;
     std::visit( PrintNumber, number );  // The else if constexpr( std::is_same_v&amp;lt;type, float&amp;gt; ) branch should be used&lt;br /&gt;
&lt;br /&gt;
     number = 2.5  // number is now considered a double&lt;br /&gt;
     std::visit( PrintNumber, number );  // The else if constexpr( std::is_same_v&amp;lt;type, double&amp;gt; ) branch should be used&lt;br /&gt;
&lt;br /&gt;
     return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Do note that for each type in the variant, you must have a case handling the 'visit' or you'll get a compile time error, and it is nowhere near helpful in determining what case you missed, but not impossible.  &lt;br /&gt;
&lt;br /&gt;
Next is a safe way, but can be less efficient depending on your accuracy in knowing the type being stored.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#include &amp;lt;variant&amp;gt;  // for std::variant, std::visit and an overload of std::get that works with std::variant&lt;br /&gt;
#include &amp;lt;iostream&amp;gt; // for std::cout&lt;br /&gt;
&lt;br /&gt;
void PrintNumber( std::variant&amp;lt;int, float, double&amp;gt;&amp;amp; _number )&lt;br /&gt;
{&lt;br /&gt;
     if( const int* myInt = std::get_if&amp;lt;int&amp;gt;( &amp;amp;_number ); myInt != nullptr )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; *myInt &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
     else if( const float* myFloat = std::get_if&amp;lt;float&amp;gt;( &amp;amp;_number ); myFloat != nullptr )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; *myFloat &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
     else if( const double* myDouble = std::get_if&amp;lt;double&amp;gt;( &amp;amp;_number ); myDouble != nullptr )&lt;br /&gt;
     {&lt;br /&gt;
          std::cout &amp;lt;&amp;lt; *myDouble &amp;lt;&amp;lt; '\n';&lt;br /&gt;
     }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int main( int ArgsC, char* ArgV[] )&lt;br /&gt;
{&lt;br /&gt;
     std::variant&amp;lt;int, float, double&amp;gt; number;&lt;br /&gt;
     &lt;br /&gt;
     number = 42;  // number is now considered an int&lt;br /&gt;
     PrintNumber( number );&lt;br /&gt;
&lt;br /&gt;
     number = 3.14159f;  // number is now considered a float&lt;br /&gt;
     PrintNumber( number );&lt;br /&gt;
&lt;br /&gt;
     number = 2.5  // number is now considered a double&lt;br /&gt;
     PrintNumber( number );&lt;br /&gt;
&lt;br /&gt;
     return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Unlike &amp;lt;code&amp;gt;std::tuple&amp;lt;/code&amp;gt;, variants cannot hold multiples of the same type.  Each type in the template parameter list must be unique.&lt;br /&gt;
&lt;br /&gt;
Finally, the unsafe way.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
#include &amp;lt;variant&amp;gt;  // for std::variant, std::visit and an overload of std::get that works with std::variant&lt;br /&gt;
#include &amp;lt;iostream&amp;gt; // for std::cout&lt;br /&gt;
&lt;br /&gt;
int main( int ArgsC, char* ArgV[] )&lt;br /&gt;
{&lt;br /&gt;
     std::variant&amp;lt;int, float, double&amp;gt; number;&lt;br /&gt;
     &lt;br /&gt;
     number = 42;  // number is now considered an int&lt;br /&gt;
     int&amp;amp; myInt = std::get&amp;lt;int&amp;gt;( number );&lt;br /&gt;
     myInt = 69;&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; myInt &amp;lt;&amp;lt; '\n';&lt;br /&gt;
&lt;br /&gt;
     number = 3.14159f;  // number is now considered a float&lt;br /&gt;
     float&amp;amp; myFloat = std::get&amp;lt;float&amp;gt;( number );&lt;br /&gt;
     myFloat = 0.707f&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; myFloat &amp;lt;&amp;lt; '\n';&lt;br /&gt;
&lt;br /&gt;
     number = 2.5  // number is now considered a double&lt;br /&gt;
     double&amp;amp; myDouble = std::get&amp;lt;double&amp;gt;( number );&lt;br /&gt;
     myDouble = 419.999999999&lt;br /&gt;
     std::cout &amp;lt;&amp;lt; myDouble &amp;lt;&amp;lt; '\n';&lt;br /&gt;
&lt;br /&gt;
     return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This example, made it safe by using the retrieved type directly after assignment, but after that, the user may not know what state the variant is in and calling &amp;lt;code&amp;gt;std::get&amp;lt;/code&amp;gt; on the wrong type will throw a &amp;lt;code&amp;gt;std::bad_variant_access&amp;lt;/code&amp;gt; exception.  The above method of assigning the value, then retrieving a reference to the underlying type allows you to modify the state of the object from within without having to setup visitors just for initialization.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Requirements for &amp;lt;code&amp;gt;std::variant&amp;lt;/code&amp;gt; ==&lt;/div&gt;</summary>
		<author><name>Albinopapa</name></author>	</entry>

	<entry>
		<id>https://wiki.planetchili.net/index.php?title=If_Statement&amp;diff=1499</id>
		<title>If Statement</title>
		<link rel="alternate" type="text/html" href="https://wiki.planetchili.net/index.php?title=If_Statement&amp;diff=1499"/>
				<updated>2018-10-17T17:41:03Z</updated>
		
		<summary type="html">&lt;p&gt;Albinopapa: /* What's really going on here tho */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If statements are a way to make decisions in your program. e.g., &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; the player presses the space bar, make the player jump, or &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; health is 0, end the game. &lt;br /&gt;
&lt;br /&gt;
== Using If Statements ==&lt;br /&gt;
=== Basics ===&lt;br /&gt;
When a decision is made at an if statement in your program, two things happen:&lt;br /&gt;
# A condition is evaluated&lt;br /&gt;
# A set of instructions (code) is executed (or skipped) based on the above condition&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
if(condition == true)&lt;br /&gt;
{&lt;br /&gt;
    // Do something&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We use the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; keyword followed by opening and closing parentheses &amp;lt;code&amp;gt;()&amp;lt;/code&amp;gt; which contain the condition we want to evaluate. The condition is followed by a block of code (surrounded by braces &amp;lt;code&amp;gt;{}&amp;lt;/code&amp;gt;) that is executed if that condition evaluates to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;. &lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
int PlayerHealth = 50;&lt;br /&gt;
if(PlayerHealth &amp;gt; 0)        // Check the condition, if it is evaluated to be true, the code inside the {} is executed &lt;br /&gt;
{&lt;br /&gt;
    // If true, execute some code &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Here we check if the player is still alive, and if so we do some shit. &lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt; can also be used directly as a condition. The code above can be written as: &lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
int playerHealth = 50;&lt;br /&gt;
bool isAlive = (playerHealth &amp;gt; 0);&lt;br /&gt;
if(isAlive)&lt;br /&gt;
{&lt;br /&gt;
    // Do stuff &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
An &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; statement is controlled by the value inside the parentheses &amp;lt;code&amp;gt;()&amp;lt;/code&amp;gt;--only when it is true is your code executed. &lt;br /&gt;
=== Else Statement ===&lt;br /&gt;
But what if you want something to happen only if the condition is ''not'' true? Then you stick the &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; keyword after the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; code block: &lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
int playerHealth = 0; &lt;br /&gt;
bool isAlive = (playerHealth &amp;gt; 0);&lt;br /&gt;
if(isAlive) // Evaluated to false&lt;br /&gt;
{&lt;br /&gt;
    // Will not execute&lt;br /&gt;
}&lt;br /&gt;
else // Will execute&lt;br /&gt;
{&lt;br /&gt;
    // You dead &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Nesting ===&lt;br /&gt;
You can even stick if conditions inside if conditions, this is called 'nesting': &lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
std::string Weapon = &amp;quot;Gun&amp;quot;; &lt;br /&gt;
if(Weapon == &amp;quot;Gun&amp;quot;) &lt;br /&gt;
{&lt;br /&gt;
    // Pew Pew Pew &lt;br /&gt;
}&lt;br /&gt;
else &lt;br /&gt;
{&lt;br /&gt;
    if(condition)&lt;br /&gt;
    {&lt;br /&gt;
        // do some stuff &lt;br /&gt;
    }&lt;br /&gt;
    else&lt;br /&gt;
    {&lt;br /&gt;
        // run this block of code&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
=== Chaining ===&lt;br /&gt;
You can also chain multiple &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; statements together using the &amp;lt;code&amp;gt;else&amp;lt;/code&amp;gt; keyword. The code above can be simplified and written as: &lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
std::string Weapon = &amp;quot;Gun&amp;quot;; &lt;br /&gt;
if(Weapon == &amp;quot;Gun&amp;quot;) // Evaluate Condition &lt;br /&gt;
{&lt;br /&gt;
    // Pew Pew Pew &lt;br /&gt;
}&lt;br /&gt;
else if(condition) // *Only* if the first if condition fails, evaluate this, otherwise skip &lt;br /&gt;
{&lt;br /&gt;
  // do some stuff   &lt;br /&gt;
}&lt;br /&gt;
else &lt;br /&gt;
{&lt;br /&gt;
    // run this block of code if everything else fails &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt; &lt;br /&gt;
C++ gives us the &amp;lt;code&amp;gt;else if&amp;lt;/code&amp;gt; keyword that allows us to keep checking for different conditions. You can use as many &amp;lt;code&amp;gt;else if&amp;lt;/code&amp;gt; as you want, but remember it will only run if the condition before it has failed.&lt;br /&gt;
&lt;br /&gt;
== What's really going on here tho == &lt;br /&gt;
When you run your program all your C++ code is converted to machine code all of which is loaded into memory. When you use an &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; statement, you're effectively telling your computer - if this condition is true then jump to another location in memory, but if it is false, just continue executing the next instruction in memory.&lt;br /&gt;
&lt;br /&gt;
If you care about performance, you should know that this jumping around (called branching) can carry some overhead. The CPU has highly specialized circuits that attempt to predict which branch of code the execution will follow. For many situations these circuits are very successful in making the predictions, and thus the cost of branching is effectively zero. But in some situations it is very difficult for the branch predictor to accurately predict which branch is going to be taken, and in these situations highly optimized code tries to avoid if statements in clever ways.&lt;br /&gt;
&lt;br /&gt;
If you are just starting out, you don't need to worry about all this.&lt;br /&gt;
&lt;br /&gt;
== Planet Chili Tutorial Video == &lt;br /&gt;
* [[Beginner C++ Game Programming Tutorial 3]]&lt;br /&gt;
&lt;br /&gt;
== Other Tutorials == &lt;br /&gt;
* http://www.cplusplus.com/doc/tutorial/control/&lt;br /&gt;
&lt;br /&gt;
* https://www.tutorialspoint.com/cplusplus/cpp_if_else_statement.htm&lt;br /&gt;
&lt;br /&gt;
* https://www.cprogramming.com/tutorial/lesson2.html&lt;br /&gt;
&lt;br /&gt;
* https://www.youtube.com/watch?v=qEgCT87KOfc&amp;amp;t=904s&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Beginner_C++_Game_Programming_Series#Topics_Covered|List of Beginner C++ Topics]]&lt;/div&gt;</summary>
		<author><name>Albinopapa</name></author>	</entry>

	<entry>
		<id>https://wiki.planetchili.net/index.php?title=Keyboard_(Chili_Framework)&amp;diff=1042</id>
		<title>Keyboard (Chili Framework)</title>
		<link rel="alternate" type="text/html" href="https://wiki.planetchili.net/index.php?title=Keyboard_(Chili_Framework)&amp;diff=1042"/>
				<updated>2017-06-27T09:26:47Z</updated>
		
		<summary type="html">&lt;p&gt;Albinopapa: /* Virtual Key Codes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;With &amp;lt;code&amp;gt;Keyboard&amp;lt;/code&amp;gt;, you can get the current state of depressed keys (have a Valium mate), and you can pop key press and release events out of an &amp;lt;code&amp;gt;Event&amp;lt;/code&amp;gt; queue contained in &amp;lt;code&amp;gt;Keyboard&amp;lt;/code&amp;gt;. You can also turn autorepeat on/off. Whopee. (''Note: the ''&amp;lt;code&amp;gt;kbd&amp;lt;/code&amp;gt;'' object lives in ''&amp;lt;code&amp;gt;MainWindow&amp;lt;/code&amp;gt;'''s belly.'')&lt;br /&gt;
&lt;br /&gt;
== Example of Use ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line=&amp;quot;1&amp;quot; &amp;gt;&lt;br /&gt;
// how to respond to key release event&lt;br /&gt;
&lt;br /&gt;
// keep processing events as long as queue contains them&lt;br /&gt;
while( !wnd.kbd.IsEmpty() )&lt;br /&gt;
{&lt;br /&gt;
	// get an event from the queue&lt;br /&gt;
	const Keyboard::Event e = wnd.kbd.ReadKey();&lt;br /&gt;
	// check if it is a release event&lt;br /&gt;
	if( e.IsRelease() )&lt;br /&gt;
	{&lt;br /&gt;
		// check if the event was for the space key&lt;br /&gt;
		if( e.GetCode() == VK_SPACE )&lt;br /&gt;
		{&lt;br /&gt;
			// respond to space key release event&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Members ==&lt;br /&gt;
=== KeyIsPressed ===&lt;br /&gt;
&amp;lt;code&amp;gt;bool Keyboard::KeyIsPressed( unsigned char keycode ) const&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Checks to see if a specific key is currently in the pressed state. The function parameter is the [[#Virtual Key Codes|virtual key code]] of the key that you want to check.&lt;br /&gt;
&lt;br /&gt;
=== ReadKey ===&lt;br /&gt;
&amp;lt;code&amp;gt;Event Keyboard::ReadKey()&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Pull a fresh &amp;lt;code&amp;gt;[[#Event|Event]]&amp;lt;/code&amp;gt; object out of the key press/release event queue. Erases an event from the queue and returns a copy if there is a key press event in the queue. Returns an invalid Event object if the queue is empty.&lt;br /&gt;
&lt;br /&gt;
=== KeyIsEmpty ===&lt;br /&gt;
&amp;lt;code&amp;gt;bool Keyboard::KeyIsEmpty() const&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the key event queue is empty.&lt;br /&gt;
&lt;br /&gt;
=== ReadChar ===&lt;br /&gt;
&amp;lt;code&amp;gt;char Keyboard::ReadChar()&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Pull a fresh character off of the character queue. Returns a &amp;lt;code&amp;gt;'\0'&amp;lt;/code&amp;gt; (null) character if the queue is empty. See also: [[#ReadKey vs. ReadChar|ReadKey vs. ReadChar]].&lt;br /&gt;
&lt;br /&gt;
=== CharIsEmpty ===&lt;br /&gt;
&amp;lt;code&amp;gt;bool Keyboard::CharIsEmpty() const&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the character queue is empty.&lt;br /&gt;
&lt;br /&gt;
=== Buffer Flushing Bullshit ===&lt;br /&gt;
&amp;lt;code&amp;gt;void Keyboard::FlushKey()&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;void Keyboard::FlushChar()&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;void Keyboard::Flush()&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
These functions empty the respective queues. Flush() empties both in one fell swoop. It's like taking a pee and a poo at the same time.&lt;br /&gt;
&lt;br /&gt;
=== Autorepeat Bullshit ===&lt;br /&gt;
&amp;lt;code&amp;gt;void Keyboard::EnableAutorepeat()&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;void Keyboard::DisableAutorepeat()&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;bool Keyboard::AutorepeatIsEnabled() const&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
If you hhhhhhhhhhhhhhhhhold a key down for a while, it will start machine gunning events and characters into your queues like a motherfucker. You can disable that if it pisses you off.&lt;br /&gt;
&lt;br /&gt;
== Event ==&lt;br /&gt;
&amp;lt;code&amp;gt;class Keyboard::Event&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Key press and release events are held in a queue in &amp;lt;code&amp;gt;Keyboard&amp;lt;/code&amp;gt; in the order they occurred. These events are modeled with their own class because they're precious fucking little snowflakes. They store the type of event (press or release) and the [[#Virtual Key Codes|virtual key code]] of the associated key. You pull them out of the buffer with &amp;lt;code&amp;gt;Keyboard::ReadKey()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== IsPress ===&lt;br /&gt;
&amp;lt;code&amp;gt;bool Keyboard::Event::IsPress() const&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the event is a press event.&lt;br /&gt;
&lt;br /&gt;
=== IsRelease ===&lt;br /&gt;
&amp;lt;code&amp;gt;bool Keyboard::Event::IsRelease() const&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the event is a release event.&lt;br /&gt;
&lt;br /&gt;
=== IsValid ===&lt;br /&gt;
&amp;lt;code&amp;gt;bool Keyboard::Event::IsValid() const&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Returns &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the event is a valid event (reading from an empty buffer will return an invalid event object).&lt;br /&gt;
&lt;br /&gt;
=== GetCode ===&lt;br /&gt;
&amp;lt;code&amp;gt;char Keyboard::Event::GetCode() const&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gets the virtual key code of the key associated with the &amp;lt;code&amp;gt;Event&amp;lt;/code&amp;gt; object.&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ==&lt;br /&gt;
=== Virtual Key Codes ===&lt;br /&gt;
The virtual key code for a standard alphanumeric key is just the &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; literal (capital if alphabetic), e.g. &amp;lt;code&amp;gt;'A'&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;'9'&amp;lt;/code&amp;gt;. Virtual key codes for other keys are defined with &amp;lt;code&amp;gt;#define&amp;lt;/code&amp;gt; macros included with &amp;lt;code&amp;gt;Windows.h&amp;lt;/code&amp;gt;. Some common ones are:&lt;br /&gt;
* &amp;lt;code&amp;gt;VK_SPACE&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;VK_SHIFT&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;VK_RETURN&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;VK_ESCAPE&amp;lt;/code&amp;gt;&lt;br /&gt;
See the Microsoft [https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx documentation] for the full list of virtual key codes defined in the Windows headers.&lt;br /&gt;
&lt;br /&gt;
=== ReadKey vs. ReadChar ===&lt;br /&gt;
There are two main differences between the events read with &amp;lt;code&amp;gt;ReadKey()&amp;lt;/code&amp;gt; and the &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; values read with &amp;lt;code&amp;gt;ReadChar()&amp;lt;/code&amp;gt;:&lt;br /&gt;
# Each key press and release sequence puts two events (press event and release event) into the &amp;lt;code&amp;gt;ReadKey()&amp;lt;/code&amp;gt; queue, but the same sequence only puts one &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; value into the &amp;lt;code&amp;gt;ReadChar()&amp;lt;/code&amp;gt; queue.&lt;br /&gt;
# The &amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; values read with &amp;lt;code&amp;gt;ReadChar()&amp;lt;/code&amp;gt; have the shift modifier applied to them, whereas those read by &amp;lt;code&amp;gt;ReadKey()&amp;lt;/code&amp;gt; are just the raw virtual key codes. For example, pressing the 'A' key puts &amp;lt;code&amp;gt;'a'&amp;lt;/code&amp;gt; into the &amp;lt;code&amp;gt;ReadChar()&amp;lt;/code&amp;gt; queue when the shift key is not pressed and &amp;lt;code&amp;gt;'A'&amp;lt;/code&amp;gt; when it is pressed, but the virtual key code in either case is &amp;lt;code&amp;gt;'A'&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;ReadKey()&amp;lt;/code&amp;gt;.&lt;br /&gt;
In general, you should use &amp;lt;code&amp;gt;ReadKey()&amp;lt;/code&amp;gt; for controlling shit and &amp;lt;code&amp;gt;ReadChar()&amp;lt;/code&amp;gt; for text input.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* The [[Chili Framework]]&lt;/div&gt;</summary>
		<author><name>Albinopapa</name></author>	</entry>

	<entry>
		<id>https://wiki.planetchili.net/index.php?title=Variable&amp;diff=555</id>
		<title>Variable</title>
		<link rel="alternate" type="text/html" href="https://wiki.planetchili.net/index.php?title=Variable&amp;diff=555"/>
				<updated>2016-08-30T23:00:43Z</updated>
		
		<summary type="html">&lt;p&gt;Albinopapa: /* Variable Types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Variables are like little boxes to store data in and read data from, typically numbers. What's in the box?!&lt;br /&gt;
&lt;br /&gt;
== How to Declare a Variable ==&lt;br /&gt;
You declare/create a variable by stating its type and then stating its name: &amp;lt;code&amp;gt;int myVar;&amp;lt;/code&amp;gt;. You can also give an initial value for the variable during creation using the assignment operator: &amp;lt;code&amp;gt;int myVar = 69;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Variable Names ==&lt;br /&gt;
Variables names (the same as any other type of user-defined symbol) can contain any number, letter, and the underscore character. They cannot start with a number. Case matters (&amp;lt;code&amp;gt;_DirtayBoi69&amp;lt;/code&amp;gt; is not the same symbol as &amp;lt;code&amp;gt;_dirtayboi69&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
== Variable Types ==&lt;br /&gt;
=== Integral types ===&lt;br /&gt;
Integral types are variables that store integers.  There are signed and unsigned versions of each integral type and the built-in or simple types are char, short, int/long, and long long/uint64_t.  Generally, for the signed versions, you do not have to specify signed, but for unsigned versions; unsigned char, unsigned short, unsigned int, unsigned long long, you do have to specify.  Unsigned integrals are integers that don't have negative numbers, they go from 0 to double + 1 their signed counterparts in the positive direction.&lt;br /&gt;
&lt;br /&gt;
As an example, signed char goes from -128 to 127 whereas unsigned char goes from 0 to 255.&lt;br /&gt;
=== char ===&lt;br /&gt;
&amp;lt;code&amp;gt;char&amp;lt;/code&amp;gt; variables store an integer ranging from -128 to 127.  They occupy 1 byte of memory and are most commonly used for narrow text/string manipulation.  &lt;br /&gt;
=== short===&lt;br /&gt;
&amp;lt;code&amp;gt;short&amp;lt;/code&amp;gt; variables store an integer ranging from -32768 to 32767.  They occupy 2 bytes of memory.  An alias for short is wchar_t and is used for wide character text and strings used to extend support for languages with more characters than the char range can handle.&lt;br /&gt;
=== long long ===&lt;br /&gt;
&amp;lt;code&amp;gt;long long&amp;lt;/code&amp;gt; variables store an integer ranging from –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.  They occupy 8 bytes in memory.  The type long long can also be referred to as int64_t because it is 64 bits long.&lt;br /&gt;
=== int ===&lt;br /&gt;
&amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; variables store an integer (non-fractional number) ranging from -2147483648 to 2147483647. They occupy 4 bytes of memory.&lt;br /&gt;
=== bool ===&lt;br /&gt;
&amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt; variables store a Boolean logic value (true or false). They occupy 4 bytes of memory. The &amp;lt;code&amp;gt;bool&amp;lt;/code&amp;gt; type is used to control the operation of flow control statements, such as the &amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt; statement.&lt;br /&gt;
&lt;br /&gt;
== The const Specifier ==&lt;br /&gt;
You can specify that a variable's value cannot be changed by declaring it like this: &amp;lt;code&amp;gt;const int blazeItFgt = 420;&amp;lt;/code&amp;gt;. Doing so can protect your code from unintentional bugs and is generally considered a fucking good practice called 'const correctness'. Note that when you declare a variable as &amp;lt;code&amp;gt;const&amp;lt;/code&amp;gt;, you need to initialize it during creation because you cannot assign to it afterwards.&lt;/div&gt;</summary>
		<author><name>Albinopapa</name></author>	</entry>

	<entry>
		<id>https://wiki.planetchili.net/index.php?title=Function&amp;diff=554</id>
		<title>Function</title>
		<link rel="alternate" type="text/html" href="https://wiki.planetchili.net/index.php?title=Function&amp;diff=554"/>
				<updated>2016-08-30T22:40:15Z</updated>
		
		<summary type="html">&lt;p&gt;Albinopapa: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A function is a grouping of code that you can invoke or 'call' from one or more points in your program. You can even call a function from itself (motherfucking funception)!&lt;br /&gt;
&lt;br /&gt;
== Function Calls ==&lt;br /&gt;
A function call in C++ generally looks something like this &amp;lt;code&amp;gt;obj.MyFunction( param1,param2 )&amp;lt;/code&amp;gt;. It consists of the function name (&amp;lt;code&amp;gt;Myfunction&amp;lt;/code&amp;gt; in the example above) followed by parentheses () which surround parameters separated by commas (,). To call a member function of an object, you first type the object name, then a period '.', and then the function name (e.g. &amp;lt;code&amp;gt;obj.&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
The function parameters are used to control the behavior of the function. A function can have zero or more of these. A function can also return a value, which can be used in other operations. If a function does not return a value, its return type is &amp;lt;code&amp;gt;void&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Declaring and Defining Functions ==&lt;br /&gt;
Declaring a function is pretty straight forward as described above.  You have the three parts; the return type, the name, the parameter list.  Functions can be declared as global functions or member functions.  Global functions are functions that do not belong to a class or struct, which would be called member functions.  You can declare a global function in the header file (.h) or in the source file (.cpp).&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
A global function that returns nothing and doesn't take any parameters.&lt;br /&gt;
 void DoSomething();&lt;br /&gt;
&lt;br /&gt;
A global function that returns nothing and takes two parameters.&lt;br /&gt;
 void PrintAandB(int A, int B);&lt;br /&gt;
&lt;br /&gt;
A global function that returns an int, and takes two int parameters.&lt;br /&gt;
 int AddThese(int A, int B);&lt;br /&gt;
&lt;br /&gt;
A member function is declared in the same manner, the only difference is they are declared inside the class declaration.&lt;br /&gt;
&lt;br /&gt;
 class MyClass&lt;br /&gt;
 {&lt;br /&gt;
     void DoSomething();&lt;br /&gt;
     void Print(int A, int B);&lt;br /&gt;
     int AddThese(int A, int B);&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
Defining functions is handled differently depending on where you define them and whether they are global or member functions.  A functions can be declared and defined in the same place.  If a global function is declared and defined in the header file, it must be preceded with the word inline, letting the compiler know that you are defining it there instead of trying to look for it in a source file.&lt;br /&gt;
&lt;br /&gt;
 inline void DoSomething()&lt;br /&gt;
 {&lt;br /&gt;
      // Put code here...&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you declare the function in the header file and define it in the source file, you don't need the inline declaration.&lt;br /&gt;
&lt;br /&gt;
If you declare and define a member function in the class declaration, you also do not need the inline declaration.&lt;br /&gt;
&lt;br /&gt;
 class MyClass&lt;br /&gt;
 {&lt;br /&gt;
     int AddThese(int A, int B)&lt;br /&gt;
     {&lt;br /&gt;
          return  A + B;&lt;br /&gt;
     }&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
== What's really goin on here tho ==&lt;br /&gt;
What actually happens when a function is called is: the values to be passed to the function are placed somewhere where the function code can access them (called the stack, or in some calling conventions the parameters are put into CPU registers), then the current execution address is saved and the CPU jumps to the function address and begins executing the function instructions. At the end of the function, the result (if any) is placed in a predetermined location (typically a register), and the CPU jumps back to the address that it had previously saved and continues on its merry way.&lt;br /&gt;
&lt;br /&gt;
== Tutorial Videos ==&lt;br /&gt;
[[Beginner C++ Game Programming Tutorial 1]]&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
http://www.cplusplus.com/doc/tutorial/functions/&lt;/div&gt;</summary>
		<author><name>Albinopapa</name></author>	</entry>

	<entry>
		<id>https://wiki.planetchili.net/index.php?title=Graphics_(Chili_Framework)&amp;diff=429</id>
		<title>Graphics (Chili Framework)</title>
		<link rel="alternate" type="text/html" href="https://wiki.planetchili.net/index.php?title=Graphics_(Chili_Framework)&amp;diff=429"/>
				<updated>2016-07-25T07:28:58Z</updated>
		
		<summary type="html">&lt;p&gt;Albinopapa: /* Screen Dimensions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This class takes care of all the Direct3D setup bullshit and provides an interface to the graphical output of the application. Use &amp;lt;code&amp;gt;Graphics&amp;lt;/code&amp;gt; to draw on the screen, anything you like, even dicks (''especially'' dicks). &amp;lt;code&amp;gt;PutPixel()&amp;lt;/code&amp;gt; is generally how this is gone about, although later on more sophisticated dick-drawing routines are created based on &amp;lt;code&amp;gt;PutPixel()&amp;lt;/code&amp;gt;. You can also use &amp;lt;code&amp;gt;Graphics::ScreenWidth&amp;lt;/code&amp;gt; etc. to make sure you keep your dicks inside the screen boundaries.&lt;br /&gt;
&lt;br /&gt;
== Members ==&lt;br /&gt;
&lt;br /&gt;
=== PutPixel ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;void Graphics::PutPixel(int x,int y,int r,int g,int b)&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;void Graphics::PutPixel(int x,int y,Color c)&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This little number lets you set the color any pixel on the screen (&amp;lt;small&amp;gt;actually streamer, it sets the pixels in a buffer residing in system memory, which then is copied to a texture in graphics memory and drawn to the backbuffer, which is subsequently presented to a region of the screen corresponding to the client area of the application window&amp;lt;/small&amp;gt; YEAH OKAY FUCK OFF NOW), which means you can pretty much create any image you want with this function, even Teletubbie porn.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you might expect, &amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;y&amp;lt;/code&amp;gt; specify the coordinates on the screen ('''(0,0)''' being the top left, '''(width-1,height-1)''' being the bottom right), and &amp;lt;code&amp;gt;r&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;g&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt; specify the color (0 being lowest and 255 being highest). If you try and draw outside of the screen space, you might get F'ed in the A. So don't do that.&lt;br /&gt;
&lt;br /&gt;
=== Screen Dimensions ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;static constexpr unsigned int Graphics::ScreenWidth = 1280u&amp;lt;/code&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;static constexpr unsigned int Graphics::ScreenHeight = 720u&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These values tell you the maximum size dick you can draw on the screen. Since they are &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt; members, you can access them with, for example, &amp;lt;code&amp;gt;Graphics::ScreenWidth&amp;lt;/code&amp;gt; (you can do &amp;lt;code&amp;gt;gfx.ScreenWidth&amp;lt;/code&amp;gt; too if you really wanna). Changing the default values from 1280 and 720 to something different will make the window larger or smaller depending on the values. Neato!&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* The [[Chili Framework]]&lt;/div&gt;</summary>
		<author><name>Albinopapa</name></author>	</entry>

	<entry>
		<id>https://wiki.planetchili.net/index.php?title=User:Albinopapa&amp;diff=428</id>
		<title>User:Albinopapa</title>
		<link rel="alternate" type="text/html" href="https://wiki.planetchili.net/index.php?title=User:Albinopapa&amp;diff=428"/>
				<updated>2016-07-25T07:22:49Z</updated>
		
		<summary type="html">&lt;p&gt;Albinopapa: Created page with &amp;quot;Loyal planetchili citezen, that is all.&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Loyal planetchili citezen, that is all.&lt;/div&gt;</summary>
		<author><name>Albinopapa</name></author>	</entry>

	</feed>