Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
FunctorUtils.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* FunctorUtils.h (C) 2000-2018 */
9/* */
10/* Fonctions utilitaires pour les fonctors. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_FUNCTORUTILS_H
13#define ARCANE_UTILS_FUNCTORUTILS_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/Functor.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23ARCANE_BEGIN_NAMESPACE
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace functor
29{
31template<typename LambdaType,typename A1> StdFunctorWithArgumentT<A1>
32make(const LambdaType& f,void (LambdaType::*)(A1 r) const)
33{
34 return StdFunctorWithArgumentT<A1>(f);
35}
36
45template<typename LambdaType> auto
46make(const LambdaType& f) -> decltype(make(f,&LambdaType::operator()))
47{
48 return make(f,&LambdaType::operator());
49}
50
52template<typename LambdaType,typename A1> StdFunctorWithArgumentT<A1>*
53makePointer(const LambdaType& f,void (LambdaType::*)(A1 r) const)
54{
55 return new StdFunctorWithArgumentT<A1>(f);
56}
57
67template<typename LambdaType> auto
68makePointer(const LambdaType& f) -> decltype(makePointer(f,&LambdaType::operator()))
69{
70 return makePointer(f,&LambdaType::operator());
71}
72
73/*---------------------------------------------------------------------------*/
74/*---------------------------------------------------------------------------*/
100template<typename LambdaType,typename T,typename ArgType> void
101apply(T* x,void (T::*ptr)(IFunctorWithArgumentT<ArgType>*),const LambdaType& f)
102{
103 auto xstr = make(f);
104 (x->*ptr)(&xstr);
105}
106}
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
110
111ARCANE_END_NAMESPACE
112
113/*---------------------------------------------------------------------------*/
114/*---------------------------------------------------------------------------*/
115
116#endif
117
Déclarations des types utilisés dans Arcane.