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/] [upair.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
#ifndef UPAIR_H_7DC08F1B7FECF8AE6856D84C3B617A75
7
#define UPAIR_H_7DC08F1B7FECF8AE6856D84C3B617A75
8
 
9
#include "utypes.h"
10
 
11
namespace ustl {
12
 
13
/// \class pair upair.h ustl.h
14
/// \ingroup AssociativeContainers
15
///
16
/// \brief Container for two values.
17
///
18
template <typename T1, typename T2>
19
class pair {
20
public:
21
    typedef T1          first_type;
22
    typedef T2          second_type;
23
public:
24
    /// Default constructor.
25
    inline pair (void)                          : first (T1()), second (T2()) {}
26
    /// Initializes members with \p a, and \p b.
27
    inline pair (const T1& a, const T2& b)      : first (a), second (b) {}
28
    inline pair&        operator= (const pair<T1, T2>& p2) { first = p2.first; second = p2.second; return (*this); }
29
    template <typename T3, typename T4>
30
    inline pair&        operator= (const pair<T3, T4>& p2) { first = p2.first; second = p2.second; return (*this); }
31
public:
32
    first_type          first;
33
    second_type         second;
34
};
35
 
36
/// Compares both values of \p p1 to those of \p p2.
37
template <typename T1, typename T2>
38
inline bool operator== (const pair<T1,T2>& p1, const pair<T1,T2>& p2)
39
{
40
    return (p1.first == p2.first && p1.second == p2.second);
41
}
42
 
43
/// Compares both values of \p p1 to those of \p p2.
44
template <typename T1, typename T2>
45
bool operator< (const pair<T1,T2>& p1, const pair<T1,T2>& p2)
46
{
47
    return (p1.first < p2.first || (p1.first == p2.first && p1.second < p2.second));
48
}
49
 
50
/// Returns a pair object with (a,b)
51
template <typename T1, typename T2>
52
inline pair<T1,T2> make_pair (const T1& a, const T2& b)
53
{
54
    return (pair<T1,T2> (a, b));
55
}
56
 
57
} // namespace ustl
58
 
59
#endif

powered by: WebSVN 2.1.0

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