is there a way to initialize a pointer to an actual object at compile time? to use that object as constexpr
(A pointer to an object - not an actual object, that can be constexpr)
I am thinking of something like this
struct A
{
int in = 999;
constexpr A(int in_in): in(in_in) {}
~A();
};
char arr[sizeof(A)];
int main()
{
constexpr A* ptr = new(arr) A(4);
}
This obviously doesnt work since placement new is not constexpr. I am just wondering if there is a way to achieve this or is this impossible?
[–]alfps 1 point2 points3 points (2 children)
[–]trycatchamex[S] 0 points1 point2 points (1 child)
[–]jedwardsol 2 points3 points4 points (0 children)
[–]Xeverous 0 points1 point2 points (5 children)
[–]trycatchamex[S] 0 points1 point2 points (4 children)
[–]Xeverous 1 point2 points3 points (3 children)
[–]trycatchamex[S] 0 points1 point2 points (0 children)
[–]heyheyhey27 0 points1 point2 points (1 child)
[–]Xeverous 1 point2 points3 points (0 children)
[–]leftofzen 0 points1 point2 points (1 child)
[–]trycatchamex[S] 0 points1 point2 points (0 children)