AWS SDK for C++  0.12.9
AWS SDK for C++
AWSFunction.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #pragma once
17 
18 #include <aws/core/Core_EXPORTS.h>
19 
21 #include <functional>
22 
23 #ifndef __GNUG__
24 
25 namespace Aws
26 {
27 
28 template<typename F>
29 std::function< F > BuildFunction(const F& f)
30 {
31  return std::function< F >( std::allocator_arg_t(), Aws::Allocator<void>(), f );
32 }
33 
34 // some things, like bind results, don't implicity convert to direct function types, catch those with specializations
35 template<typename F>
36 std::function< F > BuildFunction(const std::function< F >& f)
37 {
38  return std::function< F >( std::allocator_arg_t(), Aws::Allocator<void>(), f );
39 }
40 
41 template<typename F>
42 std::function< F > BuildFunction(std::function< F >&& f)
43 {
44  return std::function< F >( std::allocator_arg_t(), Aws::Allocator<void>(), f );
45 }
46 
47 } // namespace Aws
48 
49 #else // __GNUG__
50 
51 namespace Aws
52 {
53 
54 // gcc does not yet support passing allocators into functions
55 
56 template<typename F>
57 F BuildFunction(F f)
58 {
59  return f;
60 }
61 
62 // some things, like bind results, don't implicity convert to direct function types, catch those with specializations
63 template<typename F>
64 std::function< F > BuildFunction(const std::function< F >& f)
65 {
66  return std::function< F >( f );
67 }
68 
69 template<typename F>
70 std::function< F > BuildFunction(std::function< F >&& f)
71 {
72  return std::function< F >( std::move(f));
73 }
74 
75 } // namespace Aws
76 
77 #endif // __GNUG__
78 
79 #define AWS_BUILD_FUNCTION(func) Aws::BuildFunction(func)
80 #define AWS_BUILD_TYPED_FUNCTION(func, type) Aws::BuildFunction<type>(func)
std::function< F > BuildFunction(const F &f)
Definition: AWSFunction.h:29
std::allocator< T > Allocator
Definition: AWSAllocator.h:94
JSON (JavaScript Object Notation).