Opened 10 years ago

Last modified 10 years ago

#7934 new Bugs

tuples::element returns wrong typesss for bolatile tuples

Reported by: ptomulik@… Owned by: Joel de Guzman
Milestone: To Be Determined Component: tuple
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

Hi,

according to c++11, volatile tuples should return volatile elements. I think, boost tuple should behave similarly, however it doesn't.

Below is an example with two tests, one test for boost tuple and one for standard tuple. The boost tuple test fails.

// file a.cpp
#define BOOST_TEST_MODULE example
#include <boost/test/included/unit_test.hpp>
#include <boost/type_traits.hpp>
#include <boost/tuple/tuple.hpp>
#include <tuple>

BOOST_AUTO_TEST_CASE( boost_tuple )
{
  using boost::is_same;
  using boost::tuple;
  using boost::tuples::element;
  typedef element<0, volatile tuple<int> > VElement;
  typedef element<0, const volatile tuple<int> > CVElement;
  BOOST_CHECK((is_same<typename VElement::type, volatile int>::value));
  BOOST_CHECK((is_same<typename CVElement::type, const volatile int>::value));
}

BOOST_AUTO_TEST_CASE( std_tuple )
{
  using boost::is_same;
  using std::tuple;
  using std::tuple_element;
  typedef tuple_element<0, volatile tuple<int> > VElement;
  typedef tuple_element<0, const volatile tuple<int> > CVElement;
  BOOST_CHECK((is_same<typename VElement::type, volatile int>::value));
  BOOST_CHECK((is_same<typename CVElement::type, const volatile int>::value));
}
ptomulik@barakus$ g++ -ansi -std=c++11 -Werror -Wall -Wextra -pedantic a.cpp
ptomulik@barakus$ ./a.out
Running 2 test cases...
a.cpp(15): error in "boost_tuple": check (is_same<typename VElement::type, volatile int>::value) failed
a.cpp(16): error in "boost_tuple": check (is_same<typename CVElement::type, const volatile int>::value) failed

*** 2 failures detected in test suite "example"

my gcc version

ptomulik@barakus:$ g++ --version
g++ (Debian 4.7.2-5) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Change History (1)

comment:1 by Joel de Guzman, 10 years ago

I am not really the maintainer of Boost Tuple so I can't do anything about it. I can, however, make sure that Fusion gets this correctly.

Note: See TracTickets for help on using tickets.