OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [language/] [cxx/] [ustl/] [current/] [include/] [ustl/] [metamac.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// This file is part of the uSTL library, an STL implementation.
2
//
3
// Copyright (c) 2005-2009 by Mike Sharov <msharov@users.sourceforge.net>
4
// This file is free software, distributed under the MIT License.
5
//
6
/// \file metamac.h
7
/// \brief Macros for complex metaprogramming involving pseudoiteration.
8
 
9
#ifndef METAMAC_H_7235D14A209C29332F2330EF553B81AF
10
#define METAMAC_H_7235D14A209C29332F2330EF553B81AF
11
 
12
//----------------------------------------------------------------------
13
// Functors and general utilities.
14
//----------------------------------------------------------------------
15
 
16
/// Evaluates to itself
17
#define ITSELF(x)               x
18
 
19
/// Concatenates \p a and \p b
20
#define PASTE(a,b)      a##b
21
 
22
//----------------------------------------------------------------------
23
// Lists and other iterators
24
//----------------------------------------------------------------------
25
 
26
/// The maximum number of elements in REPEAT, LIST, and COMMA_LIST
27
#define METAMAC_MAXN    9
28
 
29
/// Simple list with no separators. Repeats x N times.
30
/// @{
31
#define REPEAT_1(x)     x(1)
32
#define REPEAT_2(x)     REPEAT_1(x) x(2)
33
#define REPEAT_3(x)     REPEAT_2(x) x(3)
34
#define REPEAT_4(x)     REPEAT_3(x) x(4)
35
#define REPEAT_5(x)     REPEAT_4(x) x(5)
36
#define REPEAT_6(x)     REPEAT_5(x) x(6)
37
#define REPEAT_7(x)     REPEAT_6(x) x(7)
38
#define REPEAT_8(x)     REPEAT_7(x) x(8)
39
#define REPEAT_9(x)     REPEAT_8(x) x(9)
40
#define REPEAT(N,x)     PASTE(REPEAT_,N)(x)
41
/// @}
42
 
43
/// Simple separated list. Repeats x N times with sep in between.
44
/// @{
45
#define LIST_1(x,sep)   x(1)
46
#define LIST_2(x,sep)   LIST_1(x,sep) sep x(2)
47
#define LIST_3(x,sep)   LIST_2(x,sep) sep x(3)
48
#define LIST_4(x,sep)   LIST_3(x,sep) sep x(4)
49
#define LIST_5(x,sep)   LIST_4(x,sep) sep x(5)
50
#define LIST_6(x,sep)   LIST_5(x,sep) sep x(6)
51
#define LIST_7(x,sep)   LIST_6(x,sep) sep x(7)
52
#define LIST_8(x,sep)   LIST_7(x,sep) sep x(8)
53
#define LIST_9(x,sep)   LIST_8(x,sep) sep x(9)
54
#define LIST(N,x,sep)   PASTE(LIST_,N)(x,sep)
55
/// @}
56
 
57
/// Comma separated list. A special case of LIST needed because the preprocessor can't substitute commas.
58
/// @{
59
#define COMMA_LIST_1(x) x(1)
60
#define COMMA_LIST_2(x) COMMA_LIST_1(x), x(2)
61
#define COMMA_LIST_3(x) COMMA_LIST_2(x), x(3)
62
#define COMMA_LIST_4(x) COMMA_LIST_3(x), x(4)
63
#define COMMA_LIST_5(x) COMMA_LIST_4(x), x(5)
64
#define COMMA_LIST_6(x) COMMA_LIST_5(x), x(6)
65
#define COMMA_LIST_7(x) COMMA_LIST_6(x), x(7)
66
#define COMMA_LIST_8(x) COMMA_LIST_7(x), x(8)
67
#define COMMA_LIST_9(x) COMMA_LIST_8(x), x(9)
68
#define COMMA_LIST(N,x) PASTE(COMMA_LIST_,N)(x)
69
/// @}
70
 
71
//----------------------------------------------------------------------
72
// Macros for defining LIST arguments.
73
//----------------------------------------------------------------------
74
 
75
/// Ignores N, producing lists of identically named arguments.
76
#define LARG_NONE(name,N)       name
77
 
78
/// Appends N to name.
79
#define LARG_NUMBER(name,N)     name##N
80
 
81
/// name is a reference type.
82
#define LARG_REF(name,N)        name##N&
83
 
84
/// Sequential parameter passed by value with sequential types.
85
#define LARG_MT_PARAM_BY_VALUE(type,name,N)     type##N name##N
86
 
87
/// Sequential parameter passed by reference with sequential types.
88
#define LARG_MT_PARAM_BY_REF(type,name,N)       type##N& name##N
89
 
90
//----------------------------------------------------------------------
91
 
92
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.