I get confused over min and max functions, in certain contexts.In one context, when you're using the functions to take the greater or lesser of two values, there is no issue. For example, //how many autographed CD's can I give out?int howManyAutographs(int CDs, int Cases, int Pens){    //if no pens, then I cannot sign any autographs    if (Pens == 0)        return 0;    //I cannot give away a CD without a case or a case without a CD    return min(CDs, Cases);}Easy. But in another context, I get confused. If I'm trying to set a maximum or minimum, I get it backwards.//return the sum, with a maximum of 255int cappedSumWRONG(int x, int y){    return max(x + y, 255); //nope, this is wrong}//return the sum, with a maximum of 255int cappedSumCORRECT(int x, int y){    return min(x + y, 255); //much better, but counter-intuitive to my mind}Is it inadvisable to make my own functions as follows?//return x, with a maximum of maxint maximize(int x, int max){    return min(x, max);}//return x, with a minimum of minint minimize(int x, int min){    return max(x, min)}Obviously, using the builtins will be faster but this seems like a needless microoptimization to me. Is there any other reason this would be inadvisable? What about in a group project?
Is it inadvisable to make a function that essentially renames a built-in function?
design;functions;readability
As others have already mentioned: don't create a function with a name that is similar to that of a builtin, standard-library or generally widely used function but change its behavior. It is possible to get used to a naming convention even if it doesn't make much sense to you at first sight but it will be impossible to reason about the functioning of your code once you introduce those other functions that do the same thing but have their names swapped.Instead of overloading the names used by the standard library, use new names that convey precisely what you mean. In your case, you're not really interested in a minimum. Rather, you want to cap a value. Mathematically, this is the same operation but semantically, it is not quite. So why not just a functionint cap(int value, int limit) { return (value > limit) ? limit : value; }that does what is needed and tells so from its name. (You could also implement capin terms of min as shown in timster's answer).Another frequently used function name is clamp. It takes three arguments and clamps a provided value into the interval defined by the other two values.int clamp(int value, int lower, int upper) {    assert(lower <= upper);  // precondition check    if (value < lower) return lower;    else if (value > upper) return upper;    else return value;}If you're using such a generally known function name, any new person joining your team (including the future you coming back to the code after a while) will quickly understand what is going on instead of cursing you for having confused them by breaking their expectations about function names they thought they knew.