Coder Social home page Coder Social logo

Comments (4)

tmadlener avatar tmadlener commented on June 28, 2024

You are right. I don't see a reason to not be consistent here. This should be fairly straight forward to fix, I think as these are directly passed to the underlying std::deque, e.g.

Mutable{{ class.bare_type }} {{ collection_type }}::operator[](unsigned int index) {
return Mutable{{ class.bare_type }}(m_storage.entries[index]);
}

Out of of curiosity: Does something change with c++20 in this respect? I am asking since you mentioned it explicitly.

from podio.

c-dilks avatar c-dilks commented on June 28, 2024

According to cppreference.com it's effectively size_type no matter the version:
0
1
2

Also, std::deque::operator[] and std::deque::size() use size_type:
4

Since vector and deque both use std::allocator by default, where size_type is std::size_t, I would assume vector::size_type is the same as deque::size_type (reference SO thread).

from podio.

c-dilks avatar c-dilks commented on June 28, 2024

I'm also now wondering if we should switch to size_t for VectorMembers and OneToManyRelations, but at least for those the type is always unsigned int. For example:

{% macro multi_relation_handling(relations, get_syntax, with_adder=False) %}
{% for relation in relations %}
{% if with_adder %}
void {{ relation.setter_name(get_syntax, is_relation=True) }}({{ relation.full_type }});
{% endif %}
unsigned int {{ relation.name }}_size() const;
{{ relation.full_type }} {{ relation.getter_name(get_syntax) }}(unsigned int) const;
std::vector<{{ relation.full_type }}>::const_iterator {{ relation.name }}_begin() const;
std::vector<{{ relation.full_type }}>::const_iterator {{ relation.name }}_end() const;
podio::RelationRange<{{ relation.full_type }}> {{ relation.getter_name(get_syntax) }}() const;
{% endfor %}
{%- endmacro %}

Ultimately it looks like Collection::size() is the only odd one out, returning size_t.

from podio.

tmadlener avatar tmadlener commented on June 28, 2024

It also looks like we have a size_t in the RelationRange that is one of the returns above.

/// convenience overload for size
size_t size() const {
return m_size;

For consistency with the usual c++ containers I think it would be good to have size_t everywhere. From a purely functional point of view, it doesn't really matter probably, because the ObjectID uses an int internally at the moment, and that is essentially the limiting factor for the number of elements in a collection:

/// index of object in collection
int index;

from podio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.