From patchwork Sat Jun 8 16:12:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 249963 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1FB972C029B for ; Sun, 9 Jun 2013 02:12:47 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; q= dns; s=default; b=Uy7pO9vZmcJs8+VyThH/rPVSXs5XHAmPKaTrdXCP4i38gD GeqDQ9c9BopB4rGIqM4vTJOST1FSsHUBV43JSGgk/Vbih8RoHgzCWMBvX+iW8alk OhHqadcimpzqZ6wLQofAGCBcnZp6yxIAOiHtb/X1QzmRD+SyGAMmWpbZhDwZI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:date:message-id:subject:from:to:content-type; s= default; bh=EzzE3C403tDRhbnDfM3ZXG/x0nk=; b=rEBWUumOLSdUoC6qZbXF /5x+3MbstrtKmhNeLJQBrLeZL4AC5PbnNQdrxiRifixUMwIA+HQjEFRhPd/rNUyP piHlPrt7mfaRVM1HC1MHhhhA/cMwirqZij2duErkblxmGLpBH6UkLQoh5CebP01X xuMm4gS3yEanKhXcQSyfxVo= Received: (qmail 21730 invoked by alias); 8 Jun 2013 16:12:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 21711 invoked by uid 89); 8 Jun 2013 16:12:32 -0000 X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mail-la0-f48.google.com (HELO mail-la0-f48.google.com) (209.85.215.48) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sat, 08 Jun 2013 16:12:31 +0000 Received: by mail-la0-f48.google.com with SMTP id lx15so3511321lab.7 for ; Sat, 08 Jun 2013 09:12:29 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.152.27.137 with SMTP id t9mr1317363lag.28.1370707948998; Sat, 08 Jun 2013 09:12:28 -0700 (PDT) Received: by 10.112.168.163 with HTTP; Sat, 8 Jun 2013 09:12:28 -0700 (PDT) Date: Sat, 8 Jun 2013 17:12:28 +0100 Message-ID: Subject: [patch] N3545 change to std::integral_constant From: Jonathan Wakely To: "libstdc++" , gcc-patches X-Virus-Found: No Another C++14 feature. * include/std/type-traits (integral_constant::operator()): Implement N3545. * testsuite/20_util/integral_constant/call_operator.cc: New. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error line numbers. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. Tested x86_64-linux, committed to trunk. commit e3b2b5a9475b7146469e6cb4c35a140c7506df63 Author: Jonathan Wakely Date: Sat Jun 8 16:45:53 2013 +0100 * include/std/type-traits (integral_constant::operator()): Implement N3545. * testsuite/20_util/integral_constant/call_operator.cc: New. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error line numbers. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index a0a8327..99d0a5b 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -60,6 +60,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef _Tp value_type; typedef integral_constant<_Tp, __v> type; constexpr operator value_type() const { return value; } +#if __cplusplus > 201103L + constexpr value_type operator()() const { return value; } +#endif }; template diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc index ad82190..5b5a8eb 100644 --- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // . -// { dg-error "static assertion failed" "" { target *-*-* } 1859 } +// { dg-error "static assertion failed" "" { target *-*-* } 1862 } #include diff --git a/libstdc++-v3/testsuite/20_util/integral_constant/call_operator.cc b/libstdc++-v3/testsuite/20_util/integral_constant/call_operator.cc new file mode 100644 index 0000000..c5b0385 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/integral_constant/call_operator.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } +// +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include //testsuite_hooks.h> + +typedef std::integral_constant ic_one; +typedef std::integral_constant ic_zero; +typedef std::integral_constant ic_minus_one; + +typedef std::integral_constant ic_true; +typedef std::integral_constant ic_false; + +static_assert( ic_one{}() == 1, "1" ); +static_assert( ic_zero{}() == 0, "0" ); +static_assert( ic_minus_one{}() == -1, "-1" ); + +static_assert( ic_true{}() == true, "true" ); +static_assert( ic_false{}() == false, "false" ); diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index 077e327..afb7336 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1601 } -// { dg-error "declaration of" "" { target *-*-* } 1565 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1604 } +// { dg-error "declaration of" "" { target *-*-* } 1568 } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index 2bc1cbb..ba5f582 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1519 } -// { dg-error "declaration of" "" { target *-*-* } 1483 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1522 } +// { dg-error "declaration of" "" { target *-*-* } 1486 }