If your compiler has rvalue references to this ( && after methods), you can use it. See Reply @juanchopanza.
If you do not, first make sure that data() makes it clear that you are moving. There are several ways to do this.
First, non-member ( friend s) methods can be overridden by && . So you can get this syntax:
std::vector<uint8_t> temp(get_data( std::move(factory) );
where get_data has && and & overloads on your factory type, and either moves or doesn't rely on it.
Then you want to return std::vector<uint8_t> instead of `std::vector<uint8_t>&& to extend the life. The execution cost is somewhere between zero and small, but the errors to be fixed are worth it.
If create_factory returns a factory object, then if we do this:
for( uint8_t x : get_data( create_factory() ) )
get_data , which returns && , does not work, and one that returns temporary works flawlessly.
What's happening? Well, range-based loops are defined as linking what you iterate over the link. A temporary link to a link has an extended lifespan: a link tied to a link does not have a life extension. The lifetime of the return value of the create_factory function create_factory not increase in both cases.
In the case of && reference to the vector remains dangling. With the back-and-forth case, the factory vector moves to the temporary one, then this lifetime increases.
In short, returning && links is very rarely a good idea.