Path: blob/master/src/hotspot/share/metaprogramming/integralConstant.hpp
40930 views
/*1* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_METAPROGRAMMING_INTEGRALCONSTANT_HPP25#define SHARE_METAPROGRAMMING_INTEGRALCONSTANT_HPP262728// An Integral Constant is a class providing a compile-time value of an29// integral type. An Integral Constant is also a nullary metafunction,30// returning itself. An integral constant object is implicitly31// convertible to the associated value.32//33// A type n is a model of Integral Constant if it meets the following34// requirements:35//36// n::ValueType : The integral type of n::value37// n::value : An integral constant expression38// n::type : IsSame<n::type, n>::value is true39// n::value_type const c = n() : c == n::value4041// A model of the Integer Constant concept.42// T is an integral type, and is the value_type.43// v is an integral constant, and is the value.44template<typename T, T v>45struct IntegralConstant {46typedef T value_type;47static const value_type value = v;48typedef IntegralConstant<T, v> type;49operator value_type() { return value; }50};5152// A bool valued IntegralConstant whose value is true.53typedef IntegralConstant<bool, true> TrueType;5455// A bool valued IntegralConstant whose value is false.56typedef IntegralConstant<bool, false> FalseType;5758#endif // SHARE_METAPROGRAMMING_INTEGRALCONSTANT_HPP596061