От: | niXman | https://github.com/niXman | |
Дата: | 09.04.13 11:12 | ||
Оценка: |
#include <iostream>
struct io_service {};
struct socket_type { socket_type(io_service &){} };
struct queue_type {};
enum class itype {
tcp, udp
};
template<itype>
struct impl;
template<>
struct impl<itype::tcp> {
impl(socket_type &, queue_type &)
{}
};
template<>
struct impl<itype::udp> {
impl(socket_type &, queue_type &)
{}
};
template<itype ST>
struct socket: impl<ST> {
socket(io_service &ios)
:_sock(ios) // 1
,_queue() // 2
,impl<ST>(_sock, _queue)// 3
{}
socket_type _sock;
queue_type _queue;
};
int main() {
io_service ios;
socket<itype::tcp> sock(ios);
}
проблемный участок обозначен циферками.source.cpp: In instantiation of 'socket<ST>::socket(io_service&) [with itype ST = (itype)0]':
source.cpp:42:31: required from here
source.cpp:36:15: warning: 'socket<(itype)0>::_queue' will be initialized after [-Wreorder]
queue_type _queue;
^
source.cpp:32:30: warning: base 'impl<(itype)0>' [-Wreorder]
,impl<ST>(_sock, _queue)// 3
^
source.cpp:29:4: warning: when initialized here [-Wreorder]
socket(io_service &ios)
^