Code
#include <limits>
extern int x;
extern int y;
__forceinline int max(int x, int y)
{
return x > y ? x : y;
}
[[msvc::forceinline]] void complexCalculation(int x)
{
static int counter = 0;
++counter;
for (int i = 1; i < 100000000; ++i)
{
counter *= i * x;
counter %= 123456789 * i;
}
}
using FC_TYPE = long long;
constexpr FC_TYPE factorial(FC_TYPE n)
{
return n <= 1 ? 1 : n * factorial(n-1);
}
constexpr int sum(int n)
{
return n <= 0 ? 0 : n + sum(n-1);
}
class Point
{
public:
constexpr Point(int x, int y): m_x(x), m_y(y) {}
private:
const int m_x;
const int m_y;
};
constexpr Point c_point = Point(10, 20);
// #pragma optimize( "", off )
int main()
{
const auto result1 = max(89, 45);
constexpr auto result2 = factorial(10);
constexpr auto result3 = sum(100);
complexCalculation(5);
constexpr auto intMax = std::numeric_limits<FC_TYPE>().max();
}
// #pragma optimize( "", on )
#include <iostream>
#define FPS_DATA alignas(4)
// #pragma pack(push, 4)
struct FPS_DATA Ammo
{
bool empty;
char padding1[2];
int bullets;
bool taken;
char padding2[3];
};
// #pragma pack(pop)
static_assert(sizeof(struct Ammo) == 12, "Struct layout was changed");
int main()
{
std::cout << "Size of Ammo: " << sizeof(Ammo) << std::endl;
std::cout << "Align of Ammo: " << alignof(Ammo) << std::endl;
}
Last updated