~evarlast/ubuntu/utopic/mongodb/upstart-workaround-debian-bug-718702

« back to all changes in this revision

Viewing changes to src/third_party/s2/base/template_util.h

  • Committer: Package Import Robot
  • Author(s): James Page, James Page, Robie Basak
  • Date: 2013-05-29 17:44:42 UTC
  • mfrom: (44.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20130529174442-z0a4qmoww4y0t458
Tags: 1:2.4.3-1ubuntu1
[ James Page ]
* Merge from Debian unstable, remaining changes:
  - Enable SSL support:
    + d/control: Add libssl-dev to BD's.
    + d/rules: Enabled --ssl option.
    + d/mongodb.conf: Add example SSL configuration options.
  - d/mongodb-server.mongodb.upstart: Add upstart configuration.
  - d/rules: Don't strip binaries during scons build for Ubuntu.
  - d/control: Add armhf to target archs.
  - d/p/SConscript.client.patch: fixup install of client libraries.
  - d/p/0010-install-libs-to-usr-lib-not-usr-lib64-Closes-588557.patch:
    Install libraries to lib not lib64.
* Dropped changes:
  - d/p/arm-support.patch: Included in Debian.
  - d/p/double-alignment.patch: Included in Debian.
  - d/rules,control: Debian also builds with avaliable system libraries
    now.
* Fix FTBFS due to gcc and boost upgrades in saucy:
  - d/p/0008-ignore-unused-local-typedefs.patch: Add -Wno-unused-typedefs
    to unbreak building with g++-4.8.
  - d/p/0009-boost-1.53.patch: Fixup signed/unsigned casting issue.

[ Robie Basak ]
* d/p/0011-Use-a-signed-char-to-store-BSONType-enumerations.patch: Fixup
  build failure on ARM due to missing signed'ness of char cast.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2005 Google Inc. All Rights Reserved.
 
2
//
 
3
// Template metaprogramming utility functions.
 
4
//
 
5
// This code is compiled directly on many platforms, including client
 
6
// platforms like Windows, Mac, and embedded systems.  Before making
 
7
// any changes here, make sure that you're not breaking any platforms.
 
8
//
 
9
//
 
10
// The names choosen here reflect those used in tr1 and the boost::mpl
 
11
// library, there are similar operations used in the Loki library as
 
12
// well.  I prefer the boost names for 2 reasons:
 
13
// 1.  I think that portions of the Boost libraries are more likely to
 
14
// be included in the c++ standard.
 
15
// 2.  It is not impossible that some of the boost libraries will be
 
16
// included in our own build in the future.
 
17
// Both of these outcomes means that we may be able to directly replace
 
18
// some of these with boost equivalents.
 
19
//
 
20
#ifndef BASE_TEMPLATE_UTIL_H_
 
21
#define BASE_TEMPLATE_UTIL_H_
 
22
 
 
23
namespace base {
 
24
 
 
25
// Types small_ and big_ are guaranteed such that sizeof(small_) <
 
26
// sizeof(big_)
 
27
typedef char small_;
 
28
 
 
29
struct big_ {
 
30
  char dummy[2];
 
31
};
 
32
 
 
33
// integral_constant, defined in tr1, is a wrapper for an integer
 
34
// value. We don't really need this generality; we could get away
 
35
// with hardcoding the integer type to bool. We use the fully
 
36
// general integer_constant for compatibility with tr1.
 
37
 
 
38
template<class T, T v>
 
39
struct integral_constant {
 
40
  static const T value = v;
 
41
  typedef T value_type;
 
42
  typedef integral_constant<T, v> type;
 
43
};
 
44
 
 
45
template <class T, T v> const T integral_constant<T, v>::value;
 
46
 
 
47
 
 
48
// Abbreviations: true_type and false_type are structs that represent boolean
 
49
// true and false values. Also define the boost::mpl versions of those names,
 
50
// true_ and false_.
 
51
typedef integral_constant<bool, true>  true_type;
 
52
typedef integral_constant<bool, false> false_type;
 
53
typedef true_type  true_;
 
54
typedef false_type false_;
 
55
 
 
56
// if_ is a templatized conditional statement.
 
57
// if_<cond, A, B> is a compile time evaluation of cond.
 
58
// if_<>::type contains A if cond is true, B otherwise.
 
59
template<bool cond, typename A, typename B>
 
60
struct if_{
 
61
  typedef A type;
 
62
};
 
63
 
 
64
template<typename A, typename B>
 
65
struct if_<false, A, B> {
 
66
  typedef B type;
 
67
};
 
68
 
 
69
 
 
70
// type_equals_ is a template type comparator, similar to Loki IsSameType.
 
71
// type_equals_<A, B>::value is true iff "A" is the same type as "B".
 
72
//
 
73
// New code should prefer base::is_same, defined in base/type_traits.h.
 
74
// It is functionally identical, but is_same is the standard spelling.
 
75
template<typename A, typename B>
 
76
struct type_equals_ : public false_ {
 
77
};
 
78
 
 
79
template<typename A>
 
80
struct type_equals_<A, A> : public true_ {
 
81
};
 
82
 
 
83
// and_ is a template && operator.
 
84
// and_<A, B>::value evaluates "A::value && B::value".
 
85
template<typename A, typename B>
 
86
struct and_ : public integral_constant<bool, (A::value && B::value)> {
 
87
};
 
88
 
 
89
// or_ is a template || operator.
 
90
// or_<A, B>::value evaluates "A::value || B::value".
 
91
template<typename A, typename B>
 
92
struct or_ : public integral_constant<bool, (A::value || B::value)> {
 
93
};
 
94
 
 
95
 
 
96
} // Close namespace base
 
97
 
 
98
#endif  // BASE_TEMPLATE_UTIL_H_