🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2238

Re: Determining between classes and built-in t

#2238
From: Scott Howlett
Date: Wed, 18 Oct 1995 13:37
31 lines
1810 bytes
In article <...>, martelli@cadlab.cadlab.it (Alex Martelli) wrote:

> template <class T> inline bool can_memmove(const T&) { return false; }
> inline bool can_memmove(const int&) { return true; } // etc

Perhaps this would be better as something like the following:

template<class T> class type_traits {
    enum { can_memmove = true };
};

class type_traits<foo> {
    enum { can_memmove = false };
};

etc.

That way you get the answer to can_memmove at compile time. Not only
does this save you code (both time and space) but it allows you to
do things which require compile-time constants, such as using
type_traits<T>::can_memmove as a parameter to some other template.

-- 
--
Scott Howlett
Storm Software, Inc.
howlett@netcom.com
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <howlett-1710952158260001@192.0.2.1>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <Pine.SGI.3.91.951003143924.20596A-100000@gusak> <450v2o$f3g@engnews2.Eng.Sun.COM> <45mor5$fms@jupiter.SJSU.EDU> <martelli.813831475@cadlab> <VANDEVOD.95Oct16193053@avs.cs.rpi.edu> <martelli.813918684@cadlab>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 18 Oct 95 13:37:17 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
From: howlett@netcom.com (Scott Howlett)
Subject: Re: Determining between classes and built-in t
Message-ID: <howlett-1710952158260001@192.0.2.1>
Sender: howlett@netcom.com (J. Scott Howlett)
Organization: Storm Software, Inc.
References: <Pine.SGI.3.91.951003143924.20596A-100000@gusak>    <450v2o$f3g@engnews2.Eng.Sun.COM> <45mor5$fms@jupiter.SJSU.EDU>         <martelli.813831475@cadlab> <VANDEVOD.95Oct16193053@avs.cs.rpi.edu> <martelli.813918684@cadlab>
X-Original-Date: Wed, 18 Oct 1995 04:52:10 GMT
Apparently-To: comp-std-c++@uunet.uu.net
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMIUDFuEDnX0m9pzZAQHG3gF9GWiF3vdPl4hAa1HpEVtpVuS6v86+o6Yh
 VIRC0Y2hvvq5kFj0ryj5SN27yTfvoZjD
 =29DG