blob: f11d2b202125f5c79b637d4b5e7675c040c86ca1 [file] [log] [blame]
//
// Copyright 2016 Google Inc. All Rights Reserved.
//
// 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.
//
$$ This is a pump file for generating the interface and implementation of
$$ optional's forwarding constructor and emplace() method. Pump is a python
$$ script that is part of the Google Test suite of utilities. Description
$$ can be found here:
$$
$$ http://code.google.com/p/googletest/wiki/PumpManual
$$
$var MAX_ARITY = 7
$range ARITY 0..MAX_ARITY
// Begin forwarding constructor definitions ////////////////////////////////////
$for ARITY [[
$range ARG 1..ARITY
$if ARITY > 0 [[
template <$for ARG , [[typename P$(ARG)]]>
]]
explicit optional(in_place_t$if ARITY > 0 [[, ]]
$for ARG , [[const P$(ARG)& p$(ARG)]]) {
InitializeAsDisengaged();
new (value_memory_.void_data()) T($for ARG , [[p$(ARG)]]);
engaged_ = true;
#if !defined(NDEBUG)
value_ptr_ = static_cast<const T*>(value_memory_.void_data());
#endif
}
]]
// End forwarding constructor definitions //////////////////////////////////////
// Begin emplace(...) definitions //////////////////////////////////////////////
$for ARITY [[
$range ARG 1..ARITY
$if ARITY > 0 [[
template <$for ARG , [[typename P$(ARG)]]>
]]
void emplace($for ARG , [[const P$(ARG)& p$(ARG)]]) {
EnsureDisengaged();
new (value_memory_.void_data()) T($for ARG , [[p$(ARG)]]);
engaged_ = true;
#if !defined(NDEBUG)
value_ptr_ = static_cast<const T*>(value_memory_.void_data());
#endif
}
]]
// End emplace(...) definitions ////////////////////////////////////////////////