COMMS
Template library intended to help with implementation of communication protocols.
cast.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 - 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 
10 
11 #pragma once
12 
13 #include "comms/details/ValueAssignWrapper.h"
14 #include "comms/details/FieldCastHelper.h"
15 
16 namespace comms
17 {
18 
19 
28 template <typename T>
29 details::ValueAssignWrapper<T> cast_assign(T& value)
30 {
31  return details::ValueAssignWrapper<T>(value);
32 }
33 
52 template <typename TFieldTo, typename TFieldFrom>
53 TFieldTo field_cast(const TFieldFrom& field)
54 {
55  return details::FieldCastHelper<>::template cast<TFieldTo, TFieldFrom>(field);
56 }
57 
58 
59 } // namespace comms
Main namespace for all classes / functions of COMMS library.
TFieldTo field_cast(const TFieldFrom &field)
Cast between fields.
Definition: cast.h:53
details::ValueAssignWrapper< T > cast_assign(T &value)
Helper function to assign value with static_cast to appropriate type.
Definition: cast.h:29