Stroika Library
3.0d16
Help-Home
Loading...
Searching...
No Matches
TypeHints.h
Go to the documentation of this file.
1
/*
2
* Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3
*/
4
#ifndef _Stroika_Foundation_Common_TypeHints_h_
5
#define _Stroika_Foundation_Common_TypeHints_h_ 1
6
7
#include "Stroika/Foundation/StroikaPreComp.h"
8
9
#include <type_traits>
10
11
#include "Stroika/Foundation/Common/Common.h"
12
13
/**
14
* \file
15
*
16
* \note Code-Status: <a href="Code-Status.md#Release">Release</a>
17
*/
18
19
namespace
Stroika::Foundation::Common
{
20
21
/**
22
* \brief This is an alias for 'T' - but how we want to pass it on stack as formal parameter.
23
*
24
* This is NOT intended to be used very widely, but can be used to decide systematically (by type)
25
* if you should pass a given argument by value or by const reference.
26
*
27
* \note Use sizeof(T) <= 2*sizeof(void*) - because passing by reference involves copying one pointer and then if you
28
* access once, that's a second copy. So may as well copy 2 directly (very loosie goosy, as depends on
29
* relative cost of main memory access versus stack).
30
*/
31
template
<
typename
T,
typename
CHECK_T = remove_cvref_t<T>>
32
using
ArgByValueType
= conditional_t<(
sizeof
(CHECK_T) <= 2 *
sizeof
(
void
*)) and is_trivially_copyable_v<CHECK_T>, CHECK_T,
const
CHECK_T&>;
33
34
}
35
36
/*
37
********************************************************************************
38
***************************** Implementation Details ***************************
39
********************************************************************************
40
*/
41
42
#endif
/*_Stroika_Foundation_Common_TypeHints_h_*/
Stroika::Foundation::Common
Definition
Character.inl:624
Stroika::Foundation::Common::ArgByValueType
conditional_t<(sizeof(CHECK_T)<=2 *sizeof(void *)) and is_trivially_copyable_v< CHECK_T >, CHECK_T, const CHECK_T & > ArgByValueType
This is an alias for 'T' - but how we want to pass it on stack as formal parameter.
Definition
TypeHints.h:32
Library
Sources
Stroika
Foundation
Common
TypeHints.h
Generated by
1.9.8