Merge pull request #46 from Pharap/constexpr-point-and-rect

Make Rect and Point's constructors constexpr
This commit is contained in:
Scott Allen 2020-02-21 13:33:04 -05:00 committed by GitHub
commit 3f9e86ab99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 20 deletions

View File

@ -8,24 +8,6 @@
#include "ab_logo.c" #include "ab_logo.c"
#include "glcdfont.c" #include "glcdfont.c"
//================================
//========== class Rect ==========
//================================
Rect::Rect(int16_t x, int16_t y, uint8_t width, uint8_t height)
: x(x), y(y), width(width), height(height)
{
}
//=================================
//========== class Point ==========
//=================================
Point::Point(int16_t x, int16_t y)
: x(x), y(y)
{
}
//======================================== //========================================
//========== class Arduboy2Base ========== //========== class Arduboy2Base ==========
//======================================== //========================================

View File

@ -122,7 +122,10 @@ struct Rect
* \param width The width of the rectangle. Copied to variable `width`. * \param width The width of the rectangle. Copied to variable `width`.
* \param height The height of the rectangle. Copied to variable `height`. * \param height The height of the rectangle. Copied to variable `height`.
*/ */
Rect(int16_t x, int16_t y, uint8_t width, uint8_t height); constexpr Rect(int16_t x, int16_t y, uint8_t width, uint8_t height)
: x(x), y(y), width(width), height(height)
{
}
}; };
//================================== //==================================
@ -153,7 +156,10 @@ struct Point
* \param x The X coordinate of the point. Copied to variable `x`. * \param x The X coordinate of the point. Copied to variable `x`.
* \param y The Y coordinate of the point. Copied to variable `y`. * \param y The Y coordinate of the point. Copied to variable `y`.
*/ */
Point(int16_t x, int16_t y); constexpr Point(int16_t x, int16_t y)
: x(x), y(y)
{
}
}; };
//================================== //==================================