Added TypeSizeof.cpp

This commit is contained in:
hyzboy 2024-08-04 01:43:07 +08:00
parent 9dfd0c0c1c
commit 4e80bbb57a
3 changed files with 59 additions and 9 deletions

View File

@ -22,6 +22,9 @@ endmacro()
#################################################################################################### ####################################################################################################
add_executable(TypeSizeof datatype/TypeSizeof.cpp)
CM_EXAMPLE_PROJECT("DataType" TypeSizeof)
add_executable(HalfFloatTest datatype/HalfFloatTest.cpp) add_executable(HalfFloatTest datatype/HalfFloatTest.cpp)
cm_example_project("DataType" HalfFloatTest) cm_example_project("DataType" HalfFloatTest)

View File

@ -5,23 +5,20 @@ void main()
{ {
using namespace hgl; using namespace hgl;
UTF8IDName id1("id1");
UTF8IDName id2("id2");
AnsiIDName id3("id1"); AnsiIDName id3("id1");
AnsiIDName id4("id2"); AnsiIDName id4("id2");
UTF8IDName id5("id1"); AnsiIDName id5("id1");
AnsiIDName id6("id1"); AnsiIDName id6("id1");
std::cout<<id1.GetID()<<":"<<id1.GetName()<<", ClassID: "<<std::hex<<id1.GetClassID()<<std::endl; std::cout<<id5.GetID()<<":"<<id5.GetName()<<", ClassID: "<<std::hex<<id5.GetClassID()<<std::endl;
std::cout<<id2.GetID()<<":"<<id2.GetName()<<", ClassID: "<<std::hex<<id2.GetClassID()<<std::endl; std::cout<<id6.GetID()<<":"<<id6.GetName()<<", ClassID: "<<std::hex<<id6.GetClassID()<<std::endl;
std::cout<<id3.GetID()<<":"<<id3.GetName()<<", ClassID: "<<std::hex<<id3.GetClassID()<<std::endl; std::cout<<id3.GetID()<<":"<<id3.GetName()<<", ClassID: "<<std::hex<<id3.GetClassID()<<std::endl;
std::cout<<id4.GetID()<<":"<<id4.GetName()<<", ClassID: "<<std::hex<<id4.GetClassID()<<std::endl; std::cout<<id4.GetID()<<":"<<id4.GetName()<<", ClassID: "<<std::hex<<id4.GetClassID()<<std::endl;
if(id1==id5) if(id3==id5)
std::cout<<"id1==id5"<<std::endl; std::cout<<"id3==id5"<<std::endl;
else else
std::cout<<"id1!=id5"<<std::endl; std::cout<<"id3!=id5"<<std::endl;
} }

50
datatype/TypeSizeof.cpp Normal file
View File

@ -0,0 +1,50 @@
#include<hgl/type/DataType.h>
#include<hgl/math/Math.h>
#include<hgl/type/RectScope.h>
#include<iostream>
using namespace hgl;
#define OUTPUT_SIZEOF(type) std::cout<<" sizeof(" #type ") = "<<sizeof(type)<<std::endl;
void main()
{
OUTPUT_SIZEOF(char)
OUTPUT_SIZEOF(char8_t)
OUTPUT_SIZEOF(char16_t)
OUTPUT_SIZEOF(char32_t)
OUTPUT_SIZEOF(wchar_t)
OUTPUT_SIZEOF(short)
OUTPUT_SIZEOF(int)
OUTPUT_SIZEOF(long)
OUTPUT_SIZEOF(long long)
OUTPUT_SIZEOF(float)
OUTPUT_SIZEOF(double)
OUTPUT_SIZEOF(long double)
OUTPUT_SIZEOF(void *)
OUTPUT_SIZEOF(ptrdiff_t)
OUTPUT_SIZEOF(Vector2f)
OUTPUT_SIZEOF(Vector3f)
OUTPUT_SIZEOF(Vector4f)
OUTPUT_SIZEOF(RectScope2s)
OUTPUT_SIZEOF(RectScope2i)
OUTPUT_SIZEOF(RectScope2f)
OUTPUT_SIZEOF(RectScope2d)
OUTPUT_SIZEOF(Matrix2f)
OUTPUT_SIZEOF(Matrix3f)
OUTPUT_SIZEOF(Matrix4f)
OUTPUT_SIZEOF(Matrix2x4f)
OUTPUT_SIZEOF(Matrix3x4f)
OUTPUT_SIZEOF(Matrix4x2f)
OUTPUT_SIZEOF(Matrix4x3f)
OUTPUT_SIZEOF(Quatf)
OUTPUT_SIZEOF(Transform)
}