Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
functional.h
00001 ///\file 00002 00003 /****************************************************************************** 00004 The MIT License(MIT) 00005 00006 Embedded Template Library. 00007 https://github.com/ETLCPP/etl 00008 http://www.etlcpp.com 00009 00010 Copyright(c) 2014 jwellbelove 00011 00012 Permission is hereby granted, free of charge, to any person obtaining a copy 00013 of this software and associated documentation files(the "Software"), to deal 00014 in the Software without restriction, including without limitation the rights 00015 to use, copy, modify, merge, publish, distribute, sublicense, and / or sell 00016 copies of the Software, and to permit persons to whom the Software is 00017 furnished to do so, subject to the following conditions : 00018 00019 The above copyright notice and this permission notice shall be included in all 00020 copies or substantial portions of the Software. 00021 00022 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00023 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00024 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE 00025 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00026 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00027 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00028 SOFTWARE. 00029 ******************************************************************************/ 00030 00031 #ifndef __ETL_FUNCTIONAL__ 00032 #define __ETL_FUNCTIONAL__ 00033 00034 #include "platform.h " 00035 00036 ///\defgroup functional functional 00037 ///\ingroup utilities 00038 00039 ///\defgroup reference_wrapper reference_wrapper 00040 ///\ingroup functional 00041 00042 namespace etl 00043 { 00044 //*************************************************************************** 00045 /// A definition of reference_wrapper for those that don't have C++ 0x11 support. 00046 ///\ingroup reference 00047 //*************************************************************************** 00048 template <typename T> 00049 class reference_wrapper 00050 { 00051 public: 00052 00053 typedef T type; 00054 00055 explicit reference_wrapper(T& t_) 00056 : t(&t_) 00057 { 00058 } 00059 00060 operator T& () const 00061 { 00062 return *t; 00063 } 00064 00065 reference_wrapper<T>& operator = (T value) 00066 { 00067 *t = value; 00068 return *this; 00069 } 00070 00071 T& get() const 00072 { 00073 return *t; 00074 } 00075 00076 private: 00077 00078 T* t; 00079 }; 00080 00081 //*************************************************************************** 00082 template <typename T> 00083 reference_wrapper<T> ref(T& t) 00084 { 00085 return reference_wrapper<T>(t); 00086 } 00087 00088 //*************************************************************************** 00089 template <typename T> 00090 reference_wrapper<T> ref(reference_wrapper<T> t) 00091 { 00092 return reference_wrapper<T>(t.get()); 00093 } 00094 00095 //*************************************************************************** 00096 template <typename T> 00097 reference_wrapper<const T> cref(const T& t) 00098 { 00099 return reference_wrapper<const T>(t); 00100 } 00101 00102 //*************************************************************************** 00103 template <typename T> 00104 reference_wrapper<const T> cref(reference_wrapper<T> t) 00105 { 00106 return reference_wrapper<const T>(t.get()); 00107 } 00108 } 00109 00110 #endif 00111 00112
Generated on Tue Jul 12 2022 14:05:41 by
