Skip to content

Array や Grid のサイズを取るコンストラクタで CTAD が効かない #1307

Open
@Raclamusi

Description

@Raclamusi

ArrayGrid のサイズを取るコンストラクタでテンプレート引数推論が効きません。
コンストラクタの引数の型にテンプレート引数 Type が使われず、代わりに型エイリアス value_type が使われているためです。
コンストラクタの引数の型として使われる型エイリアス Array<Type>::value_type は、 Type の直接エイリアスではなく、他のクラスの型エイリアス std::vector<Type>::value_type のエイリアスであるので、推論できません。

Array(size_type count, const value_type& value, const Allocator& alloc = Allocator{});

Grid(size_type w, size_type h, const value_type& value);

std::vector ではできるので、できて欲しいです。

# include <Siv3D.hpp> // OpenSiv3D v0.6.16

void Main()
{
    std::vector v1{ 42, 42, 42 };  // ok. std::vector<int> に推論される
    Array a1{ 42, 42, 42 };  // ok. Array<int> に推論される
    Grid g1{ { 42, 42 }, { 42, 42 } };  // ok. Grid<int> に推論される

    std::vector v2(3, 42);  // ok. std::vector<int> に推論される
    Array a2(3, 42);  // error!
    Grid g2(2, 2, 42);  // error!

    while (System::Update())
    {

    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Investigating

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions