Make Rect and Point's constructors constexpr

This commit is contained in:
Pharap 2020-02-21 18:18:15 +00:00 committed by GitHub
parent bc4e0ed0b5
commit 4e513a15d0
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)
{
}
}; };
//================================== //==================================