OnixS C++ CME iLink 3 Binary Order Entry Handler 1.18.9
API Documentation
Loading...
Searching...
No Matches
ValueContainer.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
25
26#include <new>
27
29
33{
34 enum
35 {
41 Capacity = 16
42 };
43
44 Byte bytes_[Capacity];
45
48 void* place() ONIXS_ILINK3_NOTHROW
49 {
50 return static_cast<void*>(bytes_);
51 }
52
55 const void* place() const ONIXS_ILINK3_NOTHROW
56 {
57 return static_cast<const void*>(bytes_);
58 }
59
60public:
63
65 template <typename Value>
67 {
68 ONIXS_ILINK3_STATIC_ASSERT_MSG
69 (
70 (sizeof(Value) <= static_cast<size_t>(Capacity)), "Capacity is not sufficient for storing values of the given type."
71 );
72
73 return * static_cast<Value*> (place());
74 }
75
77 template <typename Value>
79 {
80 ONIXS_ILINK3_STATIC_ASSERT_MSG
81 (
82 (sizeof(Value) <= static_cast<size_t>(Capacity)), "Capacity of the storage is not sufficient to store values of the specified type."
83 );
84
85 return * static_cast<const Value*>(place());
86 }
87
89 template<class Value>
91 {
92 ONIXS_ILINK3_STATIC_ASSERT_MSG
93 (
94 (sizeof(Value) <= static_cast<size_t>(Capacity)), "Capacity of the storage is not sufficient to store values of the specified type."
95 );
96
97#if defined (ONIXS_ILINK3_CXX11)
98 static_assert(
99 std::is_nothrow_copy_constructible<Value>::value,
100 "must be noexcept");
101#endif
102
103 new (place()) Value(value);
104
105 return *this;
106 }
107};
108
#define ONIXS_ILINK3_LTWT_CLASS
Definition ABI.h:84
#define ONIXS_ILINK3_MESSAGING_TAGBASED_NAMESPACE_END
Definition ABI.h:153
#define ONIXS_ILINK3_MESSAGING_TAGBASED_NAMESPACE_BEGIN
Definition ABI.h:149
#define ONIXS_ILINK3_NODISCARD
Definition Compiler.h:185
#define ONIXS_ILINK3_DEFAULT
Definition Compiler.h:202
#define ONIXS_ILINK3_NOTHROW
Definition Compiler.h:176
ValueContainer()=default
Initializes the container.
ValueContainer & assign(const Value &value) noexcept
Stores the given value.
UInt8 Byte
Alias for Byte.
Definition Memory.h:34