I'm using gcc 4.8.5 with C++11 and I'm trying to understand if the following behavior is normal or if it is a C++11 limitation / compiler bug.
Basically I get an undefined reference error to a constexpr tuple if I define it inside a class but not if I define it globally.
Following is the complete test code:
// file foo.h
#pragma once
#include <tuple>
struct ObjectStruct
  {
  int a;
  int b;
  };
static constexpr auto g_elements_ = std::make_tuple(
  1,
  2);
struct ObjectInfo
  {
  static constexpr auto elements_ = std::make_tuple(
    1,
    2);
  };
// File tuple_iterator.h
#pragma once
#include <tuple>
template<class Object, class Value, std::size_t I = 0, typename... Tp>
inline typename std::enable_if<I == sizeof...(Tp), void>::type
  iterateT(Object& object, const std::tuple<Tp...>& t, Value value)
  {
  std::cout << "base: " << std::to_string(I) << std::endl;
  }
template<class Object, class Value, std::size_t I = 0, typename... Tp>
inline typename std::enable_if<I < sizeof...(Tp), void>::type
  iterateT(Object& object, const std::tuple<Tp...>& t, Value value)
  {
    std::cout << "N: " << std::to_string(I) << std::endl;
    auto ele = std::get<I>(t);
    // DO something with ele
    iterateT<Object, Value, I + 1, Tp...>(object, t, value);
  }
// file main.cpp
#include <iostream>
#include "foo.h"
#include "tuple_iterator.h"
using namespace std;
int
main ()
{
  ObjectStruct object;
  iterateT (object, ObjectInfo::elements_, 5);
  iterateT (object, g_elements_, 5);
  return 0;
}
I get Error: undefined reference to ObjectInfo::elements_
As I said, no error for the global g_elements_ tuple.
I'd like to create a tuple with make_tuple avoiding the need to specify the arguments to a std::tuple.
Any possible explanation of this behaviour?
 
    