46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
/*
|
|
* Copyright 2015-2018 Michele "King_DuckZ" Santullo
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#if defined VWR_OUTER_NAMESPACE
|
|
namespace VWR_OUTER_NAMESPACE {
|
|
#endif
|
|
|
|
namespace vwr {
|
|
template <typename V, typename Storage>
|
|
class forward_wrapper {
|
|
public:
|
|
forward_wrapper() { new(&m_storage) V; }
|
|
forward_wrapper (const forward_wrapper&) = delete;
|
|
forward_wrapper (forward_wrapper&&) = delete;
|
|
~forward_wrapper() { vector().~V(); }
|
|
|
|
forward_wrapper& operator= (const forward_wrapper&) = delete;
|
|
forward_wrapper& operator= (forward_wrapper&&) = delete;
|
|
|
|
private:
|
|
V& vector() { return *reinterpret_cast<V*>(&m_storage); }
|
|
//const V& vector() const { return *reinterpret_cast<const V*>(&m_storage); }
|
|
|
|
Storage m_storage;
|
|
};
|
|
} //namespace vwr
|
|
|
|
#if defined VWR_OUTER_NAMESPACE
|
|
} //namespace VWR_OUTER_NAMESPACE
|
|
#endif
|