COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
DefaultValueInitialiser.h
1//
2// Copyright 2015 - 2024 (C). Alex Robenko. All rights reserved.
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8#pragma once
9
10#include "comms/ErrorStatus.h"
11
12namespace comms
13{
14
15namespace field
16{
17
18namespace adapter
19{
20
21template <typename TInitialiser, typename TBase>
22class DefaultValueInitialiser : public TBase
23{
24 using BaseImpl = TBase;
25 using Initialiser = TInitialiser;
26public:
27 using ValueType = typename BaseImpl::ValueType;
28
30 {
31 Initialiser()(*this);
32 }
33
34 explicit DefaultValueInitialiser(const ValueType& val)
35 : BaseImpl(val)
36 {
37 }
38
39 explicit DefaultValueInitialiser(ValueType&& val)
40 : BaseImpl(std::move(val))
41 {
42 }
43
44 DefaultValueInitialiser(const DefaultValueInitialiser&) = default;
45 DefaultValueInitialiser(DefaultValueInitialiser&&) = default;
46 DefaultValueInitialiser& operator=(const DefaultValueInitialiser&) = default;
47 DefaultValueInitialiser& operator=(DefaultValueInitialiser&&) = default;
48};
49
50} // namespace adapter
51
52} // namespace field
53
54} // namespace comms
55
56
57
This file contain definition of error statuses used by comms module.
comms::option::def::DefaultValueInitialiser< T > DefaultValueInitialiser
Same as comms::option::def::DefaultValueInitialiser.
Definition options.h:1548
Main namespace for all classes / functions of COMMS library.
STL namespace.