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

Side by Side Diff: base/bind_internal_win.h

Issue 1781843003: Remove CallbackParamTraits and CallbackForward (Closed) Base URL: https://chromium.googlesource.com/chromium/src.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 | « no previous file | base/callback_internal.h » ('j') | base/callback_internal.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Specializations of RunnableAdapter<> for Windows specific calling 5 // Specializations of RunnableAdapter<> for Windows specific calling
6 // conventions. Please see base/bind_internal.h for more info. 6 // conventions. Please see base/bind_internal.h for more info.
7 7
8 #ifndef BASE_BIND_INTERNAL_WIN_H_ 8 #ifndef BASE_BIND_INTERNAL_WIN_H_
9 #define BASE_BIND_INTERNAL_WIN_H_ 9 #define BASE_BIND_INTERNAL_WIN_H_
10 10
11 #include <utility>
12
11 #include "build/build_config.h" 13 #include "build/build_config.h"
12 14
13 // In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all 15 // In the x64 architecture in Windows, __fastcall, __stdcall, etc, are all
14 // the same as __cdecl which would turn the following specializations into 16 // the same as __cdecl which would turn the following specializations into
15 // multiple definitions. 17 // multiple definitions.
16 #if !defined(ARCH_CPU_X86_64) 18 #if !defined(ARCH_CPU_X86_64)
17 19
18 namespace base { 20 namespace base {
19 namespace internal { 21 namespace internal {
20 22
21 template <typename Functor> 23 template <typename Functor>
22 class RunnableAdapter; 24 class RunnableAdapter;
23 25
24 // __stdcall Function. 26 // __stdcall Function.
25 template <typename R, typename... Args> 27 template <typename R, typename... Args>
26 class RunnableAdapter<R(__stdcall *)(Args...)> { 28 class RunnableAdapter<R(__stdcall *)(Args...)> {
27 public: 29 public:
28 // MSVC 2013 doesn't support Type Alias of function types. 30 // MSVC 2013 doesn't support Type Alias of function types.
29 // Revisit this after we update it to newer version. 31 // Revisit this after we update it to newer version.
30 typedef R RunType(Args...); 32 typedef R RunType(Args...);
31 33
32 explicit RunnableAdapter(R(__stdcall *function)(Args...)) 34 explicit RunnableAdapter(R(__stdcall *function)(Args...))
33 : function_(function) { 35 : function_(function) {
34 } 36 }
35 37
36 R Run(typename CallbackParamTraits<Args>::ForwardType... args) { 38 template <typename... RunArgs>
37 return function_(args...); 39 R Run(RunArgs&&... args) {
40 return function_(std::forward<RunArgs>(args)...);
38 } 41 }
39 42
40 private: 43 private:
41 R (__stdcall *function_)(Args...); 44 R (__stdcall *function_)(Args...);
42 }; 45 };
43 46
44 // __fastcall Function. 47 // __fastcall Function.
45 template <typename R, typename... Args> 48 template <typename R, typename... Args>
46 class RunnableAdapter<R(__fastcall *)(Args...)> { 49 class RunnableAdapter<R(__fastcall *)(Args...)> {
47 public: 50 public:
48 // MSVC 2013 doesn't support Type Alias of function types. 51 // MSVC 2013 doesn't support Type Alias of function types.
49 // Revisit this after we update it to newer version. 52 // Revisit this after we update it to newer version.
50 typedef R RunType(Args...); 53 typedef R RunType(Args...);
51 54
52 explicit RunnableAdapter(R(__fastcall *function)(Args...)) 55 explicit RunnableAdapter(R(__fastcall *function)(Args...))
53 : function_(function) { 56 : function_(function) {
54 } 57 }
55 58
56 R Run(typename CallbackParamTraits<Args>::ForwardType... args) { 59 template <typename... RunArgs>
57 return function_(args...); 60 R Run(RunArgs&&... args) {
61 return function_(std::forward<RunArgs>(args)...);
58 } 62 }
59 63
60 private: 64 private:
61 R (__fastcall *function_)(Args...); 65 R (__fastcall *function_)(Args...);
62 }; 66 };
63 67
64 } // namespace internal 68 } // namespace internal
65 } // namespace base 69 } // namespace base
66 70
67 #endif // !defined(ARCH_CPU_X86_64) 71 #endif // !defined(ARCH_CPU_X86_64)
68 72
69 #endif // BASE_BIND_INTERNAL_WIN_H_ 73 #endif // BASE_BIND_INTERNAL_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | base/callback_internal.h » ('j') | base/callback_internal.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698