Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: mojo/public/cpp/system/macros.h

Issue 1770493002: Remove MOJO_STATIC_CONST_MEMBER_DEFINITION. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/transport_data.cc ('k') | mojo/public/cpp/system/tests/macros_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Define a set of C++ specific macros. 5 // Define a set of C++ specific macros.
6 // Mojo C++ API users can assume that mojo/public/cpp/system/macros.h 6 // Mojo C++ API users can assume that mojo/public/cpp/system/macros.h
7 // includes mojo/public/c/system/macros.h. 7 // includes mojo/public/c/system/macros.h.
8 8
9 #ifndef MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_ 9 #ifndef MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_
10 #define MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_ 10 #define MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // by default.) 57 // by default.)
58 #define MOJO_MOVE_ONLY_TYPE(type) \ 58 #define MOJO_MOVE_ONLY_TYPE(type) \
59 public: \ 59 public: \
60 type&& Pass() MOJO_WARN_UNUSED_RESULT { return std::move(*this); } \ 60 type&& Pass() MOJO_WARN_UNUSED_RESULT { return std::move(*this); } \
61 typedef void MoveOnlyTypeForCPP03; \ 61 typedef void MoveOnlyTypeForCPP03; \
62 \ 62 \
63 private: \ 63 private: \
64 type(const type&) = delete; \ 64 type(const type&) = delete; \
65 void operator=(const type&) = delete 65 void operator=(const type&) = delete
66 66
67 // The C++ standard requires that static const members have an out-of-class
68 // definition (in a single compilation unit), but MSVC chokes on this (when
69 // language extensions, which are required, are enabled). (You're only likely to
70 // notice the need for a definition if you take the address of the member or,
71 // more commonly, pass it to a function that takes it as a reference argument --
72 // probably an STL function.) This macro makes MSVC do the right thing. See
73 // http://msdn.microsoft.com/en-us/library/34h23df8(v=vs.100).aspx for more
74 // information. This workaround does not appear to be necessary after VS2015.
75 // Use like:
76 //
77 // In the .h file:
78 // struct Foo {
79 // static const int kBar = 5;
80 // };
81 //
82 // In the .cc file:
83 // MOJO_STATIC_CONST_MEMBER_DEFINITION const int Foo::kBar;
84 #if defined(_MSC_VER) && _MSC_VER < 1900
85 #define MOJO_STATIC_CONST_MEMBER_DEFINITION __declspec(selectany)
86 #else
87 #define MOJO_STATIC_CONST_MEMBER_DEFINITION
88 #endif
89
90 namespace mojo { 67 namespace mojo {
91 68
92 // Used to explicitly mark the return value of a function as unused. (Use this 69 // Used to explicitly mark the return value of a function as unused. (Use this
93 // if you are really sure you don't want to do anything with the return value of 70 // if you are really sure you don't want to do anything with the return value of
94 // a function marked with |MOJO_WARN_UNUSED_RESULT|. 71 // a function marked with |MOJO_WARN_UNUSED_RESULT|.
95 template <typename T> 72 template <typename T>
96 inline void ignore_result(const T&) { 73 inline void ignore_result(const T&) {
97 } 74 }
98 75
99 } // namespace mojo 76 } // namespace mojo
100 77
101 #endif // MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_ 78 #endif // MOJO_PUBLIC_CPP_SYSTEM_MACROS_H_
OLDNEW
« no previous file with comments | « mojo/edk/system/transport_data.cc ('k') | mojo/public/cpp/system/tests/macros_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698