I have a class Foo
that operates that need a reference to be built (it will be used to work on that memory space)
template<typename T>
class Foo {
public:
Foo(T& value) : _value(value) {}
...
private:
T& _value;
};
I also have a linear memory space of multiple instances of T
std::array<T, SIZE> buffer;
What I'd like to build is an array of object of type Foo
which maps the differents instances of my buffer. Which means each instance of Foo
has to be built using the correct reference.
std::array<Foo<T>, SIZE> operators;
Still, operators
is cannot be trivially initialize, and I can manage to build it by 'mapping' the buffer through the 'Foo' constructor.
Is there any way to do ? I tried using std::forward
and std::initializer_list
but those cannot be constructed from my buffer.
Note that I need my buffer to stay aligned for communication purposes, and I will en up overloading the Foo
class to implement different behaviour for different elements of my array.
Aucun commentaire:
Enregistrer un commentaire