bool
stemplate
struct just_another_container;
bool
, if you make a mistake on the order of arguments, you could hardly discover it before the program goes mad.Another approach is, to merge all
bool
s to a single unsigned
, liketemplate
struct just_another_container;
enum {
ALLOW_DUP_MASK = 1,
SORT_ELE_MASK = 2,
CHECK_OUT_OF_RANGE_MASK = 4,
};
insert
interface to the container, which is concerned about whether or not allows duplicated elements in the container, the code may look likevoid insert(element_type e)
{
_insert(e);
}
template <>
void _insert<0>(element_type e);
template <>
void _insert(element_type e);
_insert
into a template struct
, liketemplate
struct insert_s
{
static void insert(just_a_container& container, element_type& e);
};
template <>
struct insert_s
{
static void insert(just_a_container& container, element_type& e);
};
struct insert_s
, It should be granted public access to just_a_container
.Besides, in the code there would be full of bitwise-and here and there like