# FProperty: What different with GetPropertyValue() and ContainerPtrToValuePtr()?

**URL:** <https://forums.unrealengine.com/t/fproperty-what-different-with-getpropertyvalue-and-containerptrtovalueptr/1416488>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, CPP, question\
**Created:** [November 24, 2023, 6:48am UTC](https://forums.unrealengine.com/t/fproperty-what-different-with-getpropertyvalue-and-containerptrtovalueptr/1416488 "2023-11-24T06:48:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![FourRoadTitans](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fourroadtitans/32/572794_2.png) [@FourRoadTitans](https://forums.unrealengine.com/u/FourRoadTitans)\
**Post date:** [November 24, 2023, 6:48am UTC](https://forums.unrealengine.com/t/fproperty-what-different-with-getpropertyvalue-and-containerptrtovalueptr/1416488/1 "2023-11-24T06:48:53Z")

</div>

I’m trying to make a generic struct to string map node, and met a strange problem.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/6/606e6e1ce043aff88438479fa9a2dd9c62dcd075.jpeg)  
when I using FProperty-\>GetPropertyValue(), It got all wrong similar value.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/d/0/0d0594107b00da25819b3f28b52034f3bede9af9.jpeg)  
and when I using FProperty-\>ContainerPtrToValuePtr(), It got all right value.

why?

---

<div class="post-metadata">

**Author:** ![RichmarIII](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RichmarIII](https://forums.unrealengine.com/u/RichmarIII)\
**Post date:** [November 24, 2023, 7:31am UTC](https://forums.unrealengine.com/t/fproperty-what-different-with-getpropertyvalue-and-containerptrtovalueptr/1416488/2 "2023-11-24T07:31:22Z")

</div>

Despite the apparent similarity in name, `FProperty::GetPropertyValue` doesn’t perform as expected. Internally, it simply invokes:

```c++
/** Convert the address of a value of the property to the proper type */
static FORCEINLINE TCppType const* GetPropertyValuePtr(void const* A)
{
	return (TCppType const*)A;
}

```

This snippet essentially takes your `ValuePtr` pointer and converts it to the specified type (in your case, `float`). However, if `ValuePtr` is a `struct` and you attempt to convert it to a `float` (when it’s not), it retrieves the first member variable in the `struct`’s layout, resulting in a consistent return value regardless of input. This function truly needs either a clearer name or more detailed documentation.

Moving on to `FProperty::ContainerPtrToValuePtr`, it indeed accomplishes the intended task of extracting the property from the struct. Internally, it conducts a simple struct member pointer offset operation, resembling something like `return (uint8*)ValuePtr + MemberVariableOffset;`

---

<div class="post-metadata">

**Author:** ![FourRoadTitans](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fourroadtitans/32/572794_2.png) [@FourRoadTitans](https://forums.unrealengine.com/u/FourRoadTitans)\
**Post date:** [November 24, 2023, 10:03am UTC](https://forums.unrealengine.com/t/fproperty-what-different-with-getpropertyvalue-and-containerptrtovalueptr/1416488/3 "2023-11-24T10:03:05Z")

</div>

Thanks for your replay. The func name has indeed caused me trouble.

---

<div class="post-metadata">

**Author:** ![Roy\_Wierer.Seda145](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/roy_wierer.seda145/32/906551_2.png) [@Roy\_Wierer.Seda145](https://forums.unrealengine.com/u/Roy_Wierer.Seda145)\
**Post date:** [November 24, 2023, 10:11am UTC](https://forums.unrealengine.com/t/fproperty-what-different-with-getpropertyvalue-and-containerptrtovalueptr/1416488/4 "2023-11-24T10:11:58Z")

</div>

> [Correct way to get the value of a Property?](https://forums.unrealengine.com/t/correct-way-to-get-the-value-of-a-property/551897)

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [December 24, 2023, 10:12am UTC](https://forums.unrealengine.com/t/fproperty-what-different-with-getpropertyvalue-and-containerptrtovalueptr/1416488/5 "2023-12-24T10:12:24Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
