Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Foundation/Containers/Common.inl
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4
5/*
6 ********************************************************************************
7 ***************************** Implementation Details ***************************
8 ********************************************************************************
9 */
10
11#include <algorithm>
12
13#include "Stroika/Foundation/Math/Common.h"
14
16
17 /*
18 ********************************************************************************
19 ************************************* Start ************************************
20 ********************************************************************************
21 */
22 template <typename CONTAINER>
23 inline typename CONTAINER::value_type* Start (CONTAINER& c)
24 {
25 size_t cnt = c.size ();
26 return cnt == 0 ? nullptr : &c[0];
27 }
28 template <typename CONTAINER>
29 inline const typename CONTAINER::value_type* Start (const CONTAINER& c)
30 {
31 size_t cnt = c.size ();
32 return cnt == 0 ? nullptr : &c[0];
33 }
34
35 /*
36 ********************************************************************************
37 ************************************* End **************************************
38 ********************************************************************************
39 */
40 template <typename CONTAINER>
41 inline typename CONTAINER::value_type* End (CONTAINER& c)
42 {
43 size_t cnt = c.size ();
44 return cnt == 0 ? nullptr : &c[0] + cnt;
45 }
46 template <typename CONTAINER>
47 inline const typename CONTAINER::value_type* End (const CONTAINER& c)
48 {
49 size_t cnt = c.size ();
50 return cnt == 0 ? nullptr : &c[0] + cnt;
51 }
52
53}
CONTAINER::value_type * End(CONTAINER &c)
For a contiguous container (such as a vector or basic_string) - find the pointer to the end of the co...
CONTAINER::value_type * Start(CONTAINER &c)
For a contiguous container (such as a vector or basic_string) - find the pointer to the start of the ...