mercredi 29 mars 2017

Initializer list of RValues

Right now I have a class with only one constructor

ShaderProgram(std::initializer_list<std::reference_wrapper<const Shader>> shaders);

I'm using a reference wrapper because I can't have an initializer_list of references and I can't copy

This code works

    Shader v{ Shader::Type::Vertex, readFile("res/simple.vert") };
    Shader f{ Shader::Type::Fragment, readFile("res/simple.frag") };
    ShaderProgram shader{ v, f };

But this does not

    ShaderProgram shader{ 
        Shader { Shader::Type::Vertex, readFile("res/simple.vert") },
        Shader { Shader::Type::Fragment, readFile("res/simple.frag") }
    };

What should I be covering here? I suppose I'm missing some kind of constructor to handle rvalues but I can't seem to make it work

Aucun commentaire:

Enregistrer un commentaire