mirror of
				https://github.com/pocketpy/pocketpy
				synced 2025-10-26 14:30:17 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			45 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /***************************************************************************
 | |
| * Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht          *
 | |
| * Copyright (c) QuantStack                                                 *
 | |
| *                                                                          *
 | |
| * Distributed under the terms of the BSD 3-Clause License.                 *
 | |
| *                                                                          *
 | |
| * The full license is in the file LICENSE, distributed with this software. *
 | |
| ****************************************************************************/
 | |
| 
 | |
| #ifndef XTL_FUNCTIONAL_HPP
 | |
| #define XTL_FUNCTIONAL_HPP
 | |
| 
 | |
| #include <utility>
 | |
| 
 | |
| #include "xtl_config.hpp"
 | |
| #include "xtype_traits.hpp"
 | |
| 
 | |
| namespace xtl
 | |
| {
 | |
|     /***************************
 | |
|      * identity implementation *
 | |
|      ***************************/
 | |
| 
 | |
|     struct identity
 | |
|     {
 | |
|         template <class T>
 | |
|         T&& operator()(T&& x) const
 | |
|         {
 | |
|             return std::forward<T>(x);
 | |
|         }
 | |
|     };
 | |
| 
 | |
|     /*************************
 | |
|      * select implementation *
 | |
|      *************************/
 | |
| 
 | |
|     template <class B, class T1, class T2, XTL_REQUIRES(all_scalar<B, T1, T2>)>
 | |
|     inline std::common_type_t<T1, T2> select(const B& cond, const T1& v1, const T2& v2) noexcept
 | |
|     {
 | |
|         return cond ? v1 : v2;
 | |
|     }
 | |
| }
 | |
| 
 | |
| #endif
 |