Newsgroups: comp.std.c++
From: a...@servocomm.freeserve.co.uk (kwikius)
Date: Fri, 9 Jul 2004 05:45:03 +0000 (UTC)
Local: Fri 9 July 2004 06:45
Subject: common result_of for operations
When working with different libraries it is quite common to find that
they have their own methods for determining the result_types of operations.In nearly all cases the functionality is pretty much the same. Here Op is a template parameter representing the operation ie '+', '-' etc. A and B are my types. Hence in working with Your library I am doing basically boilerplate: your_library_namespace{ your_result_of<Op,MyUDTa,MyUDTb>{ typedef MyOp_implementation your_result_type; }; } I would like to propose that the Op name should be standardised in std, to prevent the tedious replication of what is basically boilerplate. We already have the proposed result_of<F(A,B)>::type . All that is now Hence I propose this to relieve the tedium : result_of<operator_plus(My_TypeA,MyTypeB)>::type etcetera. In other words one common interface for operations on UDT's and As further refinement implementation of classes representing template<typename L,template<typename>class Op,typename R> Hence a multiplication between an int and a double would look like binary_operation<int,multiplies,double>::result_type. Both this and the individual operator_xx functions above play ok with result_of<binary_operation<int,multiplies,double>::type // ok The operator_multiplies interface does not then need to be template<template <typename> class Op> /* operator_ impl ... shown below */ // these just put here to get to the point struct operator_logical_or : operator_<std::logical_or>{}; struct operator_equal_to : operator_<std::not_equal_to>{}; //possibly template<template <typename> class Op> template<typename> struct result; template<typename F, typename T> template<typename L, typename R> template<typename L, typename R> template<typename T> template<typename T> regards --- You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||
| Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy |
| ©2009 Google |