Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #12310

Re: Template argument deduction and function pointers

From 88888 Dihedral <dihedral88888@googlemail.com>
Newsgroups comp.lang.c++
Subject Re: Template argument deduction and function pointers
Date 2011-12-10 07:22 -0800
Organization http://groups.google.com
Message-ID <32687049.683.1323530571695.JavaMail.geo-discussion-forums@prol32> (permalink)
References <1246304802345211522.169679troplin-bluewin.ch@news.aioe.org> <19632393.652.1323524517570.JavaMail.geo-discussion-forums@prol32> <1337659521345220519.215885troplin-bluewin.ch@news.aioe.org>

Show all headers | View raw


On Saturday, December 10, 2011 10:40:59 PM UTC+8, Tobias Müller wrote:
> 88888 Dihedral <dihedr...@googlemail.com> wrote:
> > On Saturday, December 10, 2011 8:31:58 PM UTC+8, Tobias Müller wrote:
> >> template <typename R, typename P1, typename P2, R (*f)(P1,P2)>
> >> class MyClass
> >> {
> >>   R myMethod(P1 param1, P2 param2);
> >> };
> >> 
> >> This works, however I must always specify all the template arguments R, P1,
> >> and P2, even if those could always be deduced from the 4th argument f:
> >> 
> >> int fun(double a, int b);
> >> 
> >> MyClass<int, double, int, &fun> myObject;
> >> int c = myObject.myMethod(1.0, 2);
> >> 
> >> But I want some different template such that I can write:
> >> 
> >> MyClass<&fun> myObject;
> >> 
> >> All the information about R, P1, and P2 is already implicitly there.
> >> 
> >> Tobi
> > 
> > There's no saving in typing. 
> > Just use a functor in c elegantly.
> 
> Of course not, if the function always has the same signature. But I don't
> want to define a class for every function signature I use in that way,
> especially if I can (potentially) solve it via a template.
> 
> Tobi

http://www.newty.de/fpt/fpt.html

Check the true functional c /c++! 

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Template argument deduction and function pointers Tobias Müller <troplin@bluewin.ch> - 2011-12-10 12:31 +0000
  Re: Template argument deduction and function pointers 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-10 05:41 -0800
    Re: Template argument deduction and function pointers Tobias Müller <troplin@bluewin.ch> - 2011-12-10 14:40 +0000
      Re: Template argument deduction and function pointers 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-10 07:22 -0800
        Re: Template argument deduction and function pointers Tobias Müller <troplin@bluewin.ch> - 2011-12-10 18:53 +0000
          Re: Template argument deduction and function pointers 88888 Dihedral <dihedral88888@googlemail.com> - 2011-12-10 11:20 -0800
            Re: Template argument deduction and function pointers "Heinz Ozwirk" <hozwirk@arcor.de> - 2011-12-11 18:59 +0100
              Re: Template argument deduction and function pointers jgk@panix.com (Joe keane) - 2011-12-14 20:56 +0000
                Re: Template argument deduction and function pointers Ian Collins <ian-news@hotmail.com> - 2011-12-15 10:04 +1300
                Re: Template argument deduction and function pointers gwowen <gwowen@gmail.com> - 2011-12-14 23:36 -0800
                Re: Template argument deduction and function pointers Nobody <nobody@nowhere.com> - 2011-12-15 22:53 +0000
            Re: Template argument deduction and function pointers Tobias Müller <troplin@bluewin.ch> - 2011-12-13 07:13 +0000
  Re: Template argument deduction and function pointers "Paul" <pchrist<nospam>or@yahoo.co.uk> - 2011-12-12 13:42 +0000
  Re: Template argument deduction and function pointers Leigh Johnston <leigh@i42.co.uk> - 2011-12-12 14:01 +0000
    Re: Template argument deduction and function pointers Tobias Müller <troplin@bluewin.ch> - 2011-12-13 07:13 +0000
      Re: Template argument deduction and function pointers Leigh Johnston <leigh@i42.co.uk> - 2011-12-13 12:18 +0000

csiph-web