Opened 10 years ago

Closed 10 years ago

#7381 closed Bugs (fixed)

C++11 compliance: unresolved symbol when assigning a constexpr duration to a non-const local variable

Reported by: viboes Owned by: viboes
Milestone: Boost 1.52.0 Component: chrono
Version: Boost 1.51.0 Severity: Problem
Keywords: constexpr duration Cc:

Description

When assigning a template static value member of type constexpr boost::chrono::duration to a non-const local variable

template <int Val, typename Type>
struct dummy
{
  typedef Type type;
  static constexpr type value{static_cast<type>(Val)};
};

void aTest(){
   auto z3 = dummy2<7,boost::chrono::hours>::value;
}

There is an unresolved symbol link error.

The reason is that the boost::chrono::duration copy constructor must be =default on c++11 so that the type can be used as a constexpr.

Removing the following declaration in boost/chrono/duration

  BOOST_CONSTEXPR duration(const duration& rhs) : rep_(rhs.rep_) {} // = default;

solves the issue.

Change History (4)

comment:1 by viboes, 10 years ago

Status: newassigned

comment:2 by viboes, 10 years ago

Component: threadchrono

comment:3 by viboes, 10 years ago

Keywords: constexpr duration added
Milestone: To Be DeterminedBoost 1.52.0

Committed in trunk revision [80536].

comment:4 by viboes, 10 years ago

Resolution: fixed
Status: assignedclosed

Merged [80714]

Note: See TracTickets for help on using tickets.