Commit e37e6813 by Ville Voutilainen Committed by Jonathan Wakely

Implement std::experimental::fundamentals_v2::propagate_const.

2015-07-03  Ville Voutilainen  <ville.voutilainen@gmail.com>

	Implement std::experimental::fundamentals_v2::propagate_const.
	* include/Makefile.am: Add propagate_const.
	* include/Makefile.in: Regenerate.
	* include/experimental/propagate_const: New.
	* testsuite/experimental/propagate_const/assignment/copy.cc: Likewise.
	* testsuite/experimental/propagate_const/assignment/move.cc: Likewise.
	* testsuite/experimental/propagate_const/assignment/move_neg.cc:
	Likewise.
	* testsuite/experimental/propagate_const/cons/copy.cc: Likewise.
	* testsuite/experimental/propagate_const/cons/default.cc: Likewise.
	* testsuite/experimental/propagate_const/cons/move.cc: Likewise.
	* testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise.
	* testsuite/experimental/propagate_const/hash/1.cc: Likewise.
	* testsuite/experimental/propagate_const/observers/1.cc: Likewise.
	* testsuite/experimental/propagate_const/relops/1.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements1.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements2.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements3.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements4.cc: Likewise.
	* testsuite/experimental/propagate_const/requirements5.cc: Likewise.
	* testsuite/experimental/propagate_const/swap/1.cc: Likewise.
	* testsuite/experimental/propagate_const/typedefs.cc: Likewise.

From-SVN: r225379
parent 805a5406
2015-07-03 Ville Voutilainen <ville.voutilainen@gmail.com>
Implement std::experimental::fundamentals_v2::propagate_const.
* include/Makefile.am: Add propagate_const.
* include/Makefile.in: Regenerate.
* include/experimental/propagate_const: New.
* testsuite/experimental/propagate_const/assignment/copy.cc: Likewise.
* testsuite/experimental/propagate_const/assignment/move.cc: Likewise.
* testsuite/experimental/propagate_const/assignment/move_neg.cc:
Likewise.
* testsuite/experimental/propagate_const/cons/copy.cc: Likewise.
* testsuite/experimental/propagate_const/cons/default.cc: Likewise.
* testsuite/experimental/propagate_const/cons/move.cc: Likewise.
* testsuite/experimental/propagate_const/cons/move_neg.cc: Likewise.
* testsuite/experimental/propagate_const/hash/1.cc: Likewise.
* testsuite/experimental/propagate_const/observers/1.cc: Likewise.
* testsuite/experimental/propagate_const/relops/1.cc: Likewise.
* testsuite/experimental/propagate_const/requirements1.cc: Likewise.
* testsuite/experimental/propagate_const/requirements2.cc: Likewise.
* testsuite/experimental/propagate_const/requirements3.cc: Likewise.
* testsuite/experimental/propagate_const/requirements4.cc: Likewise.
* testsuite/experimental/propagate_const/requirements5.cc: Likewise.
* testsuite/experimental/propagate_const/swap/1.cc: Likewise.
* testsuite/experimental/propagate_const/typedefs.cc: Likewise.
2015-07-02 Jonathan Wakely <jwakely@redhat.com>
* acinclude.m4 (GLIBCXX_DEFAULT_ABI): Change valid arguments for
......
......@@ -657,6 +657,7 @@ experimental_headers = \
${experimental_srcdir}/memory \
${experimental_srcdir}/numeric \
${experimental_srcdir}/optional \
${experimental_srcdir}/propagate_const \
${experimental_srcdir}/ratio \
${experimental_srcdir}/set \
${experimental_srcdir}/string \
......
......@@ -946,6 +946,7 @@ experimental_headers = \
${experimental_srcdir}/memory \
${experimental_srcdir}/numeric \
${experimental_srcdir}/optional \
${experimental_srcdir}/propagate_const \
${experimental_srcdir}/ratio \
${experimental_srcdir}/set \
${experimental_srcdir}/string \
......
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2015 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
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
using std::experimental::propagate_const;
int main()
{
int dummy;
propagate_const<int*> test1;
propagate_const<int*> test2;
test2 = test1; // { dg-error "deleted" }
test2 = &dummy;
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <testsuite_hooks.h>
#include <utility>
#include <memory>
using std::experimental::propagate_const;
using std::unique_ptr;
int main()
{
const int dummy{42};
propagate_const<const int*> test1;
test1 = std::move(&dummy);
test1 = &dummy;
VERIFY(test1.get() == &dummy);
propagate_const<const int*> test2;
test2 = std::move(test1);
VERIFY(test1.get() == &dummy);
VERIFY(test2.get() == &dummy);
propagate_const<const int*> test3;
test3 = std::move(test2);
VERIFY(test1.get() == &dummy);
VERIFY(test2.get() == &dummy);
VERIFY(test3.get() == &dummy);
propagate_const<unique_ptr<const int>> test4;
test4 = std::make_unique<int>(666);
}
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <testsuite_hooks.h>
#include <utility>
#include <memory>
using std::experimental::propagate_const;
using std::unique_ptr;
// { dg-error "no type" "" { target *-*-* } 158 }
int main()
{
propagate_const<unique_ptr<const int>> test5;
test5 = new int{666}; // { dg-error "no match" }
const int* dummy2 = new int{666};
propagate_const<unique_ptr<const int>> test6;
test6 = dummy2; // { dg-error "no match" }
}
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2015 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
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
using std::experimental::propagate_const;
int main()
{
propagate_const<int*> test1;
propagate_const<int*> test2{test1}; // { dg-error "deleted" }
propagate_const<int*> test3 = test1; // { dg-error "deleted" }
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2015 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
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <testsuite_hooks.h>
using std::experimental::propagate_const;
int main()
{
constexpr propagate_const<int*> test1{};
static_assert(!test1.get(), "");
propagate_const<int*> test2;
VERIFY(!test2.get());
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <testsuite_hooks.h>
#include <utility>
#include <memory>
using std::experimental::propagate_const;
using std::unique_ptr;
int main()
{
const int dummy{42};
propagate_const<const int*> test1{&dummy};
VERIFY(test1.get() == &dummy);
propagate_const<const int*> test2{std::move(test1)};
VERIFY(test1.get() == &dummy);
VERIFY(test2.get() == &dummy);
propagate_const<const int*> test3{std::move(test2)};
VERIFY(test1.get() == &dummy);
VERIFY(test2.get() == &dummy);
VERIFY(test3.get() == &dummy);
propagate_const<unique_ptr<const int>> test4{std::make_unique<int>(666)};
propagate_const<unique_ptr<const int>> test5{new int{666}};
const int* dummy2 = new int{666};
propagate_const<unique_ptr<const int>> test6{dummy2};
}
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <testsuite_hooks.h>
#include <utility>
#include <memory>
using std::experimental::propagate_const;
using std::unique_ptr;
// { dg-error "no type" "" { target *-*-* } 117 }
// { dg-error "no type" "" { target *-*-* } 124 }
// { dg-error "no type" "" { target *-*-* } 133 }
// { dg-error "no type" "" { target *-*-* } 142 }
int main()
{
const int dummy{42};
propagate_const<const int*> test1{&dummy};
propagate_const<int*> test2{&dummy}; // { dg-error "no matching function" }
propagate_const<int*> test3{std::move(test1)}; // { dg-error "no matching function" }
propagate_const<unique_ptr<const int>> test4 = &dummy; // { dg-error "conversion" }
propagate_const<unique_ptr<const int>> test5 = std::move(test1); // { dg-error "conversion" }
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <testsuite_hooks.h>
using std::experimental::propagate_const;
using std::hash;
int main()
{
int x{42};
int y{666};
propagate_const<int*> xx{&x};
propagate_const<int*> yy{&y};
VERIFY(hash<int*>{}(&x) == hash<propagate_const<int*>>{}(xx));
VERIFY(hash<int*>{}(&y) == hash<propagate_const<int*>>{}(yy));
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <testsuite_hooks.h>
using std::experimental::propagate_const;
using std::hash;
int main()
{
int x{42};
propagate_const<int*> xx{&x};
VERIFY(bool(xx));
propagate_const<int*> xx2{};
VERIFY(!bool(xx2));
struct X {int x;};
X x3{42};
propagate_const<X*> xx3{&x3};
VERIFY(xx3->x == 42);
VERIFY((*xx3).x == 42);
VERIFY(xx3.get() == &x3);
const propagate_const<X*> xx4{&x3};
VERIFY(xx4->x == 42);
VERIFY((*xx4).x == 42);
VERIFY(xx4.get() == &x3);
static constexpr int x4{42};
constexpr propagate_const<const int*> xx5{&x4};
static_assert(bool(xx5), "");
constexpr propagate_const<const int*> xx6{};
static_assert(!bool(xx6), "");
struct X2 {int x;};
static constexpr X2 x5{42};
constexpr propagate_const<const X2*> xx7{&x5};
static_assert(xx7->x == 42, "");
static_assert((*xx7).x == 42, "");
static_assert(xx7.get() == &x5, "");
struct X3
{
int f() {return 42;}
int f() const {return 666;}
};
X3 xx8;
propagate_const<X3*> xx9{&xx8};
const propagate_const<X3*> xx10{&xx8};
VERIFY(xx9->f() == 42);
VERIFY(xx10->f() == 666);
}
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <testsuite_hooks.h>
using std::experimental::propagate_const;
using std::hash;
int main()
{
int x[2];
propagate_const<int*> xx1{&x[0]};
propagate_const<int*> xx2{&x[1]};
VERIFY(xx1 == xx1);
VERIFY(xx1 != xx2);
VERIFY(xx1 < xx2);
VERIFY(xx2 > xx1);
VERIFY(xx1 <= xx2);
VERIFY(xx2 >= xx1);
VERIFY(xx1 <= xx1);
VERIFY(xx2 >= xx2);
VERIFY(std::equal_to<propagate_const<int*>>{}(xx1, xx1));
VERIFY(std::not_equal_to<propagate_const<int*>>{}(xx1, xx2));
VERIFY(std::less<propagate_const<int*>>{}(xx1, xx2));
VERIFY(std::greater<propagate_const<int*>>{}(xx2, xx1));
VERIFY(std::less_equal<propagate_const<int*>>{}(xx1, xx2));
VERIFY(std::greater_equal<propagate_const<int*>>{}(xx2, xx1));
VERIFY(std::less_equal<propagate_const<int*>>{}(xx1, xx1));
VERIFY(std::greater_equal<propagate_const<int*>>{}(xx2, xx2));
static constexpr int x2[2]{};
constexpr propagate_const<const int*> xx3{&x2[0]};
constexpr propagate_const<const int*> xx4{&x2[1]};
static_assert(xx3 == xx3, "");
static_assert(xx3 != xx4, "");
static_assert(xx3 < xx4, "");
static_assert(xx4 > xx3, "");
static_assert(xx3 <= xx4, "");
static_assert(xx4 >= xx3, "");
static_assert(xx3 <= xx3, "");
static_assert(xx4 >= xx4, "");
static_assert(std::equal_to<propagate_const<const int*>>{}(xx3, xx3), "");
static_assert(std::not_equal_to<propagate_const<const int*>>{}(xx3, xx4), "");
static_assert(std::less<propagate_const<const int*>>{}(xx3, xx4), "");
static_assert(std::greater<propagate_const<const int*>>{}(xx4, xx3), "");
static_assert(std::less_equal<propagate_const<const int*>>{}(xx3, xx4), "");
static_assert(std::greater_equal<propagate_const<const int*>>{}(xx4, xx3), "");
static_assert(std::less_equal<propagate_const<const int*>>{}(xx3, xx3), "");
static_assert(std::greater_equal<propagate_const<const int*>>{}(xx4, xx4), "");
}
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2013-2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <memory>
using std::experimental::propagate_const;
using std::unique_ptr;
using std::shared_ptr;
propagate_const<int*> test1;
propagate_const<const int*> test2;
propagate_const<unique_ptr<int>> test3;
propagate_const<unique_ptr<const int>> test4;
propagate_const<const unique_ptr<int>> test5;
propagate_const<const unique_ptr<const int>> test6;
propagate_const<shared_ptr<int>> test7;
propagate_const<shared_ptr<const int>> test8;
propagate_const<const shared_ptr<int>> test9;
propagate_const<const shared_ptr<const int>> test10;
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
using std::experimental::propagate_const;
// { dg-error "requires a class or a pointer to an object type" "" { target *-*-* } 104 }
// { dg-error "not a pointer-to-object type" "" { target *-*-* } 65 }
// { dg-error "forming pointer to reference type" "" { target *-*-* } 184 }
// { dg-error "forming pointer to reference type" "" { target *-*-* } 210 }
propagate_const<void*> test1;
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
using std::experimental::propagate_const;
// { dg-error "requires a class or a pointer to an object type" "" { target *-*-* } 104 }
propagate_const<void (*)()> test1;
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
using std::experimental::propagate_const;
// { dg-error "requires a class or a pointer to an object type" "" { target *-*-* } 104 }
// { dg-error "invalid type" "" { target *-*-* } 65 }
// { dg-error "uninitialized reference member" "" { target *-*-* } 111 }
propagate_const<int&> test1; // { dg-error "use of deleted function" }
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
using std::experimental::propagate_const;
// { dg-error "requires a class or a pointer to an object type" "" { target *-*-* } 104 }
propagate_const<int[1]> test1;
// { dg-options "-std=gnu++14" }
// { dg-do run }
// Copyright (C) 2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <testsuite_hooks.h>
using std::experimental::propagate_const;
int main()
{
int x{42};
int y{666};
propagate_const<int*> xx{&x};
propagate_const<int*> yy{&y};
VERIFY(*xx == 42);
VERIFY(*yy == 666);
swap(xx, yy);
VERIFY(*xx == 666);
VERIFY(*yy == 42);
}
// { dg-options "-std=gnu++14" }
// { dg-do compile }
// Copyright (C) 2014-2015 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 moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/propagate_const>
#include <type_traits>
#include <stdexcept>
template <typename T>
using check1_t = std::experimental::fundamentals_v2::propagate_const<T>;
template <typename T>
using check2_t
= typename std::experimental::fundamentals_v2::propagate_const<T>::element_type;
static_assert(std::is_same<check2_t<int*>, int>::value,
"element_type must be based on the pointer");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment