Good name for this meta programming class ?

Started by
5 comments, last by Alberth 5 years, 7 months ago

Hi all,
I'm very picky about names and recently I had to add a meta programming class to have one function which accept char, int, float, double, T& and T*.
if it's only reference or pointer you would call it TConstPtrOrRef like that:


/*!
\brief
	Constant pointer or reference of T.
*/
template< class T >
struct TConstPtrOrRef
{
	typedef const T& Type; //!< Type.
};

/*!
\brief
	Constant pointer or reference of T.
*/
template< class T >
struct TConstPtrOrRef< T* >
{
	typedef const T* Type; //!< Type.
};

But if you add char, int, float and double then it's not only ref or ptr.
Any opinion of a good name ?
Thank you

Advertisement

Your family of overloaded functions or your function template (why do you have a struct template instead in your code example?) should not try to list types in its name; it should be named for what it does. Forbidding unsuitable types is a job for the function implementation, presumably by testing compile-time predicates.

Omae Wa Mou Shindeiru

My general rule of naming is, no matter what you name your variables and functions,  there are people who will look at your code and think your names are stupid. So IMO you might as well not spend a lot of time mulling over it.

On 9/19/2018 at 4:33 AM, Gnollrunner said:

My general rule of naming is, no matter what you name your variables and functions,  there are people who will look at your code and think your names are stupid. So IMO you might as well not spend a lot of time mulling over it.

I completely disagree. The fact that you can't make everybody happy doesn't mean that you shouldn't try to make anybody happy. Names should be picked so they facilitate the process of reading the code. The person reading the code could be you in a few months, so try to make life easier for yourself by using good names.

On 9/19/2018 at 12:13 AM, Alundra said:

Any opinion of a good name?

TConstDatatype

TConstPrimitiveType

TConstBasicType

As @LorenzoGatti says, name it on function. I was thinking "ReadOnly<T>"

This topic is closed to new replies.

Advertisement