Skip to content
Snippets Groups Projects
Commit d01eb45c authored by Henry Weller's avatar Henry Weller
Browse files

List: Reinstated construction from two iterators and added construction from an initializer list

Until C++ supports 'concepts' the only way to support construction from
two iterators is to provide a constructor of the form:

        template<class InputIterator>
        List(InputIterator first, InputIterator last);

which for some types conflicts with

        //- Construct with given size and value for all elements
        List(const label, const T&);

e.g. to construct a list of 5 scalars initialized to 0:

    List<scalar> sl(5, 0);

causes a conflict because the initialization type is 'int' rather than
'scalar'.  This conflict may be resolved by specifying the type of the
initialization value:

    List<scalar> sl(5, scalar(0));

The new initializer list contructor provides a convenient and efficient alternative
to using 'IStringStream' to provide an initial list of values:

    List<vector> list4(IStringStream("((0 1 2) (3 4 5) (6 7 8))")());

or

    List<vector> list4
    {
        vector(0, 1, 2),
        vector(3, 4, 5),
        vector(6, 7, 8)
    };
parent b8614eca
Branches
Tags
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment