rexylib/include/rexy/steal.hpp

43 lines
679 B
C++

#ifndef REXY_STEAL_HPP
#define REXY_STEAL_HPP
#include <utility> //forward
namespace rexy{
template<class T>
class steal
{
private:
T m_val;
public:
template<class U>
steal(U&& u):
m_val(std::forward<U>(u)){}
steal(const steal&) = delete;
steal(steal&&) = delete;
steal& operator=(const steal&) = delete;
steal& operator=(steal&&) = delete;
T&& value(void){
return std::forward<T>(m_val);
}
const T& value(void)const{
return m_val;
}
};
template<class T>
steal(const T&) -> steal<const T&>;
template<class T>
steal(T&&) -> steal<T&&>;
template<class T>
steal(T) -> steal<T>;
template<class T>
steal(T*) -> steal<T*>;
}
#endif