Create a distinct type from a builtin numeric type. More...
#include <limits>
Go to the source code of this file.
Data Structures | |
class | ts::NumericType< T, X > |
Numeric type template. More... | |
Namespaces | |
namespace | ts |
Apache Traffic Server commons. | |
Functions | |
template<typename T , typename X > | |
NumericType< T, X > | ts::operator+ (T const &lhs, NumericType< T, X > const &rhs) |
template<typename T , typename X > | |
NumericType< T, X > | ts::operator- (T const &lhs, NumericType< T, X > const &rhs) |
Create a distinct type from a builtin numeric type.
This template class converts a basic type into a class, so that instances of the class act like the basic type in normal use but as a distinct type when evaluating overloads. This is very handy when one has several distinct value types that map to the same basic type. That means we can have overloads based on the type even though the underlying basic type is the same. The second template argument, X, is used only for distinguishing instantiations of the template with the same base type. It doesn't have to exist. One can declare an instantiation like
typedef NumericType<int, struct some_random_tag_name> some_random_type;
It is not necessary to ever mention some_random_tag_name again. All we need is the entry in the symbol table.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file NumericType.h.