Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-11-03 19:20:20 +0300
committerJulian Eisel <julian@blender.org>2021-11-03 19:28:20 +0300
commitdebf4b70db81cff0dc22dc018c84cdcfd3eedbb7 (patch)
tree74dbd6c22c7cb882c4d347ca305aac93f04da123 /source/blender/blenlib
parentaa0ac0035a0d3601672a0c732e3f8f932a36fc04 (diff)
Cleanup: Avoid redundant template parameter in BLI serializing API
The `ContainerValue` template can obtain the type of the contained value via the given `Container` type, simply using `Container::value_type`. Use this as the default way to determine the value type which simplifies using the template. If necessary the value type can be passed explicitly still.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/BLI_serialize.hh17
1 files changed, 8 insertions, 9 deletions
diff --git a/source/blender/blenlib/BLI_serialize.hh b/source/blender/blenlib/BLI_serialize.hh
index 7b8aa03b807..088243b3a30 100644
--- a/source/blender/blenlib/BLI_serialize.hh
+++ b/source/blender/blenlib/BLI_serialize.hh
@@ -103,11 +103,11 @@ using IntValue = PrimitiveValue<int64_t, eValueType::Int>;
using DoubleValue = PrimitiveValue<double, eValueType::Double>;
using BooleanValue = PrimitiveValue<bool, eValueType::Boolean>;
-template<typename Container, typename ContainerItem, eValueType V> class ContainerValue;
+template<typename Container, eValueType V, typename ContainerItem = typename Container::value_type>
+class ContainerValue;
/* ArrayValue stores its items as shared pointer as it shares data with a lookup table that can
* be created by calling `create_lookup`. */
-using ArrayValue =
- ContainerValue<Vector<std::shared_ptr<Value>>, std::shared_ptr<Value>, eValueType::Array>;
+using ArrayValue = ContainerValue<Vector<std::shared_ptr<Value>>, eValueType::Array>;
/**
* Class containing a (de)serializable value.
@@ -234,11 +234,11 @@ template<
/** The container type where the elements are stored in. */
typename Container,
- /** Type of the data inside the container. */
- typename ContainerItem,
-
/** ValueType representing the value (object/array). */
- eValueType V>
+ eValueType V,
+
+ /** Type of the data inside the container. */
+ typename ContainerItem>
class ContainerValue : public Value {
public:
using Items = Container;
@@ -275,8 +275,7 @@ using ObjectElementType = std::pair<std::string, std::shared_ptr<Value>>;
* Object is a key-value container where the key must be a std::string.
* Internally it is stored in a blender::Vector to ensure the order of keys.
*/
-class ObjectValue
- : public ContainerValue<Vector<ObjectElementType>, ObjectElementType, eValueType::Object> {
+class ObjectValue : public ContainerValue<Vector<ObjectElementType>, eValueType::Object> {
public:
using LookupValue = std::shared_ptr<Value>;
using Lookup = Map<std::string, LookupValue>;